/* =====================================================
   SentirIA - Dashboard Styles
   ===================================================== */
:root {
    --navy: #1E2761;
    --navy-light: #2a3580;
    --crimson: #A51C30;
    --green: #27AE60;
    --yellow: #F39C12;
    --red: #E74C3C;
    --white: #ffffff;
    --gray-50: #f8f9fa;
    --gray-100: #f1f3f5;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-500: #6c757d;
    --gray-700: #495057;
    --gray-900: #212529;
    --shadow: 0 1px 3px rgba(0,0,0,.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,.12);
    --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    min-height: 100vh;
}

/* --- Layout --- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
    width: 260px;
    background: var(--navy);
    color: var(--white);
    padding: 24px 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
}
.sidebar-logo {
    font-size: 1.4rem;
    font-weight: 700;
    padding: 0 24px 24px;
    border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-logo span { color: #2ecc71; }
.sidebar-nav { padding: 16px 0; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: rgba(255,255,255,.7);
    text-decoration: none;
    font-size: .9rem;
    transition: .2s;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
    background: rgba(255,255,255,.1);
    color: var(--white);
}
.sidebar-nav a.active { border-left: 3px solid var(--green); }
.sidebar-user {
    padding: 16px 24px;
    border-top: 1px solid rgba(255,255,255,.1);
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    font-size: .85rem;
    color: rgba(255,255,255,.6);
}

.main-content {
    margin-left: 260px;
    flex: 1;
    padding: 32px;
    min-height: 100vh;
}

/* --- Header --- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}
.page-header h1 { font-size: 1.6rem; color: var(--navy); }

/* --- Cards --- */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.card-header h2 { font-size: 1.1rem; color: var(--navy); }

/* --- Stats row --- */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 24px; }
.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: var(--shadow);
}
.stat-card .stat-value { font-size: 2rem; font-weight: 700; color: var(--navy); }
.stat-card .stat-label { font-size: .85rem; color: var(--gray-500); margin-top: 4px; }
.stat-card.danger .stat-value { color: var(--red); }
.stat-card.warning .stat-value { color: var(--yellow); }
.stat-card.success .stat-value { color: var(--green); }

/* --- Tables --- */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
    text-align: left;
    padding: 12px 16px;
    font-size: .8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--gray-500);
    border-bottom: 2px solid var(--gray-200);
}
td {
    padding: 14px 16px;
    font-size: .9rem;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}
tr:hover td { background: var(--gray-50); }

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
}
.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: .75rem;
    font-weight: 700;
    background: var(--red);
    color: var(--white);
}

/* --- Trend arrows --- */
.trend-up { color: var(--red); }
.trend-down { color: var(--green); }
.trend-stable { color: var(--gray-500); }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: .9rem;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: .2s;
    font-family: inherit;
}
.btn-primary { background: var(--navy); color: var(--white); }
.btn-primary:hover { background: var(--navy-light); }
.btn-success { background: var(--green); color: var(--white); }
.btn-danger { background: var(--red); color: var(--white); }
.btn-outline { background: transparent; border: 2px solid var(--gray-300); color: var(--gray-700); }
.btn-outline:hover { border-color: var(--navy); color: var(--navy); }
.btn-sm { padding: 6px 14px; font-size: .8rem; }

/* --- Forms --- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: 6px; color: var(--gray-700); }
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: .9rem;
    font-family: inherit;
    transition: .2s;
}
.form-control:focus { outline: none; border-color: var(--navy); }
.form-inline { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.form-inline .form-group { margin-bottom: 0; }

/* --- Filters --- */
.filters {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.filters select, .filters input {
    padding: 8px 12px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: .85rem;
    font-family: inherit;
}

/* --- Alert feed --- */
.alert-feed { list-style: none; }
.alert-feed-item {
    display: flex;
    gap: 16px;
    padding: 16px;
    border-bottom: 1px solid var(--gray-100);
    align-items: flex-start;
}
.alert-feed-item:last-child { border-bottom: none; }
.alert-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 4px;
}
.alert-dot.verde { background: var(--green); }
.alert-dot.amarillo { background: var(--yellow); }
.alert-dot.rojo { background: var(--red); }
.alert-info { flex: 1; }
.alert-info strong { color: var(--navy); }
.alert-info small { color: var(--gray-500); display: block; margin-top: 4px; }
.alert-actions { display: flex; gap: 8px; }

/* --- Charts --- */
.chart-container { position: relative; height: 350px; }
.chart-controls { display: flex; gap: 8px; margin-bottom: 16px; }
.chart-controls button {
    padding: 6px 14px;
    border: 2px solid var(--gray-200);
    background: var(--white);
    border-radius: 6px;
    font-size: .8rem;
    cursor: pointer;
    font-family: inherit;
    transition: .2s;
}
.chart-controls button.active { border-color: var(--navy); background: var(--navy); color: var(--white); }

/* --- Patient detail --- */
.patient-header {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 32px;
}
.patient-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--navy);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
}
.patient-meta { flex: 1; }
.patient-meta h2 { font-size: 1.4rem; color: var(--navy); }
.patient-meta p { color: var(--gray-500); font-size: .9rem; }

.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }

/* --- PHQ-9 items --- */
.phq9-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.phq9-item {
    padding: 14px;
    border-radius: 8px;
    background: var(--gray-50);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.phq9-item .item-name { font-size: .85rem; color: var(--gray-700); }
.phq9-item .item-score {
    font-weight: 700;
    font-size: 1.1rem;
    padding: 2px 10px;
    border-radius: 6px;
}
.score-0 { background: #d4edda; color: #155724; }
.score-1 { background: #fff3cd; color: #856404; }
.score-2 { background: #ffeaa7; color: #6c5200; }
.score-3 { background: #f8d7da; color: #721c24; }

/* --- Login --- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--navy) 0%, #141c4a 100%);
}
.login-card {
    background: var(--white);
    border-radius: 16px;
    padding: 48px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}
.login-card h1 {
    text-align: center;
    font-size: 1.6rem;
    color: var(--navy);
    margin-bottom: 8px;
}
.login-card .login-subtitle {
    text-align: center;
    color: var(--gray-500);
    margin-bottom: 32px;
    font-size: .9rem;
}
.login-card .btn { width: 100%; justify-content: center; padding: 14px; }
.login-error {
    background: #f8d7da;
    color: #721c24;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: .9rem;
    margin-bottom: 16px;
}

/* --- Modal --- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--white);
    border-radius: 16px;
    padding: 32px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal h3 { margin-bottom: 20px; color: var(--navy); }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }

/* --- Responsive --- */
@media (max-width: 992px) {
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .detail-grid { grid-template-columns: 1fr; }
    .phq9-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; padding: 20px; }
    .stats-row { grid-template-columns: 1fr; }
    .phq9-grid { grid-template-columns: 1fr; }
}
