/* ============================================================
   BASE.CSS - Sistema de Diseño Unificado
   Clínica San Javier - Flujo de Citas Médicas
   ============================================================ */

/* ===== GOOGLE FONTS ===== */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');

/* ===== CSS VARIABLES ===== */
:root {
    /* Institutional colors */
    --primary: #008ea9;
    --primary-dark: #006e82;
    --primary-light: #e6f7f9;
    --secondary: #7e9100; /* WCAG AA Contrast Improvement from #a5bf00 */
    --secondary-dark: #6a7a00;
    --secondary-light: #f0f5e6;
    --danger: #b91c1c;
    --danger-dark: #991b1b;
    --danger-light: #fef2f2;
    --success: #15803d;

    /* Neutral colors */
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    /* Agendar compat aliases */
    --inst-green: #7e9100; /* WCAG AA Contrast Improvement from #a5bf00 */
    --inst-green-dark: #6a7a00;
    --inst-blue: #008ea9;
    --inst-blue-dark: #006f83;
    --inst-neutral: #f8fafc;
    --inst-neutral-dark: #64748b;
    --inst-border: #e5e7eb;

    /* Design tokens */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --radius: 1rem;
    --radius-lg: 1.5rem;
    --radius-full: 9999px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== RESET ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ===== BASE BODY ===== */
body {
    font-family: 'Montserrat', sans-serif;
    background: linear-gradient(135deg, var(--gray-50) 0%, #eef5f7 100%);
    color: var(--gray-800);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    color: var(--gray-900);
    margin-bottom: 0.5em;
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.875rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

.text-2xl {
    font-size: 1.5rem;
    line-height: 2rem;
}

.text-xl { font-size: 1.25rem; }
.text-lg { font-size: 1.125rem; }
.text-base { font-size: 1rem; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }

.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }

.uppercase { text-transform: uppercase; }
.capitalize { text-transform: capitalize; }
.tracking-wide { letter-spacing: 0.025em; }

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

/* ===== COLOR UTILITIES ===== */
.text-white { color: white; }
.text-primary { color: var(--primary); }
.text-secondary { color: var(--secondary); }
.text-danger { color: var(--danger); }
.text-gray-500 { color: var(--gray-500); }
.text-gray-600 { color: var(--gray-600); }
.text-gray-700 { color: var(--gray-700); }

.bg-white { background-color: white; }
.bg-primary { background-color: var(--primary); }
.bg-secondary { background-color: var(--secondary); }
.bg-danger { background-color: var(--danger); }
.bg-gray-50 { background-color: var(--gray-50); }
.bg-gray-100 { background-color: var(--gray-100); }

/* Agendar compat color classes */
.bg-inst-green { background-color: var(--inst-green); }
.bg-inst-blue { background-color: var(--inst-blue); }
.text-inst-green { color: var(--inst-green); }
.text-inst-blue { color: var(--inst-blue); }
.border-inst-green { border-color: var(--inst-green); }
.border-inst-blue { border-color: var(--inst-blue); }

/* ===== LAYOUT & SPACING ===== */
.container {
    width: 100%;
    max-width: 80rem;
    margin-left: auto;
    margin-right: auto;
    padding-left: 1rem;
    padding-right: 1rem;
}

.max-w-4xl { max-width: 56rem; }
.max-w-2xl { max-width: 42rem; }

.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }

.p-6 { padding: 1.5rem; }

.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mr-2 { margin-right: 0.5rem; }

.space-y-2 > * + * { margin-top: 0.5rem; }
.space-y-3 > * + * { margin-top: 0.75rem; }
.space-y-4 > * + * { margin-top: 1rem; }
.space-y-6 > * + * { margin-top: 1.5rem; }

/* ===== FLEXBOX ===== */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1 1 0%; }
.min-h-0 { min-height: 0; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }

/* ===== GRID ===== */
.grid { display: grid; }
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ===== BORDERS & RADIUS ===== */
.border { border-width: 1px; }
.border-b { border-bottom-width: 1px; }
.border-t { border-top-width: 1px; }
.border-gray-200 { border-color: var(--gray-200); }
.border-gray-300 { border-color: var(--gray-300); }
.border-primary { border-color: var(--primary); }
.border-secondary { border-color: var(--secondary); }
.border-danger { border-color: var(--danger); }

.rounded-xl { border-radius: var(--radius); }
.rounded-2xl { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }

/* ===== SHADOWS ===== */
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow { box-shadow: var(--shadow); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.shadow-xl { box-shadow: var(--shadow-xl); }

/* ===== INTERACTIONS ===== */
.opacity-50 { opacity: 0.5; }
.opacity-60 { opacity: 0.6; }
.opacity-80 { opacity: 0.8; }
.cursor-not-allowed { cursor: not-allowed; }
.transition { transition: var(--transition); }
.transition-fast { transition: var(--transition-fast); }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.875rem 1.75rem;
    border-radius: var(--radius);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    text-decoration: none;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 142, 169, 0.35);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 142, 169, 0.45);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--secondary) 0%, var(--secondary-dark) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(165, 191, 0, 0.3);
}

.btn-secondary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(165, 191, 0, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, var(--danger-dark) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(185, 28, 28, 0.3);
}

.btn-danger:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(185, 28, 28, 0.4);
}

.btn-outline {
    background-color: transparent;
    border: 2px solid var(--gray-300);
    color: var(--gray-700);
}

.btn-outline:hover:not(:disabled) {
    background-color: var(--gray-50);
    border-color: var(--gray-400);
}

.btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn-block {
    width: 100%;
}

/* ===== HEADER & FOOTER ===== */
header {
    background: linear-gradient(120deg, white 0%, #f8fbfc 100%);
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 1px solid var(--gray-200);
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.logo-img {
    width: 120px;
    height: auto;
    max-height: 60px;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-title {
    font-weight: 800;
    font-size: 1.375rem;
    color: var(--primary);
    margin-bottom: 0.125rem;
}

.logo-subtitle {
    font-size: 0.875rem;
    color: var(--gray-500);
    font-weight: 500;
}

footer {
    background: linear-gradient(120deg, white 0%, #f8fbfc 100%);
    border-top: 1px solid var(--gray-200);
    padding: 2rem 0;
    margin-top: auto;
}

.footer-text {
    font-size: 0.9375rem;
    color: var(--gray-600);
    max-width: 65ch;
    margin: 0 auto;
    line-height: 1.6;
}

/* ===== CARDS ===== */
.card {
    background-color: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    transition: var(--transition);
    margin-bottom: 2rem;
}

.card:hover {
    box-shadow: var(--shadow-xl);
}

.card-body {
    padding: 1.75rem;
}

.card-header {
    padding: 1.25rem 1.75rem;
    border-bottom: 1px solid var(--gray-200);
    background-color: var(--gray-50);
}

/* ===== FORM ELEMENTS ===== */
.form-control {
    width: 100%;
    padding: 0.875rem 1.25rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: var(--transition);
    background-color: white;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 142, 169, 0.2);
}

.form-label {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    color: var(--gray-700);
}

.form-group {
    margin-bottom: 1.5rem;
}

/* ===== SCREENS ===== */
.screen {
    display: none;
    animation: fadeIn 0.4s ease-out forwards;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.hidden {
    display: none !important;
}

/* ===== SPINNER / LOADING ===== */
.spinner {
    width: 4rem;
    height: 4rem;
    border: 4px solid rgba(0, 142, 169, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

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

/* ===== SWEETALERT2 OVERRIDES ===== */
.swal2-container {
    z-index: 10000;
}

.swal2-title {
    font-weight: 700 !important;
    color: var(--gray-900) !important;
    font-size: 1.875rem !important;
    line-height: 1.3 !important;
    margin-bottom: 0.75rem !important;
    font-family: inherit !important;
}

.swal2-html-container {
    text-align: left !important;
    color: var(--gray-700) !important;
    line-height: 1.6 !important;
    margin-bottom: 1.5rem !important;
    font-family: inherit !important;
}

.swal2-confirm {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%) !important;
    border: none !important;
    border-radius: var(--radius) !important;
    padding: 0.875rem 2rem !important;
    font-weight: 700 !important;
    font-size: 1.05rem !important;
    box-shadow: 0 4px 15px rgba(0, 142, 169, 0.35) !important;
    transition: transform 0.2s !important;
}

.swal2-confirm:hover {
    transform: translateY(-1px) !important;
    box-shadow: 0 6px 20px rgba(0, 142, 169, 0.45) !important;
}

.swal2-cancel {
    background-color: var(--gray-200) !important;
    color: var(--gray-700) !important;
    border: none !important;
    border-radius: var(--radius) !important;
    padding: 0.875rem 2rem !important;
    font-weight: 600 !important;
    transition: var(--transition) !important;
}

.swal2-cancel:hover {
    background-color: var(--gray-300) !important;
    transform: translateY(-1px) !important;
}

.swal2-icon.swal2-warning {
    border-color: var(--danger) !important;
    color: var(--danger) !important;
}

.swal2-icon.swal2-error {
    border-color: var(--danger) !important;
    color: var(--danger) !important;
}

.swal2-icon.swal2-success {
    border-color: var(--secondary) !important;
    color: var(--secondary) !important;
}

.swal2-icon.swal2-success [class^='swal2-success-line'] {
    background-color: var(--secondary) !important;
}

.swal2-icon.swal2-success [class^='swal2-success-ring'] {
    border-color: var(--secondary-light) !important;
}

/* ===== UTILITY: MISC ===== */
.w-full { width: 100%; }
.max-h-55vh { max-height: 55vh; }
.overflow-auto { overflow: auto; }
.italic { font-style: italic; }
.mx-auto { margin-left: auto; margin-right: auto; }

.text-slate-500 { color: var(--gray-500); }
.text-gray-400 { color: var(--gray-400); }
.bg-red-50 { background-color: var(--danger-light); }
.border-red-200 { border-color: #fecaca; }
.text-red-700 { color: var(--danger); }

/* SVG icon sizes */
.icon-user,
.icon-reschedule,
.icon-cancel,
.icon-info,
.icon-calendar,
.icon-tip,
.icon-warning {
    width: 16px;
    height: 16px;
    fill: currentColor;
    flex-shrink: 0;
    vertical-align: middle;
}

.icon-expiry {
    width: 32px;
    height: 32px;
    vertical-align: middle;
}

.icon-48 {
    width: 48px;
    height: 48px;
    display: inline-block;
    vertical-align: middle;
}

/* ===== RESPONSIVE BASE ===== */
@media (max-width: 640px) {
    .header-container {
        flex-direction: column;
        gap: 1.25rem;
        text-align: center;
    }

    .logo-text {
        align-items: center;
    }

    .btn-group {
        flex-direction: column;
        gap: 0.75rem;
    }

    .card-body {
        padding: 1.5rem;
    }

    h1 { font-size: 1.875rem; }
    h2 { font-size: 1.625rem; }
}

@media (max-width: 480px) {
    header {
        padding: 0.75rem 0;
    }

    .logo-title { font-size: 1.25rem; }
    .logo-subtitle { font-size: 0.8125rem; }

    .card-body {
        padding: 1.25rem;
    }

    .form-control {
        padding: 0.75rem 1rem;
        font-size: 0.9375rem;
    }

    .btn {
        padding: 0.75rem 1.5rem;
        font-size: 0.9375rem;
    }
}

@media (min-width: 1024px) {
    .container {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition: none !important;
        animation: none !important;
    }
}

/* ==================== STICKY LEGAL CONTAINER ==================== */
.sticky-legal-group {
    position: sticky;
    bottom: 0;
    z-index: 40;
    background: white;
    border-top: 1px solid var(--gray-200);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
}

.legal-consent-container {
    padding: 1rem 1.5rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--gray-100);
}

@media (max-width: 768px) {
    .legal-consent-container {
        padding: 0.75rem 1rem;
    }
}
