/* ============================================================
   CORE DASHBOARD STYLES (Fixes Sidebar & Layout)
   ============================================================ */
:root {
    --primary: #008080;      /* Teal Brand Color */
    --primary-light: #f0fdfa;
    --dark: #1e293b;
    --light: #f1f5f9;
    --white: #ffffff;
    --grey: #64748b;
    --border: #e2e8f0;
    --sidebar-width: 260px;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

* { box-sizing: border-box; }

/* Prevent horizontal page overflow globally */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    overflow-x: hidden; /* FIX: Stops the grey space on the right */
    font-family: 'Inter', sans-serif;
    background: var(--light);
    color: var(--dark);
    font-size: 0.9rem;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; padding: 0; margin: 0; }

/* --- SIDEBAR --- */
.sidebar {
    width: var(--sidebar-width);
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    background: var(--white);
    border-right: 1px solid var(--border);
    z-index: 1000;
    transition: margin-left 300ms, left 300ms;
    overflow-y: auto;
}

.sidebar .brand {
    height: 70px;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary);
    border-bottom: 1px solid var(--border);
}

.sidebar .brand i { margin-right: 10px; }

.sidebar .menu { margin-top: 1rem; padding: 0 1rem; }
.sidebar .menu li { margin-bottom: 5px; }
.sidebar .menu a {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    font-size: 0.95rem;
    color: var(--grey);
    border-radius: 8px;
    transition: 0.2s;
    font-weight: 500;
}

.sidebar .menu a i {
    font-size: 1.1rem;
    margin-right: 12px;
    width: 25px;
    text-align: center;
}

.sidebar .menu a:hover,
.sidebar .menu a.active {
    background: var(--primary-light);
    color: var(--primary);
}

/* --- MAIN CONTENT AREA --- */
.main-content {
    margin-left: var(--sidebar-width);
    transition: margin-left 300ms;
    min-height: 100vh;
    width: calc(100% - var(--sidebar-width)); /* Ensure it fits */
}

/* --- HEADER --- */
.main-content header {
    background: var(--white);
    height: 70px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 90;
    width: 100%; /* Fixes the cut-off header */
}

.toggle-btn {
    font-size: 1.5rem;
    cursor: pointer;
    margin-right: 1rem;
    display: none;
}

/* --- PAGE CONTENT --- */
.page-content {
    padding: 2rem;
    max-width: 100%;
}

/* --- CARDS & WIDGETS --- */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.card-single, .widget {
    background: var(--white);
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    max-width: 100%; /* Ensure widgets don't overflow */
    overflow-wrap: break-word;
}

.stat-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--dark); }
.stat-label { color: var(--grey); font-size: 0.9rem; }
.stat-icon { width: 50px; height: 50px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; }

.bg-green { background: #dcfce7; color: #166534; }
.bg-orange { background: #ffedd5; color: #c2410c; }
.bg-blue { background: #dbeafe; color: #1e40af; }
.bg-purple { background: #f3e8ff; color: #7e22ce; }

/* --- TABLES (FIXED FOR OVERFLOW) --- */
.table-container, .table-wrapper {
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow-x: auto !important; /* Forces scroll on mobile */
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    width: 100%;
    display: block;
}

table { 
    width: 100%; 
    border-collapse: collapse; 
    min-width: 550px; /* Prevents columns from squishing on mobile */
}

thead tr { background: #f8fafc; text-align: left; }
th { padding: 15px; font-size: 0.85rem; font-weight: 700; color: var(--grey); text-transform: uppercase; white-space: nowrap; }
td { padding: 15px; font-size: 0.95rem; border-bottom: 1px solid var(--border); color: #334155; }
tr:hover { background: #fdfdfd; }

/* --- BADGES --- */
.badge {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    display: inline-block;
    white-space: nowrap;
}
.badge.verified, .badge.delivered, .badge.paid { background: #dcfce7; color: #15803d; }
.badge.pending, .badge.transit { background: #ffedd5; color: #c2410c; }
.badge.suspended, .badge.cancelled, .badge.rejected { background: #fee2e2; color: #b91c1c; }
.badge.accepted { background: #e0f2fe; color: #0369a1; }

/* --- RESPONSIVE / MOBILE LOGIC FOR ADMIN DASHBOARD --- */
@media (max-width: 900px) {
    .sidebar { left: -100%; width: 260px; }
    .sidebar.active { left: 0; }
    .main-content { 
        margin-left: 0; 
        width: 100%; 
        overflow-x: hidden; /* Failsafe */
    }
    .main-content header { padding: 0 1rem; width: 100%; }
    .toggle-btn { display: block; }
    .page-content { padding: 1rem; width: 100%; }
    
    .overlay {
        position: fixed; top: 0; left: 0; width: 100%; height: 100%;
        background: rgba(0,0,0,0.5); z-index: 999; display: none;
    }
    .overlay.active { display: block; }
    
    .hide-mobile { display: none !important; }
}

/* ============================================================
   ALIEXPRESS MOBILE REPLICA (Appended styles)
   ============================================================ */
@media (max-width: 900px) {
    .page-container {
        padding: 8px !important;
        max-width: 100% !important;
        overflow-x: hidden;
    }
    .main-header {
        position: sticky; top: 0; z-index: 999; padding: 8px 12px !important;
        border-bottom: none !important; box-shadow: 0 1px 3px rgba(0,0,0,0.05); width: 100%;
    }
    .header-inner { gap: 10px !important; }
    .logo span { display: none; }
    .logo { font-size: 1.4rem !important; margin-right: 0 !important; }

    .search-container {
        border-radius: 99px !important; background: #f1f1f1 !important;
        border: 1px solid #e0e0e0 !important; height: 38px;
    }
    .search-input { background: transparent; font-size: 13px; }
    .search-btn {
        background: transparent !important; color: #333 !important;
        border-radius: 0 99px 99px 0 !important; padding: 0 15px !important;
    }
    .nav-icons { display: none !important; }
    .hero-layout { display: block !important; height: auto !important; margin-bottom: 10px !important; }

    .cat-sidebar {
        display: flex !important; width: 100vw; margin-left: -8px; padding: 5px 12px !important;
        overflow-x: auto; white-space: nowrap; background: transparent !important;
        box-shadow: none !important; -webkit-overflow-scrolling: touch; scrollbar-width: none;
        height: auto !important; position: relative !important; border: none !important; left: 0 !important;
    }
    .cat-sidebar::-webkit-scrollbar { display: none; }
    .cat-sidebar div:first-child { display: none; } 

    .cat-item {
        display: inline-block !important; background: white; padding: 6px 14px !important;
        border-radius: 15px !important; margin-right: 8px; font-size: 12px !important;
        font-weight: 500; color: #333 !important; border: none !important; flex-shrink: 0;
    }
    .cat-item:hover, .cat-item.active { color: var(--ali-red) !important; font-weight: 700 !important; }

    .user-box, .slider, .super-title, .grid-title { display: none !important; }

    .super-grid {
        display: flex !important; overflow-x: auto; gap: 8px !important;
        padding-bottom: 10px; margin-bottom: 15px !important; scrollbar-width: none;
    }
    .super-grid::-webkit-scrollbar { display: none; }
    .super-card { min-width: 130px; flex-direction: column !important; padding: 8px !important; gap: 5px !important; border: none !important; box-shadow: none !important; }
    .super-img { width: 100% !important; height: 110px !important; }
    .super-info { text-align: center; }
    .super-badge { display: none; }

    .ali-grid { display: grid !important; grid-template-columns: 1fr 1fr !important; gap: 8px !important; }
    .card { border-radius: 8px !important; border: none !important; box-shadow: none !important; margin-bottom: 0 !important; display: flex; flex-direction: column; }
    .img-wrap { padding-top: 100% !important; border-radius: 8px 8px 0 0; }
    .info { padding: 8px 10px 12px 10px !important; display: flex; flex-direction: column; }
    .title { font-size: 13px !important; line-height: 1.4 !important; height: 36px !important; margin-bottom: 6px !important; font-weight: 400 !important; color: #191919 !important; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
    .badge-choice { background-color: #f59e0b !important; color: #000 !important; font-size: 10px !important; padding: 1px 4px !important; border-radius: 3px !important; font-weight: 700 !important; margin-right: 4px; vertical-align: 1px; }
    .meta { font-size: 10px !important; color: #757575 !important; margin-bottom: 4px !important; }
    .meta i { font-size: 9px !important; color: #333; }
    .price-row { margin-top: auto; gap: 2px !important; align-items: baseline !important; }
    .curr { font-size: 11px !important; font-weight: 700; color: var(--ali-red); }
    .main-price { font-size: 18px !important; font-weight: 800 !important; color: var(--ali-red); letter-spacing: -0.5px; line-height: 1; }
    .disc-tag { font-size: 10px !important; background: #ffe6e6 !important; color: var(--ali-red) !important; padding: 1px 3px !important; margin-left: 4px; border-radius: 2px; }
    .old-price { font-size: 10px !important; margin-top: 0 !important; }
    .float-cart { width: 30px !important; height: 30px !important; bottom: 8px !important; right: 8px !important; background: white !important; color: #333 !important; border: 1px solid #eee !important; box-shadow: 0 2px 6px rgba(0,0,0,0.08) !important; }

    .vendor-grid { grid-template-columns: 1fr !important; gap: 12px !important; }
    .vendor-card { display: flex !important; flex-direction: row !important; height: 100px !important; }
    .v-banner { width: 100px !important; height: 100% !important; }
    .v-body { flex: 1; padding: 10px !important; }
    .v-avatar { width: 40px !important; height: 40px !important; margin-top: 0 !important; position: absolute; top: 10px; right: 10px; border: 1px solid #eee !important; }

    .mobile-bottom-nav {
        display: flex !important; position: fixed; bottom: 0; left: 0; width: 100%; height: 60px;
        background: #ffffff; border-top: 1px solid #e5e5e5; z-index: 10000; justify-content: space-between;
        padding: 0 10px; padding-bottom: env(safe-area-inset-bottom);
    }
    .nav-btn { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-decoration: none; color: #222; font-size: 10px; font-weight: 500; position: relative; }
    .nav-btn i { font-size: 22px; margin-bottom: 4px; color: #222; transition: 0.2s; }
    .nav-btn.active i { color: var(--ali-red); }
    .nav-btn.active span { color: var(--ali-red); font-weight: 700; }
    .nav-badge { position: absolute; top: 4px; right: 25%; background: var(--ali-red); color: white; font-size: 9px; padding: 1px 4px; border-radius: 10px; border: 1px solid white; font-weight: 700; }
    
    footer { padding-bottom: 80px; }
    .footer-newsletter, .footer-main { display: none !important; }
    .footer-bottom { background: transparent !important; color: #ccc !important; }
}

.mobile-bottom-nav { display: none; }