/* ========================================
   MAIN.CSS - Base styles for all pages
   ======================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: #f1f5f9;
    color: #1e293b;
    transition: background 0.3s ease, color 0.3s ease;
}

/* ========== Dashboard Container ========== */
.dashboard-container {
    display: flex;
    min-height: 100vh;
}

/* ========== Sidebar ========== */
.sidebar {
    width: 280px;
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    transition: all 0.3s ease;
    z-index: 100;
}

.sidebar::-webkit-scrollbar {
    width: 5px;
}

.sidebar::-webkit-scrollbar-track {
    background: #334155;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #3b82f6;
    border-radius: 10px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 30px 25px;
    font-size: 22px;
    font-weight: bold;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 20px;
}

.logo i {
    font-size: 28px;
    color: #3b82f6;
}

.logo span {
    color: white;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 15px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 20px;
    color: #94a3b8;
    text-decoration: none;
    border-radius: 12px;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
}

.nav-item i {
    width: 24px;
    font-size: 18px;
}

.nav-item:hover {
    background: rgba(59, 130, 246, 0.2);
    color: white;
    transform: translateX(5px);
}

.nav-item.active {
    background: #3b82f6;
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

/* ========== Mobile Menu Button ========== */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 101;
    background: #3b82f6;
    border: none;
    border-radius: 12px;
    padding: 10px 12px;
    color: white;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

/* ========== Sidebar Overlay ========== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 99;
}

/* ========== Main Content ========== */
.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 25px 35px;
    transition: all 0.3s ease;
}

/* ========== Header ========== */
.top-header {
    background: white;
    border-radius: 24px;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
    transition: background 0.3s ease;
}

.page-title h1 {
    font-size: 24px;
    color: #1e293b;
    transition: color 0.3s ease;
}

.page-title p {
    font-size: 14px;
    color: #64748b;
    margin-top: 5px;
    transition: color 0.3s ease;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info .fa-bell {
    font-size: 22px;
    color: #64748b;
    cursor: pointer;
    transition: color 0.3s;
}

.user-info .fa-bell:hover {
    color: #3b82f6;
}

.user-avatar {
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    color: white;
    cursor: pointer;
}

/* ========== Dark Mode Toggle ========== */
.dark-mode-toggle {
    background: #e2e8f0;
    border: none;
    border-radius: 40px;
    width: 50px;
    height: 26px;
    cursor: pointer;
    position: relative;
    transition: all 0.3s;
}

.dark-mode-toggle::after {
    content: "☀️";
    position: absolute;
    top: 3px;
    left: 4px;
    font-size: 18px;
    transition: all 0.3s;
}

/* ========== Show More Button ========== */
.show-more-btn {
    display: none;
    background: transparent;
    border: none;
    color: #94a3b8;
    padding: 12px 20px;
    text-align: center;
    width: 100%;
    cursor: pointer;
    font-size: 13px;
    margin-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-family: 'Inter', sans-serif;
    transition: all 0.3s;
}

.show-more-btn:hover {
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
}

/* ========================================
   RESPONSIVE
   ======================================== */

/* Tablet */
@media (max-width: 1024px) and (min-width: 769px) {
    .sidebar {
        width: 80px;
    }
    
    .sidebar .logo span,
    .sidebar .nav-item span {
        display: none;
    }
    
    .sidebar .nav-item {
        justify-content: center;
        padding: 12px;
    }
    
    .sidebar .nav-item i {
        width: auto;
    }
    
    .main-content {
        margin-left: 80px;
        padding: 20px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .mobile-menu-btn {
        display: block;
    }
    
    .sidebar {
        transform: translateX(-100%);
        width: 260px;
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 1000;
        transition: transform 0.3s ease;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar .logo span,
    .sidebar .nav-item span {
        display: inline;
    }
    
    .sidebar .nav-item {
        justify-content: flex-start;
        padding: 12px 20px;
    }
    
    .main-content {
        margin-left: 0;
        padding: 60px 15px 15px 15px;
    }
    
    .top-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
        padding: 15px;
    }
    
    .page-title h1 {
        font-size: 20px;
    }
    
    .user-info {
        justify-content: center;
    }
    
    .sidebar-overlay {
        display: none;
    }
    
    .sidebar.open ~ .sidebar-overlay,
    .sidebar.open + .sidebar-overlay {
        display: block;
    }
    
    .show-more-btn {
        display: block;
    }
    
    .sidebar .nav-menu .nav-item:nth-child(4),
    .sidebar .nav-menu .nav-item:nth-child(5),
    .sidebar .nav-menu .nav-item:nth-child(6) {
        display: none;
    }
    
    .sidebar.show-all .nav-menu .nav-item {
        display: flex !important;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .main-content {
        padding: 55px 10px 10px 10px;
    }
    
    .top-header {
        padding: 12px;
    }
    
    .page-title h1 {
        font-size: 18px;
    }
    
    .page-title p {
        font-size: 12px;
    }
    
    .dark-mode-toggle {
        width: 40px;
        height: 22px;
    }
    
    .dark-mode-toggle::after {
        font-size: 14px;
    }
    
    .user-avatar {
        width: 35px;
        height: 35px;
        font-size: 12px;
    }
    
    .sidebar {
        width: 85%;
        max-width: 280px;
    }
}

/* ========================================
   DARK MODE STYLES
   ======================================== */

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

body.dark-mode .top-header {
    background: #1e293b;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

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

body.dark-mode .page-title p {
    color: #94a3b8;
}

body.dark-mode .user-info .fa-bell {
    color: #94a3b8;
}

body.dark-mode .user-info .fa-bell:hover {
    color: #3b82f6;
}

body.dark-mode .stats-card,
body.dark-mode .kpi-card,
body.dark-mode .summary-card,
body.dark-mode .traffic-detail-item,
body.dark-mode .geo-item,
body.dark-mode .conversion-item,
body.dark-mode .metric-item {
    background: #1e293b;
    color: #f1f5f9;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

body.dark-mode .kpi-info h4,
body.dark-mode .stats-card h3 {
    color: #94a3b8;
}

body.dark-mode .kpi-number,
body.dark-mode .summary-value,
body.dark-mode .traffic-percent,
body.dark-mode .visitor-value,
body.dark-mode .conversion-rate {
    color: #f1f5f9;
}

body.dark-mode .traffic-item,
body.dark-mode .visitor-item,
body.dark-mode .top-list-item,
body.dark-mode .geo-item,
body.dark-mode .conversion-item {
    border-bottom-color: #334155;
}

body.dark-mode .progress-bar,
body.dark-mode .progress-bar-full,
body.dark-mode .geo-bar {
    background: #334155;
}

body.dark-mode .top-list-rank,
body.dark-mode .geo-rank {
    background: #3b82f6;
    color: white;
}

body.dark-mode .dark-mode-toggle {
    background: #334155;
}

body.dark-mode .dark-mode-toggle::after {
    content: "🌙";
    left: 26px;
}

body.dark-mode .show-more-btn {
    color: #94a3b8;
}

body.dark-mode .show-more-btn:hover {
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.2);
}
/* ========================================
   PREVENT HORIZONTAL SCROLL
   ======================================== */

html, body {
    overflow-x: hidden !important;
    width: 100%;
    max-width: 100%;
    position: relative;
}

.dashboard-container {
    overflow-x: hidden !important;
    width: 100%;
    max-width: 100%;
}

.main-content {
    overflow-x: hidden !important;
    width: 100%;
    max-width: 100%;
}

/* Fix for tables - make them scrollable without breaking page */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    max-width: 100%;
}

/* Fix for charts */
.stats-card canvas,
.chart-card canvas {
    max-width: 100% !important;
    height: auto !important;
}

/* Fix all images and elements */
img, iframe, canvas, svg, video {
    max-width: 100%;
    height: auto;
}

/* Fix all containers */
.stats-card,
.kpi-card,
.top-header,
.sidebar,
.main-content {
    max-width: 100%;
    overflow-x: hidden;
}

/* Fix grid containers */
.kpi-grid,
.dashboard-two-columns,
.dashboard-three-columns,
.countries-grid,
.conversion-grid,
.traffic-grid,
.visitors-grid,
.reports-grid {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

/* Fix all boxes */
* {
    max-width: 100%;
}

/* Make sure sidebar doesn't cause scroll */
.sidebar {
    overflow-x: hidden;
}

/* Fix for mobile */
@media (max-width: 768px) {
    .kpi-card,
    .stats-card,
    .top-header {
        width: 100%;
        box-sizing: border-box;
    }
    
    .kpi-grid,
    .dashboard-two-columns,
    .dashboard-three-columns {
        width: 100%;
        margin: 0;
        padding: 0;
    }
    
    .main-content {
        padding: 60px 10px 10px 10px;
        width: 100%;
        box-sizing: border-box;
    }
    
    /* Fix all text to wrap */
    .kpi-number,
    .kpi-info h4,
    .stats-card h3,
    .page-title h1,
    .page-title p {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* Fix flex items */
    .kpi-card {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .conversion-item,
    .traffic-item,
    .visitor-item,
    .geo-item,
    .top-list-item {
        flex-wrap: wrap;
        gap: 10px;
    }
}