/* ============================================================
   CENTRO MÉDICO BELÉN — Estilos Globales
   ============================================================ */

/* --- Variables --- */
:root {
    --primary:       #0d6efd;
    --primary-dark:  #0b5ed7;
    --primary-light: #cfe2ff;
    --success:       #198754;
    --danger:        #dc3545;
    --warning:       #ffc107;
    --gray-100:      #f8f9fa;
    --gray-200:      #e9ecef;
    --gray-300:      #dee2e6;
    --gray-500:      #6c757d;
    --gray-700:      #495057;
    --gray-900:      #212529;
    --white:         #ffffff;
    --shadow:        0 0.5rem 1rem rgba(0,0,0,0.1);
    --radius:        0.5rem;
    --font:          'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* --- Reset --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html { font-size: 16px; }

body {
    font-family: var(--font);
    color: var(--gray-900);
    background: var(--gray-100);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; }


/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 50%, #084298 100%);
    padding: 1rem;
}

.login-container {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-icon {
    color: var(--primary);
    margin-bottom: 1rem;
}

.login-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    color: var(--gray-900);
}

.login-subtitle {
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.login-form {
    text-align: left;
}

.login-footer {
    margin-top: 1.5rem;
    font-size: 0.8rem;
    color: var(--gray-500);
}


/* ============================================================
   FORMULARIOS
   ============================================================ */
.form-group {
    margin-bottom: 0.6rem;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.2rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-family: var(--font);
    transition: border-color 0.15s, box-shadow 0.15s;
    background: var(--white);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-group textarea {
    min-height: 60px;
    resize: vertical;
}


/* ============================================================
   BOTONES
   ============================================================ */
.btn {
    display: inline-block;
    padding: 0.6rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: var(--font);
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, opacity 0.15s;
    text-align: center;
    text-decoration: none;
}

.btn:hover { text-decoration: none; opacity: 0.9; }

.btn-primary {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-outline {
    background: transparent;
    color: var(--gray-700);
    border-color: var(--gray-300);
}

.btn-outline:hover {
    background: var(--gray-200);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-sm {
    padding: 0.3rem 0.75rem;
    font-size: 0.85rem;
}

.btn-block {
    display: block;
    width: 100%;
}


/* ============================================================
   ALERTAS
   ============================================================ */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    text-align: left;
}

.alert-error {
    background: #f8d7da;
    color: #842029;
    border: 1px solid #f5c2c7;
}

.alert-success {
    background: #d1e7dd;
    color: #0f5132;
    border: 1px solid #badbcc;
}


/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
}

.topbar-role {
    background: var(--primary-light);
    color: var(--primary);
    padding: 0.2rem 0.6rem;
    border-radius: 1rem;
    font-size: 0.8rem;
    font-weight: 600;
}

.topbar-name {
    color: var(--gray-700);
}


/* ============================================================
   LAYOUT PRINCIPAL
   ============================================================ */
.main-layout {
    display: flex;
    min-height: calc(100vh - 56px);
}

/* --- Sidebar --- */
.sidebar {
    width: 240px;
    background: var(--white);
    border-right: 1px solid var(--gray-200);
    padding: 1rem 0;
    flex-shrink: 0;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.25rem;
    color: var(--gray-700);
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
}

.nav-item:hover {
    background: var(--gray-100);
    color: var(--primary);
    text-decoration: none;
}

.nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.nav-icon {
    font-size: 1.1rem;
    width: 1.5rem;
    text-align: center;
}


/* --- Content --- */
.content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.content h2 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.text-muted {
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}


/* ============================================================
   CARDS
   ============================================================ */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    transition: box-shadow 0.15s;
}

.card:hover {
    box-shadow: var(--shadow);
}

.card-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.card-label {
    font-size: 0.85rem;
    color: var(--gray-500);
}


/* ============================================================
   TABLAS
   ============================================================ */
.table-container {
    overflow-x: auto;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th,
table td {
    padding: 0.65rem 0.75rem;
    text-align: left;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--gray-200);
}

table th {
    background: var(--gray-100);
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

table tr:last-child td {
    border-bottom: none;
}

table tr:hover td {
    background: var(--gray-100);
}


/* ============================================================
   MISC
   ============================================================ */
.info-box {
    background: var(--primary-light);
    color: var(--primary-dark);
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    margin-top: 1rem;
}

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-active {
    background: #d1e7dd;
    color: #0f5132;
}

.badge-inactive {
    background: #f8d7da;
    color: #842029;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray-500);
}

.empty-state p {
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-header h2 { margin: 0; }

.page-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.search-form {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.search-form input {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.9rem;
    width: 200px;
}

@media (max-width: 768px) {
    .search-form input { width: 140px; }
}


/* ============================================================
   FORM CARD (formularios tipo tarjeta)
   ============================================================ */
.form-card {
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    text-align: left;
}

.form-card h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--gray-700);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1rem;
}

.form-full { grid-column: 1 / -1; }

.form-actions {
    display: flex;
    gap: 0.5rem;
    padding-top: 0.5rem;
}

@media (max-width: 768px) {
    .form-grid { grid-template-columns: 1fr; }
}


/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--gray-200);
        padding: 0.5rem 0;
    }

    .sidebar-nav {
        flex-direction: row;
        overflow-x: auto;
        padding: 0 0.5rem;
    }

    .nav-item {
        white-space: nowrap;
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }

    .main-layout {
        flex-direction: column;
    }

    .content {
        padding: 1.25rem;
    }

    .cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .topbar {
        padding: 0.5rem 1rem;
    }

    .topbar-role {
        display: none;
    }
}
