/* =============================================================================
   BestMedical - Estilos Principales
   ============================================================================= */

:root {
    /* Colores de marca BestMedical */
    --primary: #4B6E2A;           /* Verde marca: RGB(75, 110, 42) */
    --primary-dark: #3d5a22;      /* Verde oscuro */
    --primary-light: #5d8735;     /* Verde claro */
    --primary-bg: #f4f7f1;        /* Fondo verde suave */
    
    /* Colores secundarios - Negro marca */
    --secondary: #1F1F21;         /* Negro marca: RGB(31, 31, 33) */
    --secondary-light: #2d2d30;   /* Negro claro */
    
    /* Colores de estado */
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;
    
    /* Neutros */
    --white: #ffffff;
    --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;
    
    /* Tipografía */
    --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    
    /* Sombras */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    /* Transiciones */
    --transition: all 0.2s ease;
    --transition-slow: all 0.3s ease;
    
    /* Bordes */
    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 9999px;
}

/* Reset básico */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background-color: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.5;
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

/* =============================================================================
   LOGIN PAGE
   ============================================================================= */

.login-page {
    background: linear-gradient(135deg, var(--gray-900) 0%, var(--gray-800) 100%);
}

.login-container {
    display: flex;
    min-height: 100vh;
}

/* Panel de Branding (Izquierdo) */
.login-branding {
    flex: 1;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    color: var(--white);
    position: relative;
    overflow: hidden;
}

.login-branding::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 60%);
    pointer-events: none;
}

.branding-content {
    position: relative;
    z-index: 1;
}

/* Logo en página de login */
.logo-container {
    margin-bottom: 2rem;
}

.logo-img {
    max-width: 280px;
    height: auto;
    filter: brightness(0) invert(1); /* Logo blanco sobre fondo verde */
}

.tagline {
    font-size: 1.25rem;
    opacity: 0.9;
    margin-bottom: 3rem;
    font-weight: 300;
    letter-spacing: 0.05em;
}

.features {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.feature {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(255,255,255,0.1);
    border-radius: var(--radius);
    backdrop-filter: blur(10px);
}

.feature .icon {
    font-size: 1.25rem;
}

.branding-footer {
    position: relative;
    z-index: 1;
}

.branding-footer p {
    font-size: 0.875rem;
    opacity: 0.7;
}

/* Panel del Formulario (Derecho) */
.login-form-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--white);
}

.form-container {
    width: 100%;
    max-width: 400px;
}

.form-header {
    text-align: center;
    margin-bottom: 2rem;
}

.form-header h2 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
}

.form-header p {
    color: var(--gray-500);
}

/* Formulario */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 1rem;
    width: 20px;
    height: 20px;
    color: var(--gray-400);
    pointer-events: none;
}

.input-wrapper input {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 3rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    color: var(--gray-800);
    background: var(--white);
    transition: var(--transition);
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.input-wrapper input::placeholder {
    color: var(--gray-400);
}

.toggle-password {
    position: absolute;
    right: 0.75rem;
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--gray-400);
    transition: var(--transition);
}

.toggle-password:hover {
    color: var(--gray-600);
}

.toggle-password svg {
    width: 20px;
    height: 20px;
}

/* Opciones del formulario */
.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.remember-me {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--gray-600);
}

.remember-me input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--primary);
}

/* Mensajes de error */
.error-message {
    padding: 0.875rem 1rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    color: var(--error);
    font-size: 0.875rem;
    text-align: center;
}

/* Botón de login */
.btn-login {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 1rem 1.5rem;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.btn-login:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-login:active {
    transform: translateY(0);
}

.btn-login:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.spinner {
    animation: spin 1s linear infinite;
}

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

.btn-loader svg {
    width: 20px;
    height: 20px;
}

/* Footer del formulario */
.form-footer {
    margin-top: 2rem;
    text-align: center;
}

.form-footer p {
    font-size: 0.875rem;
    color: var(--gray-500);
}

/* =============================================================================
   DASHBOARD PAGE
   ============================================================================= */

.dashboard-page {
    display: flex;
    background: var(--gray-100);
}

/* Sidebar */
.sidebar {
    width: 260px;
    height: 100vh;
    background: var(--gray-900);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
    transition: var(--transition-slow);
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--gray-700);
}

.sidebar-logo-full {
    max-width: 100%;
    height: auto;
    max-height: 60px;
    object-fit: contain;
    filter: brightness(0) invert(1); /* Logo blanco como en la página de login */
}

.logo-small {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    overflow: hidden;
}

.sidebar-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: brightness(0) invert(1); /* Logo blanco */
}

.brand-name {
    font-size: 1.25rem;
    font-weight: 600;
}

/* Navegación del sidebar */
.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    color: var(--gray-400);
    border-radius: var(--radius);
    transition: var(--transition);
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-item:hover {
    background: var(--gray-800);
    color: var(--white);
}

.nav-item.active {
    background: var(--primary);
    color: var(--white);
}

/* Footer del sidebar */
.sidebar-footer {
    padding: 1rem 0.75rem;
    border-top: 1px solid var(--gray-700);
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.875rem 1rem;
    background: transparent;
    border: 1px solid var(--gray-700);
    color: var(--gray-400);
    border-radius: var(--radius);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.875rem;
    transition: var(--transition);
}

.btn-logout:hover {
    background: var(--error);
    border-color: var(--error);
    color: var(--white);
}

.btn-logout svg {
    width: 20px;
    height: 20px;
}

/* Contenido principal */
.main-content {
    flex: 1;
    margin-left: 260px;
    min-height: 100vh;
}

/* Top bar */
.topbar {
    background: var(--white);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--gray-600);
    z-index: 101;
}

.menu-toggle svg {
    width: 24px;
    height: 24px;
}

/* Overlay para cerrar sidebar en móviles */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-900);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: 600;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 500;
    color: var(--gray-900);
    font-size: 0.875rem;
}

.user-email {
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* Dashboard Content */
.dashboard-content {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Welcome Card */
.welcome-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: var(--radius-xl);
    padding: 2rem;
    color: var(--white);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.welcome-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 60%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 60%);
    pointer-events: none;
}

.welcome-text {
    position: relative;
    z-index: 1;
}

.welcome-text h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.welcome-text p {
    opacity: 0.9;
    max-width: 500px;
}

.welcome-illustration {
    position: relative;
    z-index: 1;
}

.welcome-illustration svg {
    width: 120px;
    height: 100px;
    color: var(--white);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    background: var(--primary-bg);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.stat-icon svg {
    width: 24px;
    height: 24px;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-900);
}

/* Profile Card */
.profile-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-900);
}

.btn-edit {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--gray-100);
    border: none;
    border-radius: var(--radius);
    color: var(--gray-700);
    font-size: 0.875rem;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.btn-edit:hover {
    background: var(--gray-200);
}

.btn-edit svg {
    width: 16px;
    height: 16px;
}

.card-body {
    padding: 1.5rem;
    display: grid;
    gap: 1.25rem;
}

.profile-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.profile-field label {
    font-size: 0.75rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.profile-field span {
    font-size: 1rem;
    color: var(--gray-900);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: var(--transition-slow);
}

.loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-spinner {
    text-align: center;
}

.loading-spinner svg {
    width: 48px;
    height: 48px;
    color: var(--primary);
    animation: spin 1s linear infinite;
}

.loading-spinner svg circle {
    stroke-dasharray: 90;
    stroke-dashoffset: 30;
}

.loading-spinner p {
    margin-top: 1rem;
    color: var(--gray-600);
}

/* =============================================================================
   RESPONSIVE
   ============================================================================= */

@media (max-width: 1024px) {
    .login-branding {
        display: none;
    }
    
    .login-form-panel {
        flex: 1;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }
    
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
    }
    
    .menu-toggle {
        display: block;
    }
    
    .dashboard-content {
        padding: 1rem;
    }
    
    .welcome-card {
        flex-direction: column;
        text-align: center;
        gap: 1.5rem;
    }
    
    .welcome-text p {
        max-width: none;
    }
    
    .user-details {
        display: none;
    }
    
    .topbar {
        padding: 1rem;
        flex-wrap: wrap;
        gap: 1rem;
    }
    
    .topbar-left,
    .topbar-right {
        width: 100%;
    }
    
    .topbar-right {
        justify-content: flex-start;
    }
    
    .page-title {
        font-size: 1.1rem;
    }
    
    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        padding: 1rem;
    }
    
    .content-header h1 {
        font-size: 1.25rem;
    }
    
    .main-content > .filters-section,
    .main-content > .table-container,
    .main-content > .pagination {
        padding: 0 1rem;
    }
    
    .analytics-content {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .form-container {
        padding: 0 1rem;
    }
    
    .topbar {
        padding: 0.75rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .sidebar-header {
        padding: 1rem;
    }
    
    .sidebar-logo-full {
        max-height: 50px;
    }
    
    .content-header {
        padding: 0.75rem;
    }
    
    .content-header h1 {
        font-size: 1.1rem;
    }
    
    .content-header .btn-primary {
        width: 100%;
        justify-content: center;
        padding: 0.625rem 1rem;
        font-size: 0.8125rem;
    }
    
    .filters-section {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .date-filter {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .date-input {
        flex: 1;
        min-width: 120px;
    }
    
    .btn-filter {
        width: 100%;
    }
}

