/* ========================================================================
   VidaClinica - Plataforma de Salud Inteligente
   CSS principal - Mobile First, Professional, Modern
   ======================================================================== */

/* --- Custom Properties --- */
:root {
    --vc-primary: #0f766e;
    --vc-primary-dark: #115e59;
    --vc-primary-light: #14b8a6;
    --vc-accent: #14b8a6;
    --vc-light-bg: #f0fdfa;
    --vc-text: #1e293b;
    --vc-text-muted: #64748b;
    --vc-border: #e2e8f0;
    --vc-success: #16a34a;
    --vc-warning: #ea580c;
    --vc-danger: #dc2626;
    --vc-info: #2563eb;
    --vc-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --vc-radius: 8px;
    --vc-radius-lg: 12px;
    --vc-shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --vc-shadow: 0 4px 12px rgba(0,0,0,0.08);
    --vc-shadow-lg: 0 8px 24px rgba(0,0,0,0.1);
    --vc-transition: 0.2s ease;
}

/* --- Base --- */
html {
    font-size: 14px;
    scroll-behavior: smooth;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

body {
    font-family: var(--vc-font);
    color: var(--vc-text);
    background: #fff;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.3;
}

.lead {
    font-size: 1.1rem;
    line-height: 1.7;
    color: var(--vc-text-muted);
}

/* --- Brand Colors as Utility Classes --- */
.bg-vc-primary {
    background-color: var(--vc-primary) !important;
}

.bg-vc-light {
    background-color: var(--vc-light-bg) !important;
}

.text-vc-primary {
    color: var(--vc-primary) !important;
}

.text-vc-accent {
    color: var(--vc-accent) !important;
}

.border-vc-primary {
    border-color: var(--vc-primary) !important;
}

/* --- Navbar --- */
.navbar.bg-vc-primary {
    background-color: var(--vc-primary) !important;
    box-shadow: 0 2px 8px rgba(15, 118, 110, 0.15);
}

.navbar-brand {
    font-size: 1.2rem;
    letter-spacing: -0.01em;
}

.navbar .nav-link {
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    border-radius: var(--vc-radius);
    transition: background var(--vc-transition), opacity var(--vc-transition);
}

.navbar .nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
}

.nav-link-highlight {
    background: rgba(255, 255, 255, 0.12) !important;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.navbar .dropdown-menu {
    border: 1px solid var(--vc-border);
    box-shadow: var(--vc-shadow);
    border-radius: var(--vc-radius);
    padding: 0.5rem 0;
}

.navbar .dropdown-item {
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    transition: background var(--vc-transition);
}

.navbar .dropdown-item:hover {
    background: var(--vc-light-bg);
    color: var(--vc-primary);
}

/* --- Buttons --- */
.btn-vc-primary {
    background-color: var(--vc-primary);
    border-color: var(--vc-primary);
    color: #fff;
    font-weight: 600;
    border-radius: var(--vc-radius);
    transition: background var(--vc-transition), box-shadow var(--vc-transition), transform var(--vc-transition);
}

.btn-vc-primary:hover {
    background-color: var(--vc-primary-dark);
    border-color: var(--vc-primary-dark);
    color: #fff;
    box-shadow: 0 4px 12px rgba(15, 118, 110, 0.25);
    transform: translateY(-1px);
}

.btn-vc-primary:active {
    transform: translateY(0);
}

.btn-vc-primary:focus-visible {
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.35);
}

.btn-outline-vc-primary {
    border: 2px solid var(--vc-primary);
    color: var(--vc-primary);
    background: transparent;
    font-weight: 600;
    border-radius: var(--vc-radius);
    transition: all var(--vc-transition);
}

.btn-outline-vc-primary:hover {
    background-color: var(--vc-primary);
    border-color: var(--vc-primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(15, 118, 110, 0.25);
}

.btn-outline-vc-primary:focus-visible {
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.35);
}

/* --- Cards --- */
.card {
    border-radius: var(--vc-radius-lg);
    border-color: var(--vc-border);
    transition: box-shadow var(--vc-transition);
}

.card-header {
    border-radius: var(--vc-radius-lg) var(--vc-radius-lg) 0 0 !important;
}

.card.shadow-sm {
    box-shadow: var(--vc-shadow-sm);
}

.card.shadow-sm:hover {
    box-shadow: var(--vc-shadow);
}

/* --- Forms --- */
.form-control,
.form-select {
    border-color: var(--vc-border);
    border-radius: var(--vc-radius);
    padding: 0.625rem 0.875rem;
    font-size: 0.9rem;
    transition: border-color var(--vc-transition), box-shadow var(--vc-transition);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--vc-primary-light);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15);
}

.form-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--vc-text);
    margin-bottom: 0.375rem;
}

.input-group-text {
    border-color: var(--vc-border);
    color: var(--vc-text-muted);
    font-size: 0.9rem;
}

.form-control.is-invalid {
    border-color: var(--vc-danger);
}

.invalid-feedback {
    font-size: 0.8rem;
}

/* --- Tables --- */
.table {
    font-size: 0.875rem;
}

.table thead th {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--vc-text-muted);
    border-bottom-width: 1px;
}

.table-hover tbody tr:hover {
    background-color: var(--vc-light-bg);
}

/* --- Badges --- */
.badge {
    font-weight: 600;
    font-size: 0.75rem;
    padding: 0.35em 0.75em;
    border-radius: 20px;
}

/* --- Legal Content --- */
.legal-content h2 {
    font-size: 1.3rem;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--vc-border);
}

.legal-content h3 {
    font-size: 1.1rem;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.legal-content p {
    color: var(--vc-text-muted);
    margin-bottom: 1rem;
}

.legal-content ul,
.legal-content ol {
    color: var(--vc-text-muted);
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}

.legal-content li {
    margin-bottom: 0.5rem;
}

/* --- Calculator Result Animations --- */
.result-animate {
    animation: resultFadeIn 0.5s ease forwards;
}

@keyframes resultFadeIn {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.gauge-animate .gauge-fill {
    animation: gaugeDraw 1s ease forwards;
}

@keyframes gaugeDraw {
    from {
        stroke-dashoffset: 220;
    }
}

/* --- Upload Zone --- */
.upload-zone {
    border: 2px dashed var(--vc-border);
    background: var(--vc-light-bg);
    cursor: pointer;
    transition: border-color var(--vc-transition), background var(--vc-transition);
    border-radius: var(--vc-radius-lg);
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--vc-primary);
    background: rgba(15, 118, 110, 0.04);
}

.upload-zone:focus-visible {
    outline: 2px solid var(--vc-primary);
    outline-offset: 2px;
}

/* --- Toast Notifications --- */
.vc-toast-container {
    position: fixed;
    top: 80px;
    right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 380px;
}

.vc-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--vc-radius);
    background: #fff;
    box-shadow: var(--vc-shadow-lg);
    border-left: 4px solid var(--vc-primary);
    font-size: 0.875rem;
    animation: toastSlideIn 0.3s ease;
    opacity: 1;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.vc-toast.toast-exit {
    opacity: 0;
    transform: translateX(100%);
}

.vc-toast.toast-success {
    border-left-color: var(--vc-success);
}

.vc-toast.toast-error {
    border-left-color: var(--vc-danger);
}

.vc-toast.toast-warning {
    border-left-color: var(--vc-warning);
}

.vc-toast.toast-info {
    border-left-color: var(--vc-info);
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* --- Progress Bar --- */
.progress {
    border-radius: 20px;
    background: #e5e7eb;
    overflow: hidden;
}

.progress-bar.bg-vc-primary {
    background-color: var(--vc-primary) !important;
    transition: width 0.3s ease;
}

/* --- Spinner --- */
.spinner-border.text-vc-primary {
    color: var(--vc-primary) !important;
}

/* --- Admin Dashboard --- */
.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

/* --- Footer --- */
footer {
    font-size: 0.875rem;
}

footer a {
    transition: color var(--vc-transition);
}

footer a:hover {
    color: var(--vc-accent) !important;
}

/* --- Accessibility --- */
:focus-visible {
    outline: 2px solid var(--vc-primary);
    outline-offset: 2px;
}

.visually-hidden-focusable:not(:focus):not(:focus-within) {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* --- Responsive Adjustments --- */
@media (max-width: 575.98px) {
    .container {
        padding-left: 16px;
        padding-right: 16px;
    }

    .card-body {
        padding: 1rem;
    }

    .btn-lg {
        font-size: 0.95rem;
        padding: 0.65rem 1.25rem;
    }

    .table-responsive {
        font-size: 0.8rem;
    }
}

@media (min-width: 576px) and (max-width: 767.98px) {
    .card-body {
        padding: 1.25rem;
    }
}

/* --- Print Styles --- */
@media print {
    /* Hide non-essential elements */
    .navbar,
    footer,
    .btn,
    .upload-zone,
    .vc-toast-container,
    .modal,
    .dropdown-menu,
    .navbar-toggler {
        display: none !important;
    }

    /* Reset backgrounds */
    body {
        background: #fff !important;
        color: #000 !important;
        font-size: 12pt;
    }

    .bg-vc-primary {
        background: none !important;
        color: #000 !important;
        padding: 0 !important;
    }

    .bg-vc-primary h1,
    .bg-vc-primary p {
        color: #000 !important;
    }

    /* Cards */
    .card {
        border: 1px solid #ccc !important;
        box-shadow: none !important;
        break-inside: avoid;
    }

    .card-header {
        background: #f5f5f5 !important;
    }

    .shadow-sm {
        box-shadow: none !important;
    }

    /* Links */
    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }

    a.btn::after,
    a.nav-link::after,
    a.navbar-brand::after {
        content: none;
    }

    /* Tables */
    .table {
        border-collapse: collapse;
    }

    .table th,
    .table td {
        border: 1px solid #ccc !important;
    }

    /* Page breaks */
    h2, h3 {
        page-break-after: avoid;
    }

    .card, .table, img {
        page-break-inside: avoid;
    }
}

/* --- Smooth scroll for anchor links --- */
html {
    scroll-padding-top: 70px;
}

/* --- Selection color --- */
::selection {
    background: rgba(20, 184, 166, 0.2);
    color: var(--vc-text);
}
