/* ============================================================
   Base Layout - Mobile Responsive Styles
   CCE Platform - Main App Shell
   ============================================================ */

/* ============ Global Mobile Fixes ============ */
/* Prevent horizontal scroll and black bars on zoom */
html, body {
    max-width: 100vw;
    overflow-x: hidden;
}

.app-shell {
    max-width: 100vw;
    overflow-x: hidden;
}

/* ============ Large tablets and small desktops (1024px) ============ */
@media (max-width: 1024px) {
    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ============ Tablets (900px) ============ */
@media (max-width: 900px) {
    .footer-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ============ Mobile devices (768px) ============ */
@media (max-width: 768px) {
    /* ===== Viewport and Container Fixes ===== */
    .main-wrapper {
        margin-left: 0;
        width: 100%;
        max-width: 100vw;
    }

    body.sidebar-pinned .main-wrapper {
        margin-left: 0;
    }

    /* ===== Sidebar Overlay - closes menu when clicked ===== */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 1000;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .sidebar-overlay.active {
        display: block;
        opacity: 1;
    }

    /* ===== Sidebar mobile - off-canvas ===== */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1001;
    }

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

    /* Hide pin button on mobile, show close button */
    .sidebar-pin-btn {
        display: none !important;
    }

    .sidebar-close-btn {
        display: flex !important;
        position: absolute;
        top: 12px;
        right: 12px;
        width: 36px;
        height: 36px;
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 8px;
        color: #fff;
        font-size: 1.1rem;
        cursor: pointer;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;
        z-index: 10;
    }

    .sidebar-close-btn:hover {
        background: rgba(244, 1, 43, 0.3);
        border-color: rgba(244, 1, 43, 0.5);
        color: #f4012b;
    }

    /* Show sidebar items when open */
    .sidebar.open .sidebar-item {
        justify-content: flex-start;
    }

    .sidebar.open .sidebar-item span {
        opacity: 1;
        transform: translateX(0);
        position: relative;
        left: auto;
    }

    .sidebar.open .sidebar-version {
        opacity: 1;
    }

    /* ===== Topbar Mobile - Fixed positioning ===== */
    .topbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: var(--topbar-height);
        padding: 0 12px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        background: #0d0d0d;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        z-index: 1000;
        box-sizing: border-box;
    }

    body.sidebar-pinned .topbar {
        left: 0;
    }

    /* ===== Topbar Left - Hamburger Menu ===== */
    .topbar-left {
        flex: 0 0 auto;
        display: flex;
        align-items: center;
        z-index: 2;
    }

    /* Hamburger button with 3-line icon */
    .hamburger {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        background: transparent;
        border: none;
        border-radius: 8px;
        cursor: pointer;
        position: relative;
        padding: 0;
    }

    /* Create 3-line hamburger icon using pseudo-elements */
    .hamburger::before,
    .hamburger::after {
        content: '';
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        width: 22px;
        height: 2px;
        background-color: #fff;
        border-radius: 2px;
        transition: all 0.3s ease;
    }

    .hamburger::before {
        top: 14px;
        box-shadow: 0 7px 0 #fff; /* Middle line via box-shadow */
    }

    .hamburger::after {
        bottom: 14px;
    }

    .hamburger:hover::before,
    .hamburger:hover::after {
        background-color: #f4012b;
    }

    .hamburger:hover::before {
        box-shadow: 0 7px 0 #f4012b;
    }

    /* ===== Topbar Center - Logo ===== */
    .topbar-center {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 1;
        pointer-events: auto;
    }

    .topbar-logo-link {
        padding: 4px 8px;
    }

    .topbar-logo {
        height: 36px;
        width: auto;
        max-width: 120px;
        object-fit: contain;
    }

    /* ===== Topbar Right - Action Buttons ===== */
    .topbar-right {
        flex: 0 0 auto;
        display: flex;
        align-items: center;
        gap: 12px !important;
        z-index: 2;
    }

    /* Hide text labels, show only icons */
    .topbar-btn span {
        display: none !important;
    }

    /* Consistent styling for all topbar buttons */
    .topbar-btn {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 38px !important;
        height: 38px !important;
        padding: 0 !important;
        border-radius: 50% !important;
        flex-shrink: 0;
        background: rgba(255, 255, 255, 0.08) !important;
        border: 1px solid rgba(255, 255, 255, 0.15) !important;
        color: #fff !important;
        transition: all 0.2s ease;
    }

    .topbar-btn:hover {
        background: rgba(255, 255, 255, 0.15) !important;
        border-color: rgba(255, 255, 255, 0.25) !important;
    }

    .topbar-btn i {
        font-size: 0.95rem !important;
        margin: 0 !important;
    }

    /* Admin button - consistent with others */
    .admin-btn {
        width: 38px !important;
        height: 38px !important;
    }

    .admin-btn i {
        font-size: 0.95rem !important;
    }

    /* Sign out button - subtle red tint */
    .signout-btn {
        background: rgba(244, 1, 43, 0.1) !important;
        border-color: rgba(244, 1, 43, 0.25) !important;
        color: #f4012b !important;
    }

    .signout-btn:hover {
        background: rgba(244, 1, 43, 0.2) !important;
        border-color: rgba(244, 1, 43, 0.4) !important;
    }

    /* Notification bell - match other buttons */
    .notification-bell {
        position: relative;
    }

    .bell-btn {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 38px !important;
        height: 38px !important;
        border-radius: 50% !important;
        background: rgba(255, 255, 255, 0.08) !important;
        border: 1px solid rgba(255, 255, 255, 0.15) !important;
        color: #fff !important;
        font-size: 0.95rem !important;
        transition: all 0.2s ease;
    }

    .bell-btn:hover {
        background: rgba(255, 255, 255, 0.15) !important;
        border-color: rgba(255, 255, 255, 0.25) !important;
        transform: none !important;
    }

    .bell-badge {
        position: absolute;
        top: -2px !important;
        right: -2px !important;
        min-width: 16px !important;
        height: 16px !important;
        font-size: 9px !important;
    }

    /* Notification dropdown mobile - full width */
    .notification-dropdown {
        position: fixed;
        top: var(--topbar-height);
        left: 0;
        right: 0;
        width: 100%;
        max-height: calc(100vh - var(--topbar-height));
        border-radius: 0;
        margin-top: 0;
        border-left: none;
        border-right: none;
    }

    /* ===== Grid layouts ===== */
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }

    /* ===== Main content padding ===== */
    .main-content {
        padding: 16px;
        padding-top: calc(var(--topbar-height) + 16px);
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* ===== Footer Mobile - Horizontal Layout ===== */
    .site-footer {
        padding: 1.5rem 1rem 1rem;
        width: 100%;
        max-width: 100vw;
        box-sizing: border-box;
    }

    .footer-content {
        width: 100%;
        max-width: 100%;
    }

    /* Stack footer vertically on mobile */
    .footer-main-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        text-align: center;
    }

    .footer-logo-section {
        justify-content: center;
    }

    .footer-logo-large {
        width: 140px;
        max-width: 140px;
    }

    /* Navigation columns - horizontal wrap */
    .footer-nav-columns {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 1.5rem;
    }

    .footer-section {
        flex: 0 0 auto;
        min-width: 100px;
        align-items: center;
        text-align: center;
    }

    .footer-title {
        font-size: 0.75rem;
        margin-bottom: 0.5rem;
    }

    .footer-links li {
        margin-bottom: 0.4rem;
    }

    .footer-links a {
        font-size: 0.8rem;
    }

    /* Social icons - centered row */
    .footer-socials {
        display: flex;
        justify-content: center;
        gap: 0.75rem;
    }

    .footer-socials a {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    /* Footer bottom bar */
    .footer-bottom {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
        padding-top: 1rem;
        margin-top: 1rem;
    }

    .footer-copyright {
        font-size: 0.7rem;
        order: 2;
    }

    .footer-disclaimer {
        font-size: 0.65rem;
        max-width: 100%;
        order: 1;
    }
}

/* ============ Small mobile devices (480px) ============ */
@media (max-width: 480px) {
    :root {
        --topbar-height: 60px;
    }

    /* Even more compact topbar */
    .topbar {
        padding: 0 8px;
    }

    .topbar-logo {
        height: 28px;
        max-width: 100px;
    }

    /* Topbar right - consistent spacing */
    .topbar-right {
        gap: 10px !important;
    }

    /* Smaller buttons but consistent styling */
    .topbar-btn {
        width: 34px !important;
        height: 34px !important;
    }

    .topbar-btn i {
        font-size: 0.85rem !important;
    }

    .admin-btn {
        width: 34px !important;
        height: 34px !important;
    }

    /* Bell button - match other buttons */
    .bell-btn {
        width: 34px !important;
        height: 34px !important;
        font-size: 0.85rem !important;
    }

    .bell-badge {
        min-width: 14px !important;
        height: 14px !important;
        font-size: 8px !important;
        top: -2px !important;
        right: -2px !important;
    }

    .hamburger {
        width: 40px;
        height: 40px;
    }

    .hamburger::before,
    .hamburger::after {
        width: 18px;
    }

    .hamburger::before {
        top: 12px;
        box-shadow: 0 6px 0 #fff;
    }

    .hamburger::after {
        bottom: 12px;
    }

    /* Notification badge - more compact */
    .bell-badge {
        height: 14px;
        font-size: 8px;
        top: 2px;
        right: 2px;
    }

    /* Admin button hidden or very small */
    .admin-btn {
        width: 32px;
        height: 32px;
    }

    .admin-btn i {
        font-size: 0.8rem;
    }

    /* Topbar right - tighter spacing */
    .topbar-right {
        gap: 2px;
    }

    /* Notification dropdown - more compact */
    .notification-dropdown {
        max-height: calc(100vh - 60px);
    }

    .dropdown-header {
        padding: 10px 12px;
    }

    .dropdown-header h3 {
        font-size: 11px;
    }

    .mark-all-btn {
        font-size: 10px;
        padding: 4px 8px;
    }

    .notification-item {
        padding: 10px;
    }

    .notif-icon {
        width: 28px;
        height: 28px;
        font-size: 11px;
        flex-shrink: 0;
    }

    .notif-content {
        min-width: 0;
    }

    .notif-title {
        font-size: 11px;
    }

    .notif-body {
        font-size: 10px;
    }

    .notif-time {
        font-size: 9px;
    }

    .notif-btn {
        padding: 5px 8px;
        font-size: 10px;
    }

    /* Main content */
    .main-content {
        padding: 12px;
        padding-top: calc(var(--topbar-height) + 12px);
    }

    /* Footer super compact */
    .site-footer {
        padding: 1rem 0.75rem;
    }

    .footer-logo-large {
        width: 100px;
        max-width: 100px;
    }

    .footer-nav-columns {
        gap: 1rem;
    }

    .footer-section {
        min-width: 80px;
    }

    .footer-title {
        font-size: 0.65rem;
    }

    .footer-links a {
        font-size: 0.7rem;
    }

    .footer-socials a {
        width: 32px;
        height: 32px;
        font-size: 0.85rem;
    }

    .footer-copyright {
        font-size: 0.6rem;
    }

    .footer-disclaimer {
        font-size: 0.55rem;
    }

    /* Sidebar adjustments for small screens */
    .sidebar-logo {
        width: 44px;
        height: 44px;
    }

    .sidebar-logo-img {
        width: 36px;
        height: 36px;
    }

    .sidebar-item {
        padding: 10px;
        font-size: 11px;
    }

    .sidebar-item-icon {
        font-size: 14px;
    }
}

/* ============ Extra small devices (360px and below) ============ */
@media (max-width: 360px) {
    :root {
        --topbar-height: 56px;
    }

    .topbar {
        padding: 0 6px;
    }

    .topbar-logo {
        height: 24px;
        max-width: 80px;
    }

    /* Topbar right - tighter but even spacing */
    .topbar-right {
        gap: 8px !important;
    }

    .topbar-btn {
        width: 30px !important;
        height: 30px !important;
    }

    .topbar-btn i {
        font-size: 0.75rem !important;
    }

    .hamburger {
        width: 36px;
        height: 36px;
    }

    /* Bell button - match other buttons */
    .bell-btn {
        width: 30px !important;
        height: 30px !important;
        font-size: 0.75rem !important;
    }

    .bell-badge {
        min-width: 12px !important;
        height: 12px !important;
        font-size: 7px !important;
        top: -1px !important;
        right: -1px !important;
    }

    /* Hide admin button on very small screens */
    .admin-btn {
        display: none;
    }

    .main-content {
        padding: 8px;
        padding-top: calc(var(--topbar-height) + 8px);
    }
}
