/**
 * Plugin de Agendamiento - Sistema de Diseno Moderno v2.1
 * Diseno flat, limpio y responsive
 */

/* =============================================
   VARIABLES CSS - SISTEMA DE DISENO
   ============================================= */
:root {
    /* Colores Principales */
    --ag-primary: #1d4ed8;
    --ag-primary-hover: #1e40af;
    --ag-primary-light: #eff6ff;
    --ag-primary-rgb: 29, 78, 216;

    /* Fondos */
    --ag-bg-page: #f1f5f9;
    --ag-bg-card: #ffffff;
    --ag-bg-input: #f8fafc;
    --ag-bg-hover: #f1f5f9;

    /* Textos */
    --ag-text-primary: #1e293b;
    --ag-text-secondary: #64748b;
    --ag-text-muted: #94a3b8;

    /* Bordes */
    --ag-border-color: #e2e8f0;
    --ag-border-light: #f1f5f9;

    /* Estados */
    --ag-success: #22c55e;
    --ag-success-light: #dcfce7;
    --ag-error: #ef4444;
    --ag-error-light: #fee2e2;

    /* Sombras */
    --ag-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --ag-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
    --ag-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
    --ag-shadow-card: 0 4px 20px rgba(0, 0, 0, 0.04);
    --ag-shadow-primary: 0 4px 14px rgba(var(--ag-primary-rgb), 0.25);

    /* Bordes Redondeados */
    --ag-radius-sm: 8px;
    --ag-radius-md: 12px;
    --ag-radius-lg: 16px;
    --ag-radius-xl: 20px;
    --ag-radius-pill: 50px;

    /* Transiciones */
    --ag-transition: all 0.2s ease;

    /* Espaciado */
    --ag-space-xs: 4px;
    --ag-space-sm: 8px;
    --ag-space-md: 16px;
    --ag-space-lg: 24px;
    --ag-space-xl: 32px;
}

/* =============================================
   RESET Y BASE
   ============================================= */
.agendamiento-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--ag-text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.agendamiento-wrapper *,
.agendamiento-wrapper *::before,
.agendamiento-wrapper *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* =============================================
   LAYOUT PRINCIPAL - DOS TARJETAS
   ============================================= */
.agendamiento-form {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: var(--ag-space-lg);
    max-width: 1100px;
    margin: 0 auto;
    padding: var(--ag-space-lg);
    background: var(--ag-bg-page);
    border-radius: var(--ag-radius-xl);
}

@media (max-width: 900px) {
    .agendamiento-form {
        grid-template-columns: 1fr;
        padding: var(--ag-space-md);
        gap: var(--ag-space-md);
    }
}

/* =============================================
   TARJETAS
   ============================================= */
.agendamiento-card {
    background: var(--ag-bg-card);
    border-radius: var(--ag-radius-xl);
    box-shadow: var(--ag-shadow-card);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.card-header {
    display: flex;
    align-items: center;
    gap: var(--ag-space-md);
    padding: var(--ag-space-lg) var(--ag-space-lg) 0;
}

.card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--ag-primary-light);
    border-radius: var(--ag-radius-md);
    color: var(--ag-primary);
    flex-shrink: 0;
}

.card-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--ag-text-primary);
}

.card-body {
    padding: var(--ag-space-lg);
    flex: 1;
}

.card-footer {
    padding: var(--ag-space-md) var(--ag-space-lg);
    border-top: 1px solid var(--ag-border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ag-space-md);
    background: var(--ag-bg-input);
}

@media (max-width: 500px) {
    .card-footer {
        flex-direction: column;
        text-align: center;
    }
}

/* =============================================
   CAMPOS DEL FORMULARIO
   ============================================= */
.fields-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ag-space-md);
}

.field-group {
    width: 100%;
}

.field-group.field-half {
    width: calc(50% - var(--ag-space-sm));
}

@media (max-width: 500px) {
    .field-group.field-half {
        width: 100%;
    }
}

.field-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--ag-text-secondary);
    margin-bottom: var(--ag-space-sm);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.form-control {
    width: 100%;
    padding: 14px var(--ag-space-md);
    font-size: 15px;
    font-family: inherit;
    color: var(--ag-text-primary);
    background: var(--ag-bg-card);
    border: 2px solid var(--ag-border-color);
    border-radius: var(--ag-radius-md);
    transition: var(--ag-transition);
    outline: none;
}

.form-control::placeholder {
    color: var(--ag-text-muted);
}

.form-control:hover {
    border-color: #cbd5e1;
}

.form-control:focus {
    border-color: var(--ag-primary);
    box-shadow: 0 0 0 4px rgba(var(--ag-primary-rgb), 0.1);
}

textarea.form-control {
    resize: vertical;
    min-height: 90px;
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--ag-space-md) center;
    padding-right: 48px;
}

/* =============================================
   BANNER DE SOPORTE
   ============================================= */
.support-banner {
    position: relative;
    margin: var(--ag-space-sm) var(--ag-space-lg) var(--ag-space-lg);
    padding: var(--ag-space-lg);
    background: var(--ag-primary);
    border-radius: var(--ag-radius-lg);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ag-space-md);
}

.support-content {
    color: #fff;
    position: relative;
    z-index: 1;
}

.support-content h4 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 2px;
}

.support-content p {
    font-size: 13px;
    opacity: 0.85;
}

.support-btn {
    display: inline-flex;
    align-items: center;
    padding: 10px 20px;
    background: #fff;
    color: var(--ag-primary);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    border-radius: var(--ag-radius-pill);
    transition: var(--ag-transition);
    white-space: nowrap;
    position: relative;
    z-index: 1;
    border: none;
    cursor: pointer;
}

.support-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.support-icon-bg {
    position: absolute;
    right: -10px;
    bottom: -10px;
    color: #fff;
}

@media (max-width: 500px) {
    .support-banner {
        flex-direction: column;
        text-align: center;
        padding: var(--ag-space-md);
        margin: var(--ag-space-sm) var(--ag-space-md) var(--ag-space-md);
    }
}

/* =============================================
   CALENDARIO - CONTENEDOR
   ============================================= */
.availability-calendar {
    min-height: 280px;
}

.calendar-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px var(--ag-space-lg);
    color: var(--ag-text-secondary);
}

.loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--ag-border-color);
    border-top-color: var(--ag-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin-bottom: var(--ag-space-md);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-message,
.error-message {
    text-align: center;
    padding: 40px var(--ag-space-lg);
    color: var(--ag-text-secondary);
}

.error-message {
    color: var(--ag-error);
}

/* =============================================
   CALENDARIO - NAVEGACION SUPERIOR
   ============================================= */
.calendar-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--ag-space-lg);
}

.nav-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--ag-bg-card);
    border: 2px solid var(--ag-border-color);
    border-radius: var(--ag-radius-md);
    color: var(--ag-text-primary);
    cursor: pointer;
    transition: var(--ag-transition);
}

.nav-arrow:hover:not(.nav-arrow-disabled) {
    border-color: var(--ag-primary);
    color: var(--ag-primary);
    background: var(--ag-primary-light);
}

.nav-arrow-disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.calendar-month {
    font-size: 16px;
    font-weight: 600;
    color: var(--ag-text-primary);
    text-transform: capitalize;
}

/* =============================================
   CALENDARIO - CARRUSEL DE DIAS
   ============================================= */
.days-carousel {
    display: flex;
    gap: var(--ag-space-sm);
    margin-bottom: var(--ag-space-lg);
    overflow-x: auto;
    padding-bottom: var(--ag-space-sm);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.days-carousel::-webkit-scrollbar {
    display: none;
}

.day-pill {
    flex: 1;
    min-width: 64px;
    padding: var(--ag-space-md) var(--ag-space-sm);
    background: var(--ag-bg-card);
    border: 2px solid var(--ag-border-color);
    border-radius: var(--ag-radius-lg);
    text-align: center;
    cursor: pointer;
    transition: var(--ag-transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.day-pill:hover:not(.day-pill-blocked):not(.day-pill-selected) {
    border-color: var(--ag-primary);
    background: var(--ag-primary-light);
}

.day-pill-selected {
    background: var(--ag-primary);
    border-color: var(--ag-primary);
    box-shadow: var(--ag-shadow-primary);
}

.day-pill-selected .day-pill-name,
.day-pill-selected .day-pill-number {
    color: #fff;
}

.day-pill-blocked {
    opacity: 0.4;
    cursor: not-allowed;
    background: var(--ag-bg-input);
}

.day-pill-empty {
    opacity: 0.6;
}

.day-pill-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--ag-text-secondary);
    letter-spacing: 0.5px;
}

.day-pill-number {
    font-size: 22px;
    font-weight: 700;
    color: var(--ag-text-primary);
    line-height: 1;
}

/* =============================================
   CALENDARIO - SECCIONES MANANA/TARDE
   ============================================= */
.time-slots-container {
    min-height: 140px;
}

.select-day-message,
.no-slots-message {
    text-align: center;
    padding: var(--ag-space-xl) var(--ag-space-md);
    color: var(--ag-text-muted);
    font-size: 14px;
}

.time-section {
    margin-bottom: var(--ag-space-lg);
}

.time-section:last-child {
    margin-bottom: 0;
}

.time-section-header {
    display: flex;
    align-items: center;
    gap: var(--ag-space-sm);
    margin-bottom: var(--ag-space-md);
    color: var(--ag-text-secondary);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.time-section-icon {
    color: var(--ag-text-muted);
}

/* =============================================
   CALENDARIO - SLOTS DE HORA (HORIZONTAL)
   ============================================= */
.time-slots-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ag-space-sm);
}

.time-slot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 70px;
    padding: 10px var(--ag-space-md);
    font-size: 14px;
    font-weight: 500;
    color: var(--ag-text-primary);
    background: var(--ag-bg-card);
    border: 2px solid var(--ag-border-color);
    border-radius: var(--ag-radius-pill);
    text-decoration: none;
    cursor: pointer;
    transition: var(--ag-transition);
}

.time-slot:hover {
    border-color: var(--ag-primary);
    color: var(--ag-primary);
    background: var(--ag-primary-light);
}

.time-slot.selected {
    background: var(--ag-primary);
    border-color: var(--ag-primary);
    color: #fff;
    box-shadow: var(--ag-shadow-primary);
}

.time-slot.unavailable {
    background: var(--ag-bg-input);
    color: var(--ag-text-muted);
    text-decoration: line-through;
    cursor: not-allowed;
    pointer-events: none;
}

/* =============================================
   FOOTER - RESUMEN Y BOTON
   ============================================= */
.selected-summary {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.summary-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--ag-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.summary-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--ag-primary);
}

.btn-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--ag-space-sm);
    padding: 14px var(--ag-space-lg);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    color: #fff;
    background: var(--ag-primary);
    border: none;
    border-radius: var(--ag-radius-pill);
    cursor: pointer;
    transition: var(--ag-transition);
    white-space: nowrap;
    min-width: 180px;
}

.btn-submit:hover:not(:disabled) {
    background: var(--ag-primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--ag-shadow-primary);
}

.btn-submit:disabled {
    background: var(--ag-text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-submit svg {
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.btn-submit:hover:not(:disabled) svg {
    transform: translateX(3px);
}

.btn-loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@media (max-width: 500px) {
    .btn-submit {
        width: 100%;
    }

    .selected-summary {
        align-items: center;
        width: 100%;
    }
}

/* =============================================
   MENSAJES DEL FORMULARIO
   ============================================= */
.form-message {
    padding: 14px var(--ag-space-md);
    border-radius: var(--ag-radius-md);
    margin-bottom: var(--ag-space-md);
    font-size: 14px;
    font-weight: 500;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.form-message-error {
    background: var(--ag-error-light);
    color: var(--ag-error);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.form-message-success {
    background: var(--ag-success-light);
    color: var(--ag-success);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

/* =============================================
   VISTA DE CONFIRMACION EXITOSA
   ============================================= */
.success-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--ag-space-xl) var(--ag-space-lg);
    background: var(--ag-bg-card);
    border-radius: var(--ag-radius-xl);
    box-shadow: var(--ag-shadow-lg);
    max-width: 420px;
    margin: var(--ag-space-xl) auto;
}

.success-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    background: var(--ag-success-light);
    color: var(--ag-success);
    border-radius: 50%;
    margin-bottom: var(--ag-space-lg);
}

.success-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--ag-text-primary);
    margin-bottom: var(--ag-space-md);
}

.success-details {
    width: 100%;
    padding: var(--ag-space-md) var(--ag-space-lg);
    background: var(--ag-bg-input);
    border-radius: var(--ag-radius-md);
}

.success-details p {
    font-size: 14px;
    color: var(--ag-text-secondary);
    line-height: 1.6;
    margin: 0;
}

/* Compatibilidad con estructura anterior */
.alert-success {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--ag-space-xl) var(--ag-space-lg);
    background: var(--ag-bg-card);
    border-radius: var(--ag-radius-xl);
    box-shadow: var(--ag-shadow-lg);
    max-width: 420px;
    margin: var(--ag-space-xl) auto;
}

.alert-success .success-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    background: var(--ag-success-light);
    color: var(--ag-success);
    font-size: 40px;
    font-weight: bold;
    border-radius: 50%;
    margin-bottom: var(--ag-space-lg);
}

.alert-success h3 {
    font-size: 24px;
    font-weight: 700;
    color: var(--ag-text-primary);
    margin-bottom: var(--ag-space-md);
}

.alert-success p {
    font-size: 14px;
    color: var(--ag-text-secondary);
    line-height: 1.6;
    padding: var(--ag-space-md) var(--ag-space-lg);
    background: var(--ag-bg-input);
    border-radius: var(--ag-radius-md);
    margin: 0;
    width: 100%;
}

/* =============================================
   ERROR DE CONFIGURACION
   ============================================= */
.agendamiento-error {
    padding: var(--ag-space-lg);
    background: var(--ag-error-light);
    color: var(--ag-error);
    border-radius: var(--ag-radius-md);
    text-align: center;
    font-weight: 500;
}

/* =============================================
   OCULTAR ELEMENTOS LEGACY
   ============================================= */
.nav-buttons,
.week-title,
.week-grid,
.day-column,
ul.time-slots {
    display: none !important;
}

/* =============================================
   RESPONSIVE FINAL
   ============================================= */
@media (max-width: 400px) {
    .agendamiento-form {
        padding: var(--ag-space-sm);
    }

    .card-header {
        padding: var(--ag-space-md) var(--ag-space-md) 0;
    }

    .card-body {
        padding: var(--ag-space-md);
    }

    .card-icon {
        width: 38px;
        height: 38px;
    }

    .card-title {
        font-size: 15px;
    }

    .day-pill {
        min-width: 56px;
        padding: var(--ag-space-sm);
    }

    .day-pill-number {
        font-size: 18px;
    }

    .time-slot {
        min-width: 60px;
        padding: 8px var(--ag-space-sm);
        font-size: 13px;
    }

    .success-card,
    .alert-success {
        margin: var(--ag-space-md);
        padding: var(--ag-space-lg);
    }

    .success-icon-wrapper,
    .alert-success .success-icon {
        width: 64px;
        height: 64px;
    }

    .success-title,
    .alert-success h3 {
        font-size: 20px;
    }
}
