:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --secondary: #64748b;
    --accent: #0ea5e9;
    --background: #f8fafc;
    --surface: #ffffff;
    --text: #0f172a;
    --text-light: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --danger: #ef4444;
    --radius: 0.75rem;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --font-sans: 'Outfit', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background-color: var(--background);
    background-image:
        linear-gradient(rgba(248, 250, 252, 0.92), rgba(248, 250, 252, 0.92)),
        url('../img/med_abstract_bg.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    line-height: 1.25;
    margin-bottom: 1rem;
}

h1 {
    font-size: 2.5rem;
    letter-spacing: -0.025em;
}

h2 {
    font-size: 2rem;
    letter-spacing: -0.025em;
}

/* Components */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
    font-size: 1rem;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
}

.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
    border: 1px solid var(--border);
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    text-align: left;
}

.table th,
.table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.table th {
    font-weight: 600;
    color: var(--text);
    background-color: var(--background);
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}

.table tbody tr:hover {
    background-color: rgba(37, 99, 235, 0.02);
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
    border-radius: var(--radius);
}

.table-responsive .table {
    min-width: 900px;
}

.text-nowrap {
    white-space: nowrap;
}

/* Navbar Premium Styles */
.navbar {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    padding: 0.75rem 2rem;
    margin-bottom: 2rem;
    transition: all 0.3s ease;
}

.navbar-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1800px;
    margin: 0 auto;
    width: 100%;
    padding: 0.75rem 2rem;
    flex-wrap: wrap;
    row-gap: 1rem; /* Espacio entre filas cuando colapsa */
}

.brand {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.brand-link {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.brand-logo {
    height: 44px; /* Un poco más grande para mejor presencia */
    width: auto;
    min-width: 140px; /* Asegura espacio mínimo */
    object-fit: contain;
    transition: transform 0.2s ease;
}

.brand-logo:hover {
    transform: scale(1.02);
}

.nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    align-items: center;
    flex: 1 1 100%; /* Forzar línea propia por defecto en escritorio */
    justify-content: center;
    order: 3; /* Ir debajo del Logo y User Menu */
    transition: all 0.3s ease;
    padding: 0.5rem 0;
    border-top: 1px solid rgba(0,0,0,0.05); /* Separación visual prolija */
}

.brand {
    order: 1;
    flex: 0 0 auto;
}

.user-menu {
    order: 2; /* Lado opuesto al logo en la primera fila */
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.nav-link {
    font-size: 0.9rem;
    padding: 0.5rem 0.8rem;
    font-weight: 500;
    color: var(--text-light);
    text-decoration: none;
    border-radius: var(--radius);
    transition: all 0.2s ease-in-out;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
    /* Reset para botones que actúan como links */
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.row-break {
    display: none;
}

.user-menu {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    justify-content: flex-end;
    flex-shrink: 0;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.75rem;
    cursor: pointer;
    color: var(--text);
    padding: 0.5rem;
}

/* Nav Items */
.nav-item {
    position: relative;
    height: auto;
    display: flex;
    align-items: center;
}

.nav-link:hover,
.nav-item:hover>.nav-link {
    background-color: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
}

/* Dropdown Menu */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    min-width: 240px;
    padding: 0.5rem;
    display: none;
    z-index: 100;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.dropdown-menu::before {
    content: '';
    position: absolute;
    top: -15px; /* Crea un área sensible arriba del menú */
    left: 0;
    right: 0;
    height: 15px;
    background: transparent;
}

.nav-item:hover .dropdown-menu {
    display: flex;
    opacity: 1;
    visibility: visible;
    transform: translateY(2px); /* Reducido para mayor estabilidad */
}

.dropdown-item {
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: var(--text);
    display: flex;
    align-items: center;
    border-radius: calc(var(--radius) - 4px);
    font-size: 0.95rem;
    transition: all 0.2s ease;
    gap: 0.5rem;
}

.dropdown-item:hover {
    background-color: rgba(37, 99, 235, 0.05);
    color: var(--primary);
    transform: translateX(4px);
}

/* Notifications Box specific */
.notifications-dropdown {
    margin-right: 0.5rem;
}

.notification-btn {
    position: relative;
    background: none;
    border: none;
    font-size: 1.35rem;
    /* slightly larger icon */
    cursor: pointer;
    padding: 0.4rem;
    display: flex;
    align-items: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.notification-btn:hover {
    background-color: var(--border);
}

.notification-badge {
    position: absolute;
    top: 0px;
    right: 0px;
    background: var(--danger);
    color: white;
    border-radius: 50%;
    padding: 0.15rem 0.4rem;
    font-size: 0.7rem;
    font-weight: bold;
    transform: scale(0.9);
    border: 2px solid var(--surface);
}

.dropdown-menu.notifications-menu {
    right: 0;
    left: auto;
    min-width: 340px;
    padding: 0;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.notifications-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface);
    border-radius: var(--radius) var(--radius) 0 0;
}

.notifications-header h6 {
    margin: 0;
    font-weight: 600;
    color: var(--text);
    font-size: 1rem;
}

.mark-all-read-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0;
    font-weight: 500;
}

.mark-all-read-btn:hover {
    text-decoration: underline;
}

.notifications-body {
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
}

.notification-item {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    cursor: default;
    transition: background-color 0.2s ease;
}

.notification-item:hover {
    background-color: rgba(0, 0, 0, 0.01);
}

.notification-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 0.4rem;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px var(--surface);
    background-color: var(--primary); /* default */
}

.notification-dot.info { background-color: var(--primary); }
.notification-dot.success { background-color: var(--success); }
.notification-dot.warning { background-color: var(--warning); }
.notification-dot.danger { background-color: var(--danger); }

.notification-content {
    flex-grow: 1;
    min-width: 0;
}

.notification-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    color: var(--text);
}

.notification-message {
    font-size: 0.85rem;
    color: var(--text-light);
    line-height: 1.4;
    word-break: break-word;
}

.notification-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
}

.notification-time {
    font-size: 0.75rem;
    color: #a0aec0;
}

.notification-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.notification-link {
    font-size: 0.8rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.notification-link:hover {
    text-decoration: underline;
}

.mark-read-btn {
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    transition: background 0.2s;
}

.mark-read-btn:hover {
    background-color: var(--border);
    color: var(--danger);
}

.notifications-empty {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--text-light);
}

.notifications-empty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    opacity: 0.3;
}

.user-name-label {
    color: var(--text-light);
    font-size: 0.95rem;
    font-weight: 500;
}

.logout-btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: calc(var(--radius) - 2px);
    text-decoration: none;
    transition: all 0.2s ease;
    font-weight: 500;
}

.logout-btn:hover {
    background: var(--background);
    border-color: var(--secondary);
}

/* User config button */
.admin-users-btn {
    color: var(--primary);
    font-weight: 500;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.5rem;
    border-radius: var(--radius);
}

.admin-users-btn:hover {
    background: rgba(37, 99, 235, 0.05);
}

/* Media Queries for Mobile Responsiveness */
@media (max-width: 900px) {
    .nav-links {
        display: none; /* Hide default for mobile toggle */
        flex: none;
        order: unset;
        width: 100%;
        border-top: none;
    }
    .user-menu {
        display: none;
    }
    .nav-link {
        font-size: 0.85rem;
        padding: 0.4rem 0.6rem;
        gap: 0.3rem;
    }
    .nav-links {
        gap: 0.5rem 0.8rem;
    }
}

@media (max-width: 900px) {
    .main-content {
        padding: 1rem;
    }

    .navbar {
        padding: 0.5rem 1rem;
    }

    .navbar-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .brand {
        width: 100%;
        justify-content: space-between;
    }

    .mobile-menu-btn {
        display: block !important;
        position: absolute;
        right: 1rem;
        top: 0.75rem;
    }

    .nav-links {
        display: none;
        flex-direction: column;
        width: 100%;
        align-items: stretch;
        gap: 0.25rem;
    }

    .nav-links.active {
        display: flex;
    }

    .user-menu {
        display: none;
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .user-menu.active {
        display: flex;
    }

    .dropdown-menu {
        position: static;
        box-shadow: none;
        border: none;
        border-left: 2px solid var(--border);
        border-radius: 0;
        padding-left: 1rem;
        margin-top: 0.5rem;
        display: none;
        opacity: 1;
        visibility: visible;
        transform: none;
        width: 100%;
    }

    .nav-item.dropdown.active .dropdown-menu {
        display: flex;
    }

    .dropdown-menu.notifications-menu {
        position: absolute;
        right: 0;
        left: 0;
        top: 100%;
        width: 100%;
        min-width: unset;
        z-index: 1000;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
        border: 1px solid var(--border);
    }

    /* Specific adjustment for waiting room service row */
    div[style*="display: grid"] {
        grid-template-columns: 1fr !important;
    }

    /* Specific adjustment for waiting room service row */
    .service-row {
        grid-template-columns: 1fr !important;
    }
}

/* Hide native browser password reveal and clear buttons (mostly for Edge/IE on Windows) */
input::-ms-reveal,
input::-ms-clear {
    display: none;
}