/* =============================================
   Top Header Bar — eCertifyHub
   ============================================= */

/* ---------- Top Bar Layout ---------- */
#app-topbar {
    display: flex;
    align-items: center;
    /* Centers both .topbar-left and .topbar-right content */
    justify-content: space-between;
    padding: 0 24px;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 90;
    height: 78px;
    /* Fixed height for alignment with sidebar brand area */
    flex-shrink: 0;
    /* Prevent topbar from shrinking in height */
}

.topbar-left {
    display: flex;
    align-items: center !important;
    /* Center content within the stretched section */
    gap: 10px;
}

.topbar-page-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
    letter-spacing: 0.2px;
    line-height: normal;
}

.topbar-right {
    display: flex;
    align-items: center !important;
    /* Center content within the stretched section */
    gap: 6px;
}

/* ---------- Bell Button ---------- */
.topbar-icon-btn {
    position: relative;
    background: none;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.topbar-icon-btn:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.topbar-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
    border: 2px solid #ffffff;
}

/* ---------- Profile Avatar Button ---------- */
.topbar-profile-wrap {
    position: relative;
}

.topbar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #1e3a8a;
    border: none;
    color: #ffffff;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s, box-shadow 0.15s;
    text-transform: uppercase;
}

.topbar-avatar:hover {
    opacity: 0.9;
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.2);
}

/* ---------- Profile Dropdown ---------- */
.topbar-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 210px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10);
    z-index: 200;
    overflow: hidden;
    animation: topbar-dropdown-in 0.15s ease;
}

.topbar-dropdown.open {
    display: block;
}

@keyframes topbar-dropdown-in {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* User info section inside dropdown */
.topbar-dropdown-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px 12px;
}

.topbar-dropdown-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #1e3a8a;
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    text-transform: uppercase;
}

.topbar-dropdown-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-dropdown-role {
    font-size: 0.72rem;
    color: #94a3b8;
    margin-top: 1px;
}

/* Divider inside dropdown */
.topbar-dropdown-divider {
    border: none;
    border-top: 1px solid #f1f5f9;
    margin: 0;
}

/* Dropdown menu items */
.topbar-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    text-align: left;
    font-size: 0.875rem;
    color: #374151;
    cursor: pointer;
    transition: background 0.12s;
}

.topbar-dropdown-item:hover {
    background: #f8fafc;
    color: #1e293b;
}

.topbar-dropdown-item i {
    font-size: 1rem;
    width: 18px;
    text-align: center;
    color: #64748b;
}

.topbar-dropdown-item--danger {
    color: #ef4444;
}

.topbar-dropdown-item--danger i {
    color: #ef4444;
}

.topbar-dropdown-item--danger:hover {
    background: #fef2f2;
    color: #dc2626;
}

/* =============================================
   Dark Mode overrides (applied to <body>)
   ============================================= */
body.dark-mode {
    --body-bg: #0f172a;
    --content-bg: #1e293b;
    --card-bg: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    background-color: #0f172a;
    color: #f1f5f9;
}

body.dark-mode #app-topbar {
    background: #1e293b;
    border-bottom-color: #334155;
}

body.dark-mode .topbar-page-title {
    color: #f1f5f9;
}

body.dark-mode .topbar-icon-btn {
    color: #94a3b8;
}

body.dark-mode .topbar-icon-btn:hover {
    background: #334155;
    color: #f1f5f9;
}

body.dark-mode .topbar-dropdown {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

body.dark-mode .topbar-dropdown-name {
    color: #f1f5f9;
}

body.dark-mode .topbar-dropdown-divider {
    border-top-color: #334155;
}

body.dark-mode .topbar-dropdown-item {
    color: #cbd5e1;
}

body.dark-mode .topbar-dropdown-item:hover {
    background: #334155;
    color: #f1f5f9;
}

body.dark-mode #app-content {
    background-color: #0f172a;
}

body.dark-mode .stat-card,
body.dark-mode .table-card {
    background: #1e293b;
    border-color: #334155;
    color: #f1f5f9;
}

body.dark-mode .table thead {
    background-color: #1e293b;
}

body.dark-mode .table thead th,
body.dark-mode .table tbody td {
    color: #94a3b8;
    border-color: #334155;
}

body.dark-mode .table tbody tr:hover {
    background-color: #334155;
}

/* ---------- Responsive: Topbar on Mobile ---------- */
@media (max-width: 768px) {
    #app-topbar {
        height: 60px;
        padding: 0 12px 0 60px;
    }

    .topbar-page-title {
        font-size: 0.9rem;
    }

    .topbar-right {
        gap: 4px;
    }

    .topbar-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.7rem;
    }

    .topbar-icon-btn {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }

    .topbar-dropdown {
        right: -8px;
        width: 200px;
    }
}

@media (max-width: 480px) {
    #app-topbar {
        padding: 0 8px 0 52px;
    }

    .topbar-page-title {
        font-size: 0.82rem;
    }
}