/* =========================================
   Variables Globales (Modo Claro por defecto)
   ========================================= */
:root {
    --primary-color: #0ea5e9;
    --primary-hover: #0284c7;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --icon-bg: #f0f9ff;
    --legacy-icon-bg: #f1f5f9;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --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);
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --radius-md: 12px;
    --radius-lg: 20px;
}

/* =========================================
   Variables Modo Oscuro
   ========================================= */
[data-theme="dark"] {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --icon-bg: #0f172a;
    --legacy-icon-bg: #334155;
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.5);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5);
}

/* =========================================
   Reset y Estilos Base
   ========================================= */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem 1rem;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* =========================================
   Botón Tema (Dark Mode)
   ========================================= */
.theme-btn {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    z-index: 100;
}

.theme-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

/* =========================================
   Contenedor y Cabecera
   ========================================= */
.dashboard-container { width: 100%; max-width: 800px; margin: 0 auto; }

.header { text-align: center; margin-bottom: 3rem; }

.header-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
    box-shadow: var(--shadow-md);
}

.header h1 { font-size: 2.25rem; font-weight: 700; letter-spacing: -0.025em; margin-bottom: 0.5rem; }
.header p { color: var(--text-muted); font-size: 1.125rem; }

/* =========================================
   Grilla y Tarjetas
   ========================================= */
.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    list-style: none;
}

.service-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    text-decoration: none;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.service-card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; height: 100%; width: 4px;
    background-color: var(--primary-color);
    transform: scaleY(0); transition: var(--transition); transform-origin: bottom;
}

.service-card:hover, .service-card:focus {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.service-card:hover::before, .service-card:focus::before { transform: scaleY(1); }

.service-icon {
    display: flex; align-items: center; justify-content: center;
    width: 48px; height: 48px;
    background-color: var(--icon-bg); color: var(--primary-color);
    border-radius: 50%; font-size: 1.5rem; flex-shrink: 0; transition: var(--transition);
}

.service-card:hover .service-icon { background-color: var(--primary-color); color: white; }

.service-info { display: flex; flex-direction: column; }
.service-title { font-weight: 600; font-size: 1.125rem; }
.service-desc { font-size: 0.875rem; color: var(--text-muted); margin-top: 0.25rem; }

/* EMR Antiguo (Legacy) */
.service-card.legacy .service-icon { background-color: var(--legacy-icon-bg); color: var(--text-muted); }
.service-card.legacy:hover { border-color: var(--text-muted); }
.service-card.legacy:hover::before { background-color: var(--text-muted); }
.service-card.legacy:hover .service-icon { background-color: var(--text-muted); color: white; }

/* =========================================
   Media Queries
   ========================================= */
@media (max-width: 600px) { .services-grid { grid-template-columns: 1fr; } }