/* ========================================
   Layout Styles - Header, Sidebar, Content
   ======================================== */

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-6);
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header__left {
    display: flex;
    align-items: center;
    gap: var(--spacing-4);
}

.header__right {
    display: flex;
    align-items: center;
    gap: var(--spacing-4);
}

.sidebar-toggle {
    display: none;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    transition: background var(--transition-fast);
    position: relative;
    z-index: 10;
    cursor: pointer;
}

.sidebar-toggle:hover {
    background: var(--bg-tertiary);
}

.sidebar-toggle svg {
    width: 20px;
    height: 20px;
}

/* Logo */
.logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
}

.logo svg {
    width: 28px;
    height: 28px;
    color: var(--primary);
}

.logo__text {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--text-primary);
}

/* Theme Toggle */
.theme-toggle {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    transition: background var(--transition-fast);
    position: relative;
}

.theme-toggle:hover {
    background: var(--bg-tertiary);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    position: absolute;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.theme-icon-dark {
    opacity: 0;
    transform: rotate(-90deg);
}

[data-theme="dark"] .theme-icon-light {
    opacity: 0;
    transform: rotate(90deg);
}

[data-theme="dark"] .theme-icon-dark {
    opacity: 1;
    transform: rotate(0);
}

/* Notification Button */
.notification-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    transition: background var(--transition-fast);
    position: relative;
}

.notification-btn:hover {
    background: var(--bg-tertiary);
}

.notification-btn svg {
    width: 20px;
    height: 20px;
}

.notification-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 18px;
    height: 18px;
    background: var(--danger);
    color: white;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
}

/* User Menu */
.user-menu {
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
    padding: var(--spacing-2) var(--spacing-3);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: background var(--transition-fast);
    position: relative;
}

.user-menu:hover {
    background: var(--bg-tertiary);
}

.user-avatar,
.user-menu .avatar,
.avatar-placeholder {
    width: 36px;
    height: 36px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    object-fit: cover;
}

.user-avatar svg,
.avatar-placeholder svg {
    width: 20px;
    height: 20px;
}

.user-name {
    font-weight: 500;
}

.user-chevron {
    width: 16px;
    height: 16px;
    transition: transform var(--transition-fast);
}

.user-menu:hover .user-chevron {
    color: var(--text-primary);
}

.user-menu.active .user-chevron {
    transform: rotate(180deg);
}

/* Language Dropdown */
.lang-menu {
    position: relative;
    margin-right: var(--spacing-2);
}

.lang-toggle {
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
    padding: var(--spacing-2) var(--spacing-3);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.lang-toggle:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-hover);
}

.lang-flag {
    font-size: 16px;
    line-height: 1;
}

.lang-code {
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-transform: uppercase;
}

.lang-chevron {
    width: 14px;
    height: 14px;
    color: var(--text-tertiary);
    transition: transform var(--transition-fast);
}

.lang-menu.active .lang-chevron {
    transform: rotate(180deg);
}

.lang-dropdown {
    position: absolute;
    top: calc(100% + var(--spacing-2));
    right: 0;
    width: 160px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--spacing-2);
    display: none;
    flex-direction: column;
    gap: var(--spacing-1);
    z-index: 100;
}

.lang-menu.active .lang-dropdown {
    display: flex;
}

/* User Dropdown */
.user-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 220px;
    background: var(--bg-secondary);
    background-color: #ffffff;
    /* Fallback/Force */
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    /* Stronger shadow */
    padding: var(--spacing-2);
    display: none;
    flex-direction: column;
    z-index: 9999;
    /* Super high z-index */
    animation: slideDown 0.2s ease;
}

[data-theme="dark"] .user-dropdown {
    background-color: var(--bg-secondary);
}

.user-dropdown.show {
    display: flex;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

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

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
    padding: var(--spacing-3);
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    font-size: var(--font-size-sm);
}

.dropdown-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.dropdown-item svg {
    width: 16px;
    height: 16px;
}

.dropdown-item.text-danger {
    color: var(--danger);
}

.dropdown-item.text-danger:hover {
    background: var(--danger-bg);
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: var(--spacing-2) 0;
}

/* Main Container */
.main-container {
    display: flex;
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    /* Sidebar Background - Gradient Lighter Brown to match Login Page vibes */
    background: linear-gradient(180deg, #8D6E63 0%, #5D4037 100%);
    border-right: none;
    padding: var(--spacing-4);
    /* Add padding bottom to prevent content from being covered by waves */
    padding-bottom: 200px;
    overflow-y: auto;
    z-index: 90;
    transition: transform var(--transition-base), width var(--transition-base);
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE and Edge */
}

.sidebar::-webkit-scrollbar {
    display: none;
}

/* Global Collapsed State */
.sidebar.collapsed {
    width: 70px;
}

.sidebar.collapsed .nav__item {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

.sidebar.collapsed .nav__item span,
.sidebar.collapsed .logo__text {
    display: none;
}

.sidebar.collapsed .logo {
    justify-content: center;
    padding-left: 0;
}

/* Sidebar Wave Decoration */
.sidebar::after {
    content: "";
    position: fixed;
    /* Fixed relative to viewport, aligns with sidebar bottom */
    bottom: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 500px;
    /* Diperbesar 5x lipat (Big Waves) */
    background-image: url('../assets/waves.svg');
    background-repeat: repeat-x;
    background-position: bottom left;
    /* Crop bagian kanan, fokus kiri bawah */
    background-size: auto 100%;
    /* Tinggi mengikuti container 500px */
    pointer-events: none;
    z-index: 91;
    opacity: 1;
    /* Full opacity agar jelas terlihat kontrasnya */
    transition: width var(--transition-base);
}

/* Hide Wave in Mobile per user request */
@media (max-width: 1024px) {
    .sidebar::after {
        display: none;
    }
}

/* Dark Mode Sidebar Override - Revert to dark theme colors and hide wave */
[data-theme="dark"] .sidebar {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
}

[data-theme="dark"] .sidebar::after {
    display: none;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-1);
}

.nav__item {
    display: flex;
    align-items: center;
    gap: var(--spacing-3);
    padding: var(--spacing-3) var(--spacing-4);
    border-radius: var(--radius-lg);
    /* Light Mode Text Color */
    color: rgba(255, 255, 255, 0.8);
    transition: all var(--transition-fast);
}

/* Dark Mode Nav Item Override */
[data-theme="dark"] .nav__item {
    color: var(--text-secondary);
}

.nav__item:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

[data-theme="dark"] .nav__item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav__item.active {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    font-weight: 500;
}

[data-theme="dark"] .nav__item.active {
    background: var(--primary-light);
    color: var(--primary);
}

.nav__item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Content */
.content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: var(--spacing-6);
    background: var(--bg-primary);
    min-height: calc(100vh - var(--header-height));
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar-toggle {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .content {
        margin-left: 0;
    }

    .user-name {
        display: none;
    }
}

/* Sidebar Minimize (Desktop) */
@media (min-width: 1025px) {
    .sidebar-toggle {
        display: flex !important;
    }

    .sidebar {
        transition: width 0.3s ease;
    }

    .content {
        transition: margin-left 0.3s ease;
    }

    .content {
        transition: margin-left 0.3s ease;
    }

    /* Content margin handled below */

    /* Adjust content margin when sidebar is collapsed */
    /* We use general sibling combinator if structure allows, or JS to add class to body/layout */
    /* layout.css line 471 uses: margin-left: var(--sidebar-width); */

    /* We need to target .content when sidebar is collapsed.
       Since .content is inside .main-container next to .sidebar:
    */
    .sidebar.collapsed~.content {
        margin-left: 70px;
    }

    .sidebar.collapsed::after {
        width: 70px;
    }
}

@media (max-width: 640px) {
    .logo__text {
        display: none;
    }

    .header {
        padding: 0 var(--spacing-4);
        height: 80px;
        /* Increased from default for mobile per user request */
    }

    .main-container {
        margin-top: 80px;
        /* Sync with new header height */
    }

    .content {
        padding: var(--spacing-4);
    }

    /* Mobile Header Icons Enlarge */
    .header .sidebar-toggle,
    .header .theme-toggle,
    .header .notification-btn {
        width: 48px;
        /* Larger touch target */
        height: 48px;
    }

    .header .sidebar-toggle svg,
    .header .theme-toggle svg,
    .header .notification-btn svg {
        width: 24px;
        /* Larger icon */
        height: 24px;
    }

    .header .user-avatar,
    .header .avatar-placeholder {
        width: 40px;
        height: 40px;
    }

    .header .user-avatar svg,
    .header .avatar-placeholder svg {
        width: 24px;
        height: 24px;
    }

    .header .logo img {
        height: 40px !important;
        /* Larger Logo */
        width: auto !important;
    }

    /* Adjust notification badge position for larger button */
    .header .notification-badge {
        top: 8px;
        right: 8px;
    }
}

/* Notification Dropdown */
.notification-wrapper {
    position: relative;
    /* Ensure relative positioning for absolute children */
}

.notification-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    right: -80px;
    width: 360px;
    background: var(--bg-secondary);
    background-color: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    display: none;
    flex-direction: column;
    z-index: 1000;
    max-height: 80vh;
    animation: slideDown 0.2s ease;
}

[data-theme="dark"] .notification-dropdown {
    background-color: var(--bg-secondary);
}

.notification-dropdown.show {
    display: flex;
}

/* Mobile responsive */
@media (max-width: 640px) {
    .notification-dropdown {
        position: fixed;
        top: 70px;
        left: var(--spacing-4);
        right: var(--spacing-4);
        width: auto;
    }
}

.notification-header {
    padding: var(--spacing-4);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.notification-header h3 {
    font-size: var(--font-size-md);
    font-weight: 600;
}

.mark-read-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-size: var(--font-size-xs);
    font-weight: 500;
    cursor: pointer;
}

.mark-read-btn:hover {
    text-decoration: underline;
}

.notification-list {
    overflow-y: auto;
    max-height: 400px;
}

.notification-item {
    padding: var(--spacing-3) var(--spacing-4);
    display: flex;
    gap: var(--spacing-3);
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition-fast);
    cursor: pointer;
}

.notification-item:last-child {
    border-bottom: none;
}

.notification-item:hover {
    background: var(--bg-tertiary);
}

.notification-item.unread {
    background: var(--bg-tertiary);
}

.notification-item.unread:hover {
    background: var(--border-light);
}

.notification-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.notification-icon svg {
    width: 16px;
    height: 16px;
}

.notification-icon.warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.notification-icon.info {
    background: var(--info-bg);
    color: var(--info);
}

.notification-icon.success {
    background: var(--success-bg);
    color: var(--success);
}

.notification-icon.danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.notification-content {
    flex: 1;
}

.notification-text {
    margin: 0;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    margin-bottom: 4px;
    line-height: 1.4;
}

.notification-time {
    display: block;
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
}

.notification-footer {
    padding: var(--spacing-3);
    text-align: center;
    border-top: 1px solid var(--border);
}

.notification-footer a {
    font-size: var(--font-size-sm);
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.notification-footer a:hover {
    text-decoration: underline;
}

/* Personal Page Vertical Stack */
.cert-stack {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding-bottom: 2rem;
}

.cert-card-premium {
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    transition: transform 0.2s;
    border: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
}

/* Header Styles with Gradient */
.cert-card-premium__header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark, #2563eb) 100%);
    color: white;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.cert-card-premium__header.status-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.cert-card-premium__header.status-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.cert-card-premium__header.status-danger {
    background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
}

.cert-card-premium__top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.cert-card-premium__status-badge {
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(4px);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.cert-card-premium__badge {
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(4px);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.cert-card-premium__title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: white;
    line-height: 1.3;
}

.cert-card-premium__subtitle {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cert-card-premium__body {
    padding: 1.5rem;
    flex: 1;
}

.cert-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.cert-detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.cert-detail-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    font-weight: 600;
}

.cert-detail-value {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
}

.cert-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: auto;
    border-top: 1px solid var(--border-light);
    padding: 1rem 1.5rem;
    background: var(--bg-tertiary);
}

.cert-actions .btn {
    justify-content: center;
    border-radius: 10px;
    font-weight: 500;
}

/* Desktop Grid Override */
@media (min-width: 768px) {
    .cert-stack {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
        align-items: start;
    }

    .cert-card-premium:hover {
        transform: translateY(-4px);
        box-shadow: 0 12px 24px -4px rgba(0, 0, 0, 0.15);
    }
}