/* ==================== RESPONSIVE STYLES ==================== */
/* Mobile First Approach - COMPLETE REWRITE */

/* ==================== BASE MOBILE FIXES ==================== */
* {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    width: 100%;
}

body {
    overflow-x: hidden;
    width: 100%;
    position: relative;
}

/* Prevent horizontal scroll */
.container,
.hero,
.section,
.features,
.stats-grid {
    max-width: 100%;
    overflow-x: hidden;
}

/* ==================== MOBILE (< 576px) ==================== */
@media (max-width: 575.98px) {
    body {
        font-size: 14px;
        overflow-x: hidden !important;
        width: 100vw;
    }
    
    /* Container fixes */
    .container {
        padding: 0 20px;
        max-width: 100%;
        width: 100%;
    }
    
    /* Navigation - Homepage */
    nav,
    .navbar {
        padding: 1rem 1.5rem;
        flex-wrap: wrap;
    }
    
    .navbar-brand,
    .logo {
        font-size: 1.2rem;
    }
    
    .navbar-menu {
        display: none;
    }
    
    /* Hero Section */
    .hero {
        padding: 6rem 1.5rem 4rem;
        text-align: center;
    }
    
    .hero h1 {
        font-size: 2rem !important;
        line-height: 1.2;
        margin-bottom: 1rem;
    }
    
    .hero p {
        font-size: 1rem !important;
        margin-bottom: 2rem;
    }
    
    .hero-buttons {
        flex-direction: column;
        gap: 1rem;
    }
    
    .hero-buttons .btn {
        width: 100%;
        justify-content: center;
    }
    
    /* Preview Windows */
    .preview-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
        padding: 0 1rem;
    }
    
    .preview-window {
        margin: 0;
    }
    
    /* Stats Grid */
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
        padding: 0 1rem;
    }
    
    /* Features */
    .feature-grid,
    .features {
        grid-template-columns: 1fr !important;
        gap: 1.5rem;
        padding: 0 1rem;
    }
    
    .feature-card {
        padding: 1.5rem;
    }
    
    .feature-icon {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
    
    /* Dashboard Sidebar */
    .sidebar {
        width: 280px !important;
        position: fixed;
        left: -280px;
        top: 0;
        height: 100vh;
        z-index: 2000;
        transition: left 0.3s ease;
        overflow-y: auto;
    }
    
    .sidebar.active {
        left: 0;
    }
    
    /* Dashboard Main Content */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    .nav-item {
        font-size: 14px;
        padding: 12px 15px;
    }
    
    /* Login Page */
    .login-grid {
        grid-template-columns: 1fr !important;
        gap: 3rem;
        padding: 0 1.5rem;
    }
    
    .login-left,
    .login-right {
        max-width: 100%;
    }
    
    .login-left h1 {
        font-size: 2rem !important;
    }
    
    .features {
        gap: 1rem;
    }
    
    .stats {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 0.5rem;
    }
    
    .stat {
        padding: 0.75rem 0.5rem;
    }
    
    .stat-num {
        font-size: 1.3rem;
    }
    
    /* Cards & Stats */
    .stat-card,
    .card {
        margin-bottom: 1rem;
        padding: 1rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    /* Buttons */
    .btn,
    button {
        padding: 0.75rem 1.5rem;
        font-size: 0.95rem;
    }
    
    /* Forms */
    input, 
    select, 
    textarea,
    .form-input {
        font-size: 16px !important; /* Prevent zoom on iOS */
        padding: 0.75rem;
    }
    
    /* Tables */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        font-size: 12px;
        min-width: 600px;
    }
    
    /* Modals */
    .modal-content,
    .server-selector-content {
        margin: 1rem;
        padding: 2rem;
        max-height: 85vh;
    }
    
    .servers-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }
    
    /* Typography */
    h1 { font-size: 2rem !important; }
    h2 { font-size: 1.5rem !important; }
    h3 { font-size: 1.25rem !important; }
    h4 { font-size: 1.1rem !important; }
    
    /* Spacing */
    section,
    .section {
        padding: 3rem 1.5rem !important;
    }
    
    .mb-4 { margin-bottom: 2rem; }
    .mt-4 { margin-top: 2rem; }
}

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) and (max-width: 767.98px) {
    .feature-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
    
    .stat-card {
        min-width: calc(50% - 10px);
    }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) and (max-width: 991.98px) {
    .sidebar {
        width: 250px;
    }
    
    .main-content {
        margin-left: 250px;
    }
    
    .feature-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 25px;
    }
    
    .stat-card {
        min-width: calc(33.333% - 15px);
    }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .sidebar {
        width: 280px;
    }
    
    .main-content {
        margin-left: 280px;
    }
    
    .feature-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 30px;
    }
    
    .stat-card {
        min-width: calc(25% - 15px);
    }
}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
    .container {
        max-width: 1400px;
        margin: 0 auto;
    }
    
    .feature-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 35px;
    }
}

/* General Responsive Utilities */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1001;
    background: var(--bg-secondary);
    border: none;
    padding: 10px 15px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 20px;
}

@media (max-width: 991.98px) {
    .mobile-menu-toggle {
        display: block;
    }
}

/* Flexbox Responsive Helpers */
.flex-wrap {
    flex-wrap: wrap;
}

.flex-column-mobile {
    @media (max-width: 767.98px) {
        flex-direction: column;
    }
}

/* Grid Responsive Helpers */
.grid-responsive {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

/* Text Responsive */
@media (max-width: 575.98px) {
    h1 { font-size: 24px; }
    h2 { font-size: 20px; }
    h3 { font-size: 18px; }
    h4 { font-size: 16px; }
    h5 { font-size: 14px; }
    h6 { font-size: 13px; }
}

/* Hide/Show on Different Devices */
.hide-mobile {
    @media (max-width: 767.98px) {
        display: none !important;
    }
}

.hide-tablet {
    @media (min-width: 768px) and (max-width: 991.98px) {
        display: none !important;
    }
}

.hide-desktop {
    @media (min-width: 992px) {
        display: none !important;
    }
}

.show-mobile {
    display: none !important;
    @media (max-width: 767.98px) {
        display: block !important;
    }
}

/* Spacing Adjustments */
@media (max-width: 767.98px) {
    .mb-4 { margin-bottom: 20px; }
    .mt-4 { margin-top: 20px; }
    .p-4 { padding: 20px; }
}

/* Image Responsive */
img {
    max-width: 100%;
    height: auto;
}

/* Font Awesome Icon Sizing */
.fas, .far, .fab {
    display: inline-block;
    min-width: 1.25em;
    text-align: center;
}

.fa-sm { font-size: 0.875em; }
.fa-lg { font-size: 1.25em; }
.fa-xl { font-size: 1.5em; }
.fa-2x { font-size: 2em; }
.fa-3x { font-size: 3em; }

/* Icon colors */
.text-primary { color: var(--accent-primary); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--error); }
.text-info { color: var(--info); }

/* Purple icons - Global styling */
.fas, .far, .fab, .fa {
    color: #d678ff;
}

/* Feature icons */
.feature-icon i,
.window-icon i,
.stat-icon i {
    color: #d678ff;
}

/* Medal colors */
.gold { color: #FFD700; }
.silver { color: #C0C0C0; }
.bronze { color: #CD7F32; }

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets */
    button, a, .nav-item {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Remove hover effects on touch devices */
    .btn:hover,
    .nav-item:hover {
        transform: none;
    }
}

/* Landscape orientation */
@media (orientation: landscape) and (max-height: 500px) {
    .sidebar {
        height: 100vh;
        overflow-y: auto;
    }
}

/* Print styles */
@media print {
    .sidebar,
    .mobile-menu-toggle,
    .btn,
    button {
        display: none !important;
    }
    
    .main-content {
        margin: 0;
        width: 100%;
    }
}

/* ==================== SMALL DEVICES (576px - 767px) ==================== */
@media (min-width: 576px) and (max-width: 767.98px) {
    .container {
        padding: 0 2rem;
    }
    
    .feature-grid,
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    .hero h1 {
        font-size: 2.5rem;
    }
    
    .login-grid {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        width: 280px;
        left: -280px;
    }
    
    .sidebar.active {
        left: 0;
    }
    
    .main-content {
        margin-left: 0;
    }
}

/* ==================== MEDIUM DEVICES (768px - 991px) ==================== */
@media (min-width: 768px) and (max-width: 991.98px) {
    .sidebar {
        width: 250px;
        left: -250px;
        transition: left 0.3s ease;
    }
    
    .sidebar.active {
        left: 0;
    }
    
    .main-content {
        margin-left: 0;
        transition: margin-left 0.3s ease;
    }
    
    .feature-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .hero h1 {
        font-size: 3rem;
    }
    
    .login-grid {
        grid-template-columns: 1fr;
        max-width: 600px;
        margin: 0 auto;
    }
}

/* ==================== LARGE DEVICES (992px - 1199px) ==================== */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .sidebar {
        width: 280px;
        left: 0;
        position: fixed;
    }
    
    .main-content {
        margin-left: 280px;
    }
    
    .feature-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .login-grid {
        grid-template-columns: 1fr 1fr;
        max-width: 1000px;
    }
}

/* ==================== EXTRA LARGE DEVICES (1200px+) ==================== */
@media (min-width: 1200px) {
    .container {
        max-width: 1400px;
        margin: 0 auto;
    }
    
    .sidebar {
        width: 280px;
        left: 0;
        position: fixed;
    }
    
    .main-content {
        margin-left: 280px;
    }
    
    .feature-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .login-grid {
        grid-template-columns: 1fr 1fr;
        max-width: 1100px;
    }
}

/* ==================== MOBILE MENU TOGGLE ==================== */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 2001;
    background: rgba(214, 120, 255, 0.2);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(214, 120, 255, 0.3);
    padding: 12px 15px;
    border-radius: 12px;
    cursor: pointer;
    color: #d678ff;
    font-size: 20px;
    transition: all 0.2s ease;
}

.mobile-menu-toggle:hover {
    background: rgba(214, 120, 255, 0.3);
    transform: scale(1.05);
}

.mobile-menu-toggle i {
    color: #d678ff;
}

@media (max-width: 991.98px) {
    .mobile-menu-toggle {
        display: block;
    }
    
    /* Add padding to body when menu toggle is visible */
    body {
        padding-top: 0;
    }
}

/* ==================== MOBILE MENU OVERLAY ==================== */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 1999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

/* ==================== UTILITY CLASSES ==================== */

/* Hide/Show on Different Devices */
.hide-mobile {
    @media (max-width: 767.98px) {
        display: none !important;
    }
}

.hide-tablet {
    @media (min-width: 768px) and (max-width: 991.98px) {
        display: none !important;
    }
}

.hide-desktop {
    @media (min-width: 992px) {
        display: none !important;
    }
}

.show-mobile {
    display: none !important;
}

@media (max-width: 767.98px) {
    .show-mobile {
        display: block !important;
    }
}

/* ==================== IMAGES RESPONSIVE ==================== */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ==================== GRID HELPERS ==================== */
.grid-responsive {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

@media (max-width: 575.98px) {
    .grid-responsive {
        grid-template-columns: 1fr;
    }
}

/* ==================== FLEXBOX HELPERS ==================== */
.flex-wrap {
    flex-wrap: wrap;
}

@media (max-width: 767.98px) {
    .flex-column-mobile {
        flex-direction: column !important;
    }
}

/* ==================== TOUCH OPTIMIZATIONS ==================== */
@media (hover: none) and (pointer: coarse) {
    /* Touch targets - minimum 44px */
    button,
    a,
    .btn,
    .nav-item,
    .clickable {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 20px;
    }
    
    /* Remove hover effects on touch */
    .btn:hover,
    .nav-item:hover,
    a:hover {
        transform: none !important;
    }
    
    /* Larger touch areas for small elements */
    input[type="checkbox"],
    input[type="radio"] {
        width: 24px;
        height: 24px;
    }
}

/* ==================== LANDSCAPE ORIENTATION ==================== */
@media (orientation: landscape) and (max-height: 500px) {
    .sidebar {
        height: 100vh;
        overflow-y: auto;
    }
    
    .hero {
        padding: 4rem 2rem 2rem;
    }
    
    .hero h1 {
        font-size: 2rem;
    }
}

/* ==================== PRINT STYLES ==================== */
@media print {
    .sidebar,
    .mobile-menu-toggle,
    .mobile-menu-overlay,
    .btn,
    button,
    nav,
    .navbar {
        display: none !important;
    }
    
    .main-content {
        margin: 0;
        width: 100%;
    }
    
    body {
        background: white;
        color: black;
    }
}

/* ==================== HIGH DPI SCREENS ==================== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .logo,
    .server-icon,
    .feature-icon {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

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

/* ==================== DARK MODE SUPPORT ==================== */
@media (prefers-color-scheme: dark) {
    /* Already dark by default */
}

@media (prefers-color-scheme: light) {
    /* Keep dark theme even in light mode preference */
}

/* ==================== FIXES FOR SPECIFIC ISSUES ==================== */

/* Fix horizontal overflow on mobile */
body,
html {
    max-width: 100vw;
    overflow-x: hidden;
}

/* Fix flexbox overflow */
.flex-container {
    min-width: 0;
}

/* Fix grid overflow */
.grid-container {
    min-width: 0;
}

/* Ensure all sections fit */
section,
.section,
.container {
    max-width: 100%;
    box-sizing: border-box;
}

/* Fix percentage-based widths */
.w-100 {
    width: 100%;
}

.w-auto {
    width: auto;
}

/* ==================== ANIMATION HELPERS ==================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease;
}

.slide-in-left {
    animation: slideInLeft 0.3s ease;
}
