/* Layout utama - Prevent horizontal scroll */
* {
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
}

body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

/* Dashboard Container */
.dashboard-container {
    display: flex;
    min-height: 100vh;
    position: relative;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

/* Mobile Menu Button */
.mobile-menu-btn {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.8rem;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: var(--card-shadow);
    display: none;
    transition: all 0.3s ease;
}

.mobile-menu-btn:hover {
    background: #1a5cc8;
    transform: scale(1.05);
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(32,124,229,0.18) 0%, rgba(106,130,251,0.18) 100%);
    z-index: 999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

/* Sidebar */
.sidebar {
    width: 220px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 1000;
    transition: box-shadow 0.3s, transform 0.3s, background 0.3s;
    border-radius: 0 15px 15px 0;
    box-shadow: 2px 0 20px rgba(36,113,243,0.12);
}

.sidebar .logo {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 8px rgba(36,113,243,0.10);
    text-align: left;
    padding: 0.5rem 0;
    padding-left: 3rem; /* Tambah padding kiri agar tidak tertutup toggle button di mobile */
}

.menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.menu a {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s ease;
    background: rgba(255,255,255,0.08);
    font-size: 0.9rem;
    font-weight: 500;
}

.menu a:hover,
.menu a.active {
    background: rgba(255,255,255,0.18);
    color: #fff;
    transform: translateX(3px);
}

.menu a i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

.logout-btn {
    margin-top: 1rem;
    background: #dc3545;
    color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(220,53,69,0.25);
    font-weight: 600;
    padding: 0.8rem;
    border: none;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.logout-btn:hover {
    background: #c82333;
    box-shadow: 0 4px 15px rgba(220,53,69,0.35);
    transform: translateY(-2px);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
    margin-left: 220px;  /* Match new sidebar width */
    background: #fff;
    overflow-x: hidden;
    max-width: calc(100vw - 220px);
    width: calc(100vw - 220px);
    box-sizing: border-box;
}

/* Profile Header */
.profile-header {
    text-align: center;
    padding: 3rem 2rem;
    background: white;
    border-radius: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    margin-bottom: 2rem;
}

.profile-photo {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--primary-color);
    margin: 0 auto 1rem auto;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: #f8f9fa;
}

.profile-photo img.user-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    border-radius: 50%;
    display: block;
    position: relative;
    z-index: 1;
    background: #f8f9fa;
}

.profile-photo .default-photo {
    position: absolute;
    left: 0; top: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.5rem;
    color: var(--primary-color);
    background: #f8f9fa;
    z-index: 2;
}

.profile-header h1 {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

/* Stats Container */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.stat-card {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    text-align: center;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.stat-card h3 {
    color: var(--text-color);
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.score, .rank {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 1rem 0;
}

.score small, .rank small {
    font-size: 1rem;
    opacity: 0.7;
}

.view-more {
    color: var(--primary-color);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    font-weight: 500;
}

/* Quick Actions */
.quick-actions {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.quick-actions h2 {
    margin-bottom: 1.5rem;
    color: var(--text-color);
}

.action-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    width: 100%;
    max-width: 100%;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 500;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    text-align: center;
    justify-content: center;
}

.action-btn.primary {
    background: var(--primary-color);
    color: white;
}

.action-btn.secondary {
    background: var(--light-gray);
    color: var(--text-color);
}

.action-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.1);
}

/* User Photo */
.user-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    border-radius: 50%;
    border: 3px solid var(--primary-color);
    background: #f0f0f0;
}

/* =========================== */
/* RESPONSIVE MEDIA QUERIES */
/* =========================== */

/* Mobile Phones (320px - 480px) */
@media screen and (max-width: 480px) {
    .main-content {
        margin-left: 0;
        padding: 1rem;
        padding-top: 4rem; /* Space for mobile menu button */
        overflow-x: hidden;
        max-width: 100vw;
        width: 100vw;
        box-sizing: border-box;
    }

    .profile-header {
        padding: 1.5rem 1rem;
        border-radius: 16px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .profile-header h1 {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
        text-align: center;
        word-wrap: break-word;
    }

    .profile-photo {
        width: 120px;
        height: 120px;
        margin-bottom: 1rem;
    }

    .stats-container {
        grid-template-columns: 1fr;
        gap: 1rem;
        width: 100%;
        max-width: 100%;
    }

    .stat-card {
        padding: 1.5rem;
        border-radius: 12px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .action-buttons {
        grid-template-columns: 1fr;
        gap: 1rem;
        width: 100%;
        max-width: 100%;
    }

    .action-btn {
        width: 100%;
        justify-content: center;
        padding: 1rem;
        font-size: 1rem;
        min-height: 44px;
        box-sizing: border-box;
    }

    /* Mobile sidebar toggle */
    .mobile-menu-btn {
        display: block;
    }
    
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

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

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

/* Mobile Phones (Portrait) - 768px and down */
@media (max-width: 768px) {
    body {
        overflow-x: hidden;
    }
    
    .mobile-menu-btn {
        display: block;
    }
    
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .sidebar-overlay.active {
        display: block;
        opacity: 1;
    }
    
    .main-content {
        margin-left: 0;
        width: 100vw;
        max-width: 100vw;
        padding: 1rem;
        padding-top: 4rem; /* Space for mobile menu button */
        overflow-x: hidden;
        box-sizing: border-box;
    }
    
    .profile-header {
        padding: 2rem 1rem;
        margin-bottom: 1rem;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .profile-header h1 {
        font-size: 1.5rem;
        margin-top: 0.5rem;
        margin-bottom: 1rem;
        word-wrap: break-word;
    }
    
    .stats-container {
        grid-template-columns: 1fr;
        gap: 1rem;
        width: 100%;
        max-width: 100%;
    }
    
    .action-buttons {
        grid-template-columns: 1fr;
        gap: 1rem;
        width: 100%;
        max-width: 100%;
    }

    .action-btn {
        width: 100%;
        padding: 1rem;
        box-sizing: border-box;
        min-height: 48px;
    }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 769px) and (max-width: 991px) {
    .mobile-menu-btn {
        display: block;
    }
    
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .sidebar-overlay.active {
        display: block;
        opacity: 1;
    }
    
    .main-content {
        margin-left: 0;
        width: 100vw;
        max-width: 100vw;
        padding: 1.5rem;
        padding-top: 4rem;
        overflow-x: hidden;
        box-sizing: border-box;
    }
    
    .stats-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }

    .action-buttons {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
}

/* Desktop - 992px and up */
@media (min-width: 992px) {
    .mobile-menu-btn {
        display: none;
    }
    
    .sidebar {
        transform: translateX(0);
    }
    
    .sidebar .logo {
        padding-left: 0; /* Reset padding di desktop */
    }
    
    .sidebar-overlay {
        display: none !important;
    }
    
    .main-content {
        margin-left: 220px;
        width: calc(100vw - 220px);
        max-width: calc(100vw - 220px);
        padding: 2rem;
        overflow-x: hidden;
        box-sizing: border-box;
    }

    .stats-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
    }

    .action-buttons {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }
}