/* ========================================
   📱 MOBILE-FIRST RESPONSIVE DESIGN
   99% موبایل محور - بهترین تجربه کاربری
   ======================================== */

/* ========================================
   📱 BASE MOBILE STYLES (Default)
   ======================================== */
html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    padding: 12px;
    max-width: 100%;
}

/* ========================================
   🎯 NAVBAR - موبایل با همبرگر
   ======================================== */
.navbar {
    padding: 12px 0;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
}

.nav-brand {
    font-size: 16px;
    gap: 8px;
    z-index: 10002;
}

.nav-logo {
    width: 32px;
    height: 32px;
}

.hamburger {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    z-index: 10002;
    border-radius: 6px;
    transition: background 0.3s ease;
}

.hamburger:hover {
    background: var(--bg-hover);
}

.hamburger span {
    width: 100%;
    height: 2.5px;
    background: var(--text-color);
    border-radius: 3px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hamburger.active span:nth-child(1) {
    transform: translateY(9px) rotate(45deg);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
    transform: translateX(20px);
}

.hamburger.active span:nth-child(3) {
    transform: translateY(-9px) rotate(-45deg);
}

.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

.nav-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 85%;
    max-width: 320px;
    height: 100vh;
    background: var(--card-bg);
    padding: 0;
    margin: 0;
    list-style: none;
    z-index: 10001;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
}

[data-theme="dark"] .nav-menu {
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.6);
    border-left: 1px solid rgba(255, 107, 53, 0.15);
}

.nav-menu.active {
    right: 0;
}

.mobile-menu-header {
    background: var(--gradient-game);
    padding: 24px 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.mobile-user-info {
    display: flex;
    align-items: center;
    gap: 14px;
    color: white;
    flex: 1;
}

.mobile-avatar {
    width: 52px;
    height: 52px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    flex-shrink: 0;
}

.mobile-username {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 4px;
    line-height: 1.3;
}

.mobile-user-role {
    font-size: 13px;
    opacity: 0.9;
    font-weight: 500;
}

.mobile-close {
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    line-height: 1;
    flex-shrink: 0;
    margin-top: -4px;
}

.mobile-close:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: rotate(90deg);
}

.nav-menu > li {
    width: 100%;
    border-bottom: 1px solid var(--border-color);
}

.nav-menu a {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 18px 20px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
    text-decoration: none;
    transition: all 0.3s ease;
    background: transparent;
    position: relative;
}

.nav-menu a.active {
    background: var(--gradient-primary);
    color: white;
}

.nav-menu a::before {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    width: 4px;
    height: 100%;
    background: var(--primary-color);
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.nav-menu a:hover {
    background: var(--bg-hover);
    padding-right: 28px;
}

.nav-menu a:hover::before {
    transform: scaleY(1);
}

.menu-icon {
    font-size: 22px;
    width: 28px;
    text-align: center;
    flex-shrink: 0;
}

.desktop-only {
    display: none;
}

.admin-link {
    color: var(--warning-color) !important;
    font-weight: 700;
}

.mobile-logout {
    margin-top: auto;
    border-top: 2px solid var(--border-color);
    border-bottom: none;
}

.logout-link {
    color: var(--error-color) !important;
    font-weight: 700;
    background: var(--bg-primary);
}

.logout-link:hover {
    background: var(--error-light) !important;
}

.nav-menu::-webkit-scrollbar {
    width: 6px;
}

.nav-menu::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

.nav-menu::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3px;
}

/* ========================================
   💻 TABLET (768px+)
   ======================================== */
@media (min-width: 768px) {
    .container {
        padding: 24px;
        max-width: 1200px;
        margin: 0 auto;
    }
    
    .hamburger {
        display: none;
    }
    
    .mobile-menu-overlay {
        display: none !important;
    }
    
    .navbar {
        padding: 16px 0;
    }
    
    .navbar .container {
        padding: 12px 24px;
    }
    
    .nav-brand {
        font-size: 22px;
    }
    
    .nav-logo {
        width: 40px;
        height: 40px;
    }
    
    .nav-menu {
        position: static;
        width: auto;
        height: auto;
        flex-direction: row;
        background: transparent;
        box-shadow: none;
        gap: 12px;
        overflow: visible;
        max-width: none;
    }
    
    .mobile-menu-header {
        display: none;
    }
    
    .nav-menu > li {
        width: auto;
        border: none;
    }
    
    .nav-menu a {
        padding: 10px 18px;
        background: transparent;
        border-radius: 10px;
        font-size: 15px;
        gap: 8px;
    }

    .nav-menu a.active {
        background: var(--gradient-primary);
        color: white;
    }
    
    .nav-menu a::before {
        display: none;
    }
    
    .nav-menu a:hover {
        background: var(--bg-hover);
        padding-right: 18px;
        transform: translateY(-2px);
    }
    
    .menu-icon {
        font-size: 18px;
        width: 20px;
    }
    
    .mobile-logout {
        margin-top: 0;
        border: none;
    }
    
    .logout-link {
        background: var(--gradient-primary) !important;
        color: white !important;
        box-shadow: var(--shadow-md);
    }
    
    .logout-link:hover {
        background: var(--primary-dark) !important;
        box-shadow: var(--shadow-lg);
    }

    .desktop-only {
        display: list-item;
    }
    
    .main-content {
        padding: 32px 24px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
    
    .stat-card {
        padding: 24px;
    }
    
    .game-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 24px;
    }
    
    .game-card {
        padding: 36px 28px;
    }
    
    .modal-content {
        width: 80%;
        max-width: 550px;
    }
    
    .modal-actions {
        grid-template-columns: 1fr 1fr;
    }
    
    .room-card {
        flex-direction: row;
        align-items: center;
        padding: 20px;
    }
    
    .room-card .btn {
        width: auto;
        min-width: 140px;
    }
    
    .game-header {
        flex-direction: row;
        justify-content: space-between;
        padding: 20px;
    }
    
    .game-info {
        flex-direction: row;
        width: auto;
        gap: 16px;
    }
    
    .auth-box {
        max-width: 500px;
        padding: 40px;
    }
    
    .alert {
        flex-direction: row;
        text-align: right;
    }
    
    .balance-cards {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .wallet-actions {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .admin-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ========================================
   🖥️ DESKTOP (1025px+)
   ======================================== */
@media (min-width: 1025px) {
    .container {
        max-width: 1400px;
    }
    
    .nav-brand {
        font-size: 24px;
    }
    
    .nav-logo {
        width: 45px;
        height: 45px;
    }
    
    .nav-menu {
        gap: 16px;
    }
    
    .nav-menu a {
        padding: 12px 20px;
        font-size: 16px;
    }
    
    .main-content {
        padding: 40px 32px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 24px;
    }
    
    .stat-card {
        padding: 28px;
    }
    
    .game-cards {
        grid-template-columns: repeat(3, 1fr);
        gap: 28px;
    }
    
    .game-card {
        padding: 40px 32px;
    }
    
    .admin-stats {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .game-actions {
        flex-direction: row;
        justify-content: flex-start;
    }
    
    .game-actions .btn {
        width: auto;
        min-width: 180px;
    }
}

/* ========================================
   🖥️ LARGE DESKTOP (1440px+)
   ======================================== */
@media (min-width: 1440px) {
    .container {
        max-width: 1600px;
    }
    
    .stats-grid {
        gap: 28px;
    }
    
    .stat-card {
        padding: 32px;
    }
    
    .game-cards {
        gap: 32px;
    }
}

/* ========================================
   📱 MOBILE DIALOGS
   ======================================== */
@media (max-width: 600px) {
    .app-toast-container {
        top: 72px;
        right: 12px;
        left: 12px;
        max-width: none;
    }

    .app-dialog-actions {
        grid-template-columns: 1fr;
    }

    .dashboard-hero {
        flex-direction: column;
        align-items: flex-start;
    }

    .dashboard-banner {
        flex-direction: column;
        align-items: flex-start;
    }

    .recent-game-card {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ========================================
   📱 SMALL MOBILE (< 375px)
   ======================================== */
@media (max-width: 374px) {
    html {
        font-size: 14px;
    }
    
    .container {
        padding: 10px;
    }
    
    .nav-brand {
        font-size: 14px;
    }
    
    .nav-logo {
        width: 28px;
        height: 28px;
    }
}

/* ========================================
   🎯 LANDSCAPE MODE
   ======================================== */
@media (max-width: 896px) and (orientation: landscape) {
    .nav-menu {
        width: 90%;
        max-width: 360px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .game-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ========================================
   🎨 ANIMATIONS
   ======================================== */
@keyframes slideInRight {
    from {
        right: -100%;
        opacity: 0;
    }
    to {
        right: 0;
        opacity: 1;
    }
}

.nav-menu.active {
    animation: slideInRight 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-menu.active li {
    animation: fadeInUp 0.5s ease forwards;
    opacity: 0;
}

.nav-menu.active .mobile-menu-header { animation-delay: 0s; opacity: 1; }
.nav-menu.active li:nth-child(2) { animation-delay: 0.1s; }
.nav-menu.active li:nth-child(3) { animation-delay: 0.15s; }
.nav-menu.active li:nth-child(4) { animation-delay: 0.2s; }
.nav-menu.active li:nth-child(5) { animation-delay: 0.25s; }
.nav-menu.active li:nth-child(6) { animation-delay: 0.3s; }

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========================================
   🌐 PWA SUPPORT
   ======================================== */
@media (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* ========================================
   📶 OFFLINE INDICATOR
   ======================================== */
.offline-indicator {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--error-color);
    color: white;
    padding: 12px 24px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 700;
    box-shadow: var(--shadow-xl);
    z-index: 10001;
    display: none;
}

.offline-indicator.show {
    display: block;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}
