/* ===========================================
   Mada Platform - Header Component
   2-Row Layout, Search, Navigation, Mobile
   =========================================== */

.main-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    max-width: 100vw;
    overflow-x: clip;
    z-index: 1000;
    background: rgba(11, 17, 32, 0.92);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    box-shadow: 0 10px 30px rgba(8, 15, 30, 0.35);
    transition: var(--transition);
}

.curriculum-term-strip {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(15, 23, 42, 0.9);
}

.curriculum-term-strip .container {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 34px;
    color: #e2e8f0;
    font-size: 0.82rem;
}

.curriculum-term-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 0.78rem;
    color: #ffffff;
}

.term-term1 .curriculum-term-chip {
    background: linear-gradient(135deg, #1d4ed8, #0ea5e9);
}

.term-term2 .curriculum-term-chip {
    background: linear-gradient(135deg, #1d4ed8, #0ea5e9);
}

.curriculum-term-text {
    font-weight: 700;
}

.curriculum-term-note {
    color: rgba(226, 232, 240, 0.72);
    margin-inline-start: auto;
}

/* Header Row 1 - Logo, Search, Actions */
.header-row-1 {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.header-top {
    display: grid;
    grid-template-columns: auto minmax(320px, 1fr) auto auto;
    align-items: center;
    gap: 20px;
    padding: 12px 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.logo-img {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    object-fit: contain;
}

.logo-text {
    font-size: 1.6rem;
    font-weight: 800;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Search Bar */
.header-search {
    display: flex;
    max-width: 680px;
    width: 100%;
    justify-self: center;
    margin-inline: auto;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.12);
    transition: var(--transition);
}

.header-search:focus-within {
    border-color: rgba(47, 91, 255, 0.7);
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 10px 25px rgba(47, 91, 255, 0.2);
}

.search-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 20px;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    color: #e2e8f0;
}

.search-btn {
    padding: 12px 18px;
    background: var(--primary-gradient);
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    transition: var(--transition);
}

.search-btn:hover {
    transform: scale(1.1);
}

/* User Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.notification-menu {
    position: relative;
}

.notification-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 45px;
    height: 45px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

.notification-btn:hover {
    background: rgba(255, 255, 255, 0.16);
    transform: scale(1.05);
}

.notification-icon {
    font-size: 1.2rem;
}

.notification-count {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notification-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 240px;
    background: #0b1220;
    border-radius: 12px;
    box-shadow: 0 20px 45px rgba(2, 6, 23, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.08);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: var(--transition);
    z-index: 100;
    padding: 6px 0;
}

.notification-menu:hover .notification-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(5px);
}

.notification-item {
    display: block;
    padding: 10px 14px;
    color: #e2e8f0;
    text-decoration: none;
    transition: var(--transition);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.notification-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.notification-item.is-unread {
    background: rgba(59, 130, 246, 0.12);
}

.notification-item.is-unread:hover {
    background: rgba(59, 130, 246, 0.22);
}

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

.notification-title {
    font-weight: 700;
    font-size: 0.85rem;
}

.notification-message {
    font-size: 0.8rem;
    color: rgba(226, 232, 240, 0.75);
    margin-top: 2px;
}

.notification-time {
    font-size: 0.75rem;
    color: rgba(148, 163, 184, 0.8);
    margin-top: 4px;
}

.notification-empty {
    padding: 12px 14px;
    color: rgba(226, 232, 240, 0.7);
    font-size: 0.85rem;
}

.notification-toast-stack {
    position: fixed;
    top: 84px;
    right: 14px;
    width: min(360px, calc(100vw - 24px));
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1300;
    pointer-events: none;
}

.notification-toast {
    pointer-events: auto;
    display: block;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(59, 130, 246, 0.35);
    background: rgba(8, 17, 40, 0.95);
    color: #e2e8f0;
    text-decoration: none;
    box-shadow: 0 20px 35px rgba(15, 23, 42, 0.45);
    animation: notificationToastIn 0.26s ease-out;
}

.notification-toast.is-leaving {
    opacity: 0;
    transform: translateX(12px) scale(0.98);
    transition: opacity 0.24s ease, transform 0.24s ease;
}

.notification-toast:hover {
    border-color: rgba(56, 189, 248, 0.6);
    transform: translateY(-1px);
}

.notification-toast-head {
    display: flex;
    align-items: center;
    gap: 8px;
}

.notification-toast-icon {
    font-size: 1rem;
    line-height: 1;
}

.notification-toast-title {
    font-size: 0.9rem;
    line-height: 1.4;
}

.notification-toast-message {
    margin-top: 6px;
    font-size: 0.82rem;
    color: rgba(226, 232, 240, 0.86);
}

.notification-toast-time {
    margin-top: 4px;
    font-size: 0.75rem;
    color: rgba(148, 163, 184, 0.9);
}

@keyframes notificationToastIn {
    from {
        opacity: 0;
        transform: translateX(14px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.user-menu {
    position: relative;
}

.user-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    transition: var(--transition);
}

.user-btn:hover {
    background: rgba(255, 255, 255, 0.16);
}

.user-icon {
    font-size: 1.2rem;
}

.user-icon--modern {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(15, 23, 42, 0.72);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #bfdbfe;
}

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

.user-text {
    font-size: 0.9rem;
    color: #e2e8f0;
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    left: auto;
    min-width: 180px;
    width: max-content;
    max-width: min(280px, calc(100vw - 20px));
    background: #0b1220;
    border-radius: 12px;
    box-shadow: 0 20px 45px rgba(2, 6, 23, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.08);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: var(--transition);
    z-index: 100;
}

.user-menu:hover .user-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(5px);
}

.user-menu.is-open .user-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(5px);
}

.dropdown-item {
    display: block;
    padding: 12px 16px;
    color: #e2e8f0;
    font-size: 0.9rem;
    transition: var(--transition);
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.dropdown-item-with-icon {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dropdown-item-icon {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #93c5fd;
    flex: 0 0 18px;
}

.dropdown-item-icon svg {
    width: 100%;
    height: 100%;
}

.dropdown-item-profile {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dropdown-item-profile-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    color: #93c5fd;
}

.dropdown-item-profile-icon svg {
    width: 100%;
    height: 100%;
}

.dropdown-role-badge {
    margin-inline-start: auto;
    font-style: normal;
    font-size: 0.72rem;
    font-weight: 800;
    color: #dbeafe;
    border: 1px solid rgba(96, 165, 250, 0.42);
    background: rgba(30, 64, 175, 0.24);
    border-radius: 999px;
    padding: 3px 8px;
}

.dropdown-item:first-child {
    border-radius: 12px 12px 0 0;
}

.dropdown-item:last-child {
    border-radius: 0 0 12px 12px;
}

.dropdown-item-form {
    margin: 0;
}

.dropdown-item-form .logout-btn {
    display: block;
    width: 100%;
    padding: 12px 16px;
    border: 0;
    background: transparent;
    color: #fecaca;
    text-align: right;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.2;
    cursor: pointer;
    transition: var(--transition);
    border-radius: 0 0 12px 12px;
}

.dropdown-item-form .logout-btn.logout-btn-with-icon {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dropdown-item-form .logout-btn.logout-btn-with-icon .dropdown-item-icon {
    color: #fca5a5;
}

.dropdown-item-form .logout-btn:hover {
    background: rgba(239, 68, 68, 0.18);
    color: #fff;
}

/* Cart Button */
.cart-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 45px;
    height: 45px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    text-decoration: none;
    transition: var(--transition);
}

.cart-btn:hover {
    background: rgba(255, 255, 255, 0.16);
    transform: scale(1.05);
}

.cart-icon {
    font-size: 1.3rem;
}

.cart-count {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-menu {
    position: relative;
}

.cart-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    width: 320px;
    background: #0b1220;
    border-radius: 14px;
    box-shadow: 0 22px 50px rgba(2, 6, 23, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.08);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: var(--transition);
    z-index: 120;
    padding: 6px 0;
    max-width: calc(100vw - 24px);
}

.cart-menu:hover .cart-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(5px);
}

.cart-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    color: #e2e8f0;
    font-weight: 700;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.cart-dropdown-count {
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
}

.cart-dropdown-empty {
    padding: 14px;
    color: rgba(226, 232, 240, 0.7);
    font-size: 0.85rem;
}

.cart-dropdown-list {
    max-height: 320px;
    overflow: auto;
}

.cart-mini-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

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

.cart-mini-thumb {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 48px;
}

.cart-mini-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cart-mini-icon {
    font-size: 1.2rem;
}

.cart-mini-info {
    flex: 1;
    min-width: 0;
}

.cart-mini-title {
    font-weight: 700;
    font-size: 0.85rem;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cart-mini-sub {
    font-size: 0.75rem;
    color: rgba(226, 232, 240, 0.7);
    margin-top: 2px;
}

.cart-mini-price {
    font-weight: 700;
    font-size: 0.8rem;
    color: #38bdf8;
    white-space: nowrap;
}

.cart-dropdown-actions {
    display: flex;
    gap: 8px;
    padding: 10px 14px 8px;
}

.cart-action-btn {
    flex: 1;
    text-align: center;
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 700;
    background: var(--primary-gradient);
    color: #fff;
    text-decoration: none;
    transition: var(--transition);
}

.cart-action-btn.ghost {
    background: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
}

.cart-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(37, 99, 235, 0.25);
}

/* Header Row 2 - Navigation */
.header-row-2 {
    background: var(--primary-gradient);
}

.header-ticker {
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(15, 23, 42, 0.94);
    overflow: hidden;
    min-height: 32px;
    display: flex;
    align-items: center;
}

.header-ticker-track {
    width: 100%;
    position: relative;
    overflow: hidden;
}

.header-ticker-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #e2e8f0;
    font-size: 0.86rem;
    font-weight: 700;
    white-space: nowrap;
    padding-inline: 14px;
    animation: headerTickerLtr 20s linear infinite;
}

.header-ticker-icon {
    font-size: 1rem;
}

.header-ticker-link,
.header-ticker-text {
    color: #e2e8f0;
    text-decoration: none;
}

.header-ticker-link:hover {
    color: #ffffff;
}

@keyframes headerTickerLtr {
    from {
        transform: translateX(-110%);
    }
    to {
        transform: translateX(100vw);
    }
}

.main-nav ul {
    display: flex;
    justify-content: flex-start;
    gap: 5px;
    list-style: none;
    padding: 0;
    padding-inline: 14px;
}

.main-nav a {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 18px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 8px;
    transition: var(--transition);
    position: relative;
}

.main-nav a:hover {
    background: rgba(255, 255, 255, 0.18);
    color: white;
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 10px;
    border-radius: 10px;
    transition: var(--transition);
}

.mobile-menu-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.hamburger-line {
    width: 24px;
    height: 3px;
    background: #e2e8f0;
    border-radius: 3px;
    transition: var(--transition);
}

.mobile-menu-btn.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translateY(8px);
}

.mobile-menu-btn.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.mobile-menu-btn.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translateY(-8px);
}

/* Mobile Navigation */
.mobile-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: linear-gradient(180deg, rgba(4, 9, 24, 1), rgba(7, 14, 31, 1));
    box-shadow: 0 20px 40px rgba(2, 6, 23, 0.45);
    border-radius: 0;
    padding: 14px 12px calc(18px + env(safe-area-inset-bottom, 0px));
    height: calc(100dvh - var(--header-offset));
    max-height: calc(100dvh - var(--header-offset));
    transform: translateY(-8px);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    pointer-events: none;
    overflow-y: auto;
    z-index: 950;
}

.mobile-nav.active {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.mobile-nav ul {
    list-style: none;
    margin: 0 auto;
    max-width: 720px;
    display: grid;
    gap: 8px;
}

.mobile-nav li {
    border-bottom: none;
}

.mobile-nav li:last-child {
    border-bottom: none;
}

.mobile-nav a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    font-size: 0.96rem;
    font-weight: 700;
    color: #e2e8f0 !important;
    -webkit-text-fill-color: #e2e8f0 !important;
    opacity: 1 !important;
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.62);
    text-shadow: 0 1px 0 rgba(2, 6, 23, 0.45);
}

.mobile-nav a * {
    color: #e2e8f0 !important;
    -webkit-text-fill-color: #e2e8f0 !important;
    opacity: 1 !important;
}

.mobile-nav a:hover {
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
    border-color: rgba(96, 165, 250, 0.56);
    background: rgba(30, 64, 175, 0.34);
}

.mobile-nav a:hover * {
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
}

@media (max-width: 900px) {
    .desktop-nav {
        display: none;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .mobile-nav {
        display: block;
    }

    .header-row-1 .container,
    .curriculum-term-strip .container {
        width: 100%;
        max-width: 100%;
        padding-inline: 12px;
    }

    .header-search {
        display: none;
    }

    .header-top {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        padding: 10px 0;
        width: 100%;
        overflow-x: hidden;
    }

    .logo {
        flex: 0 1 auto;
        min-width: 0;
        gap: 8px;
    }

    .header-actions {
        gap: 6px;
        flex: 0 0 auto;
        min-width: 0;
        flex-wrap: nowrap;
        margin: 0;
    }

    .header-actions > * {
        min-width: 0;
    }

    .logo-text {
        font-size: 1.75rem;
        line-height: 1;
        white-space: nowrap;
    }

    .mobile-menu-btn {
        flex: 0 0 auto;
        margin: 0;
    }

    .notification-btn,
    .cart-btn {
        width: 40px;
        height: 40px;
    }

    .user-btn {
        min-width: 40px;
        min-height: 40px;
        width: 40px;
        height: 40px;
        padding: 0;
        border-radius: 50%;
        justify-content: center;
        gap: 0;
    }

    .user-text {
        display: none;
    }

    .mobile-nav {
        overflow: auto;
        padding: 12px;
    }

    .mobile-nav a {
        border-radius: 11px;
        padding: 11px 12px;
    }
}

@media (max-width: 768px) {
    .logo {
        gap: 8px;
    }

    .logo-img {
        width: 48px;
        height: 48px;
    }

    .curriculum-term-strip .container {
        min-height: 30px;
        font-size: 0.76rem;
    }

    .curriculum-term-note {
        display: none;
    }

    .notification-dropdown {
        min-width: min(280px, calc(100vw - 20px));
    }

    .cart-dropdown {
        width: min(300px, calc(100vw - 20px));
    }

    .notification-toast-stack {
        top: 72px;
        right: 10px;
        width: calc(100vw - 20px);
    }

    .mobile-nav {
        padding-inline: 10px;
    }
}

@media (max-width: 480px) {
    .header-row-1 .container,
    .curriculum-term-strip .container {
        padding-inline: 10px;
    }

    .header-top {
        gap: 6px;
        padding: 8px 0;
    }

    .logo-img {
        width: 42px;
        height: 42px;
        border-radius: 10px;
    }

    .logo-text {
        font-size: 1.35rem;
    }

    .mobile-menu-btn,
    .notification-btn,
    .cart-btn,
    .user-btn {
        width: 38px;
        height: 38px;
    }

    .mobile-nav a {
        font-size: 0.9rem;
        padding: 10px 12px;
    }

    .notification-toast {
        border-radius: 12px;
        padding: 11px 12px;
    }
}

@media (max-width: 400px) {
    .logo-text {
        display: none;
    }
}
