/* Mobile-First Responsive Styles for DCS Statistics */

/* Global box-sizing fix to prevent overflow */
* {
    box-sizing: border-box;
}

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

/* Mobile Menu Button */
.mobile-menu-toggle {
    display: none;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    padding: 10px;
    z-index: 1001;
    position: relative;
    border-radius: 8px;
    margin-left: 10px;
}

.hamburger-line {
    display: block;
    width: 25px;
    height: 3px;
    background-color: #fff;
    margin: 5px 0;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

/* Mobile Menu Header */
.mobile-menu-header {
    display: none;
    padding: 20px;
    background: #1a1a1a;
    border-bottom: 2px solid #4CAF50;
    position: relative;
}

.mobile-menu-title {
    color: #4CAF50;
    font-size: 1.2rem;
    font-weight: bold;
}

.mobile-menu-close {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: 1px solid transparent;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s ease;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}

.mobile-menu-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.mobile-menu-close:active {
    transform: translateY(-50%) scale(0.95);
}

/* Ensure the X doesn't move */
.mobile-menu-close span {
    display: block;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    line-height: 1;
}

/* 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);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

/* Base Mobile Styles */
@media screen and (max-width: 768px) {
    /* Prevent horizontal scroll on all elements */
    * {
        max-width: 100vw !important;
    }
    
    /* Ensure images don't overflow */
    img {
        max-width: 100%;
        height: auto;
    }
    /* Show mobile menu toggle */
    .mobile-menu-toggle {
        display: block !important;
        margin-left: auto;
        flex-shrink: 0;
        position: fixed;
        top: 20px;
        right: 15px;
        z-index: 1002;
    }
    
    /* Header adjustments */
    .main-header {
        min-height: 80px;
        position: fixed;
        width: 100%;
        top: 0;
        left: 0;
        right: 0;
        z-index: 900;
    }
    
    .header-container {
        padding: 1rem;
        min-height: 80px;
        width: 100%;
        max-width: 100%;
        margin: 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    /* Header brand adjustments */
    .header-brand {
        flex: 1;
        min-width: 0;
        overflow: hidden;
        padding-right: 60px; /* Space for menu button */
    }
    
    .brand-text {
        overflow: hidden;
    }
    
    .site-title {
        font-size: 1.5rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .site-subtitle {
        font-size: 0.7rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .header-actions {
        display: none; /* Hide status indicator on mobile */
    }
    
    /* Navigation Mobile Styles */
    .nav-bar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 80%;
        max-width: 300px;
        height: 100vh;
        background: #1a1a1a;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
        transition: left 0.3s ease;
        z-index: 999;
        overflow-y: auto;
    }
    
    .nav-bar.mobile-menu-open {
        left: 0;
    }
    
    .mobile-menu-header {
        display: flex;
    }
    
    .nav-menu {
        flex-direction: column;
        padding: 0;
        margin: 0;
    }
    
    .nav-menu li {
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .nav-link {
        display: block;
        padding: 15px 20px;
        font-size: 1.1rem;
        transition: background 0.3s ease;
    }
    
    .nav-link:hover {
        background: rgba(76, 175, 80, 0.2);
    }
    
    /* Main content adjustments */
    body {
        padding-top: 80px; /* Account for fixed header */
        margin: 0;
    }
    
    main {
        padding: 1rem;
        width: 100%;
        max-width: 100%;
        margin: 0 auto;
        overflow-x: hidden;
    }
    
    /* Tables - Make them responsive */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -1rem;
        padding: 0 1rem;
    }
    
    table {
        min-width: 600px;
        font-size: 0.9rem;
    }
    
    th, td {
        padding: 8px 5px;
        white-space: nowrap;
    }
    
    /* Stats Cards - Stack vertically on mobile */
    .stats-cards {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
        padding: 0;
    }
    
    .stat-card {
        padding: 20px !important;
    }
    
    .stat-icon {
        font-size: 2rem !important;
    }
    
    .stat-number {
        font-size: 2rem !important;
    }
    
    /* Charts - Optimize for mobile */
    .charts-dashboard {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
        padding: 0 !important;
    }
    
    .chart-container {
        padding: 20px !important;
    }
    
    .chart-container h2 {
        font-size: 1.2rem !important;
    }
    
    .chart-container canvas {
        max-height: 250px !important;
    }
    
    /* Forms and inputs */
    input[type="text"],
    input[type="search"],
    input[type="email"],
    input[type="password"],
    select {
        width: 100%;
        padding: 12px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    button {
        min-height: 44px; /* Touch-friendly size */
        padding: 12px 20px;
        font-size: 1rem;
    }
    
    /* Search forms */
    .search-form {
        flex-direction: column;
        gap: 10px;
        width: 100%;
        max-width: 100%;
    }
    
    .search-form input {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .search-form button {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    /* Dashboard header */
    .dashboard-header {
        text-align: center;
        padding: 0;
    }
    
    .dashboard-header h1 {
        font-size: 1.8rem;
    }
    
    .dashboard-subtitle {
        font-size: 0.9rem;
    }
    
    /* Pilot statistics page */
    .pilot-info {
        flex-direction: column;
        gap: 10px;
    }
    
    .pilot-avatar {
        width: 80px;
        height: 80px;
    }
    
    /* Squadron page */
    .squadron-grid {
        grid-template-columns: 1fr !important;
    }
    
    .squadron-card {
        padding: 15px;
    }
    
    /* Loading overlay */
    .loading-overlay {
        font-size: 1rem;
    }
    
    .loader {
        width: 40px;
        height: 40px;
    }
    
    /* Footer adjustments */
    footer {
        padding: 20px 10px;
        font-size: 0.8rem;
    }
    
    /* Utility classes for mobile */
    .hide-mobile {
        display: none !important;
    }
    
    .show-mobile {
        display: block !important;
    }
    
    /* Leaderboard specific */
    .leaderboard-controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .leaderboard-controls button {
        width: 100%;
    }
    
    /* Modal adjustments */
    .modal-content {
        width: 95%;
        margin: 10px;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    /* Error messages */
    .error-message,
    .success-message,
    .warning-message {
        margin: 10px;
        padding: 15px;
        font-size: 0.9rem;
    }
}

/* Small Mobile Devices */
@media screen and (max-width: 480px) {
    .site-title {
        font-size: 1.2rem;
    }
    
    .site-subtitle {
        display: none;
    }
    
    .nav-bar {
        width: 85%;
    }
    
    table {
        font-size: 0.8rem;
    }
    
    th, td {
        padding: 5px 3px;
    }
    
    .stat-card {
        padding: 15px !important;
    }
    
    .chart-container {
        padding: 15px !important;
    }
    
    .chart-container canvas {
        max-height: 200px !important;
    }
}

/* Landscape Mobile */
@media screen and (max-width: 768px) and (orientation: landscape) {
    .main-header {
        min-height: 60px;
    }
    
    .header-container {
        min-height: 60px;
        padding: 0.5rem 1rem;
    }
    
    body {
        padding-top: 60px;
    }
    
    .site-title {
        font-size: 1.3rem;
    }
    
    .charts-dashboard {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Touch-friendly hover states */
@media (hover: none) and (pointer: coarse) {
    .nav-link:hover {
        background: transparent;
    }
    
    .nav-link:active {
        background: rgba(76, 175, 80, 0.3);
    }
    
    button:hover {
        transform: none;
    }
    
    button:active {
        transform: scale(0.95);
    }
}

/* Mobile Card Layouts for Tables */
.mobile-cards {
    display: none;
    width: 100%;
    max-width: 100%;
    padding: 0;
    margin: 0;
}

@media screen and (max-width: 768px) {
    /* Hide tables on mobile, show cards instead */
    .table-wrapper table,
    .table-responsive table {
        display: none;
    }
    
    .mobile-cards {
        display: block;
        padding: 0;
        width: 100%;
        max-width: 100%;
    }
    
    /* Card base styles */
    .mobile-card {
        background: rgba(0, 0, 0, 0.6);
        border: 1px solid rgba(76, 175, 80, 0.3);
        border-radius: 12px;
        padding: 15px;
        margin: 0 10px 15px 10px;
        transition: all 0.3s ease;
        width: calc(100% - 20px);
        max-width: calc(100% - 20px);
        box-sizing: border-box;
    }
    
    .mobile-card:active {
        transform: scale(0.98);
        background: rgba(76, 175, 80, 0.1);
    }
    
    /* Leaderboard cards */
    .leaderboard-card {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .leaderboard-card-left {
        flex: 1;
    }
    
    .leaderboard-card-rank {
        font-size: 1.5rem;
        font-weight: bold;
        color: #4CAF50;
        margin-bottom: 5px;
    }
    
    .leaderboard-card-name {
        font-size: 1.1rem;
        color: #fff;
        margin-bottom: 5px;
    }
    
    .leaderboard-card-stats {
        display: flex;
        gap: 15px;
        font-size: 0.9rem;
    }
    
    .leaderboard-card-stat {
        color: #ccc;
    }
    
    .leaderboard-card-stat span {
        color: #4CAF50;
        font-weight: bold;
    }
    
    /* Squadron cards */
    .squadron-card {
        position: relative;
    }
    
    .squadron-card-header {
        display: flex;
        align-items: center;
        gap: 15px;
        margin-bottom: 10px;
    }
    
    .squadron-card-logo {
        width: 50px;
        height: 50px;
        object-fit: cover;
        border-radius: 8px;
        border: 1px solid rgba(76, 175, 80, 0.3);
    }
    
    .squadron-card-info {
        flex: 1;
    }
    
    .squadron-card-name {
        font-size: 1.2rem;
        color: #4CAF50;
        margin-bottom: 5px;
    }
    
    .squadron-card-description {
        font-size: 0.85rem;
        color: #ccc;
        line-height: 1.4;
    }
    
    .squadron-card-members {
        font-size: 0.9rem;
        color: #999;
        margin-top: 10px;
    }
    
    /* Server cards */
    .server-card-header {
        display: flex;
        justify-content: space-between;
        align-items: start;
        margin-bottom: 10px;
    }
    
    .server-card-name {
        font-size: 1.1rem;
        color: #fff;
        margin-bottom: 3px;
    }
    
    .server-card-mission {
        font-size: 0.85rem;
        color: #999;
        margin-bottom: 5px;
    }
    
    .server-card-status {
        padding: 4px 10px;
        border-radius: 15px;
        font-size: 0.85rem;
        font-weight: bold;
    }
    
    .server-card-status.online {
        background: rgba(76, 175, 80, 0.2);
        color: #4CAF50;
    }
    
    .server-card-status.offline {
        background: rgba(244, 67, 54, 0.2);
        color: #f44336;
    }
    
    .server-card-info {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        font-size: 0.9rem;
    }
    
    .server-card-info-item {
        color: #ccc;
    }
    
    .server-card-info-item strong {
        color: #4CAF50;
        display: block;
        font-size: 0.8rem;
        margin-bottom: 2px;
    }
    
    /* Remove scroll indicators completely */
    .scroll-indicator {
        display: none !important;
    }
    
    /* Remove table wrapper styles on mobile */
    .table-wrapper::after {
        display: none !important;
    }
}

/* Custom scrollbar for mobile */
@media screen and (max-width: 768px) {
    *::-webkit-scrollbar {
        height: 6px;
        width: 6px;
    }
    
    *::-webkit-scrollbar-track {
        background: rgba(0, 0, 0, 0.1);
    }
    
    *::-webkit-scrollbar-thumb {
        background: #4CAF50;
        border-radius: 3px;
    }
    
    /* Better scrolling for mobile */
    body {
        -webkit-overflow-scrolling: touch;
    }
    
    main {
        min-height: calc(100vh - 80px);
        padding-bottom: 60px; /* Account for footer */
    }
}

/* Better form styling for mobile */
@media screen and (max-width: 768px) {
    .form-group {
        margin-bottom: 1rem;
    }
    
    label {
        display: block;
        margin-bottom: 0.5rem;
        font-weight: 600;
        color: #4CAF50;
    }
    
    .btn-group {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    
    .btn-group button {
        width: 100%;
    }
}

/* Improve readability on small screens */
@media screen and (max-width: 480px) {
    body {
        font-size: 14px;
    }
    
    p {
        line-height: 1.6;
    }
    
    /* Stack stat cards better */
    .stat-card {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }
    
    .stat-icon {
        margin: 0 auto;
    }
}

/* Global search container styles for all pages */
@media screen and (max-width: 768px) {
    .search-container {
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 0 15px;
        margin: 20px auto;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .search-container input[type="text"],
    .search-container input[type="search"],
    .search-container input {
        width: 100%;
        max-width: 100%;
        padding: 12px 15px;
        font-size: 16px; /* Prevents zoom on iOS */
        border-radius: 25px;
        background: rgba(0, 0, 0, 0.6);
        border: 1px solid rgba(76, 175, 80, 0.3);
        color: #fff;
        box-sizing: border-box;
    }
    
    .search-container button {
        width: 100%;
        padding: 12px 20px;
        font-size: 1rem;
        border-radius: 25px;
        min-height: 44px;
        background: #4CAF50;
        color: white;
        border: none;
        cursor: pointer;
    }
    
    /* Results list for all pages */
    .results-list {
        padding: 0 10px;
        max-height: 300px;
        overflow-y: auto;
        margin-top: 10px;
    }
    
    .result-item {
        padding: 15px;
        margin: 8px 0;
        background: rgba(0, 0, 0, 0.6);
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.3s ease;
    }
    
    /* Pilot card styles for all pages */
    .pilot-card {
        padding: 15px;
        margin: 15px;
        background: rgba(0, 0, 0, 0.6);
        border-radius: 12px;
    }
    
    .pilot-card h3 {
        font-size: 1.5rem;
        margin-bottom: 15px;
        color: #4CAF50;
    }
    
    /* Stats grid for all pages */
    .stats-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .stat-item {
        display: flex;
        justify-content: space-between;
        padding: 12px;
        background: rgba(0, 0, 0, 0.3);
        border-radius: 5px;
    }
    
    .stat-group {
        margin-bottom: 20px;
    }
    
    .stat-group h4 {
        font-size: 1.1rem;
        margin-bottom: 10px;
        color: #4CAF50;
    }
    
    /* Dashboard headers for all pages */
    .dashboard-header {
        text-align: center;
        padding: 0 15px;
        margin-bottom: 20px;
    }
    
    .dashboard-header h1 {
        font-size: 1.8rem;
        margin-bottom: 10px;
    }
    
    .dashboard-subtitle {
        font-size: 0.9rem;
        color: #ccc;
    }
    
    /* Alert messages */
    .alert {
        padding: 30px 15px !important;
        margin: 15px;
    }
    
    .alert h2 {
        font-size: 1.5rem;
    }
    
    .alert p {
        font-size: 1rem;
    }
    
    /* Container adjustments */
    .container {
        padding: 0 15px;
        max-width: 100%;
    }
    
    /* Trophy boxes on leaderboard */
    .trophy-box {
        padding: 15px;
        margin: 10px 0;
    }
    
    .top-3-container {
        flex-direction: column;
    }
    
    /* General form elements */
    input, select, textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Buttons */
    button, .button, .btn {
        min-height: 44px;
        padding: 12px 20px;
        font-size: 1rem;
        cursor: pointer;
    }
    
    /* Error and success messages */
    .error-message,
    .success-message,
    .warning-message,
    .no-results {
        padding: 20px 15px;
        margin: 15px;
        border-radius: 8px;
    }
}

/* Landscape adjustments */
@media screen and (max-width: 768px) and (orientation: landscape) {
    .dashboard-header h1 {
        font-size: 1.5rem;
    }
    
    .main-header {
        min-height: 60px;
    }
    
    body {
        padding-top: 60px;
    }
}

/* Very small devices additional styles */
@media screen and (max-width: 480px) {
    /* Even smaller text */
    body {
        font-size: 14px;
    }
    
    .dashboard-header h1 {
        font-size: 1.4rem;
    }
    
    .dashboard-subtitle {
        font-size: 0.8rem;
    }
    
    /* Smaller padding on containers */
    main {
        padding: 10px;
    }
    
    .pilot-card,
    .alert,
    .no-results {
        margin: 10px;
        padding: 10px;
    }
    
    /* Smaller stat items */
    .stat-item {
        padding: 8px;
        font-size: 0.85rem;
    }
    
    /* Adjust button sizes */
    button, .button, .btn {
        padding: 10px 15px;
        font-size: 0.9rem;
    }
}

/* Footer mobile styles */
@media screen and (max-width: 768px) {
    footer {
        padding: 20px 15px;
        font-size: 0.85rem;
        text-align: center;
        line-height: 1.6;
    }
    
    footer p {
        margin: 0;
    }
    
    footer a {
        display: inline-block;
        margin: 0 5px;
    }
}

@media screen and (max-width: 480px) {
    footer {
        font-size: 0.75rem;
        padding: 15px 10px;
    }
    
    footer a {
        display: block;
        margin: 5px 0;
    }
}

/* Print styles for mobile */
@media print {
    .mobile-menu-toggle,
    .mobile-menu-overlay,
    .nav-bar {
        display: none !important;
    }
    
    body {
        padding-top: 0 !important;
        position: static !important;
        height: auto !important;
    }
    
    main {
        height: auto !important;
        overflow: visible !important;
    }
    
    .main-header {
        position: relative !important;
    }
}