/* Global Responsive Framework for Pinball High Score Tracker */

/* ===== GOOGLE FONTS IMPORT ===== */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&display=swap');

/* ===== RESPONSIVE BREAKPOINTS ===== */
/* Mobile First Approach */
/* xs: 0-575px (default) */
/* sm: 576px+ */
/* md: 768px+ */
/* lg: 992px+ */
/* xl: 1200px+ */

/* ===== VIEWPORT META TAG ===== */
/* Add this to all HTML head sections:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
*/

/* ===== GLOBAL RESPONSIVE UTILITIES ===== */

/* Prevent horizontal scrolling */
html, body {
    overflow-x: hidden;
    width: 100%;
    box-sizing: border-box;
}

*, *:before, *:after {
    box-sizing: inherit;
}

/* Container with responsive max-widths */
.container {
    width: 100%;
    margin: 0 auto;
    padding: 0 15px;
    box-sizing: border-box;
}

@media (min-width: 576px) {
    .container {
        max-width: 540px;
    }
}

@media (min-width: 768px) {
    .container {
        max-width: 720px;
    }
}

@media (min-width: 992px) {
    .container {
        max-width: 960px;
    }
}

@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }
}

/* ===== RESPONSIVE GRID SYSTEM ===== */
.grid {
    display: grid;
    gap: 1rem;
}

/* Auto-fit responsive grids */
.grid-auto-fit {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.grid-auto-fill {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* Responsive columns */
.grid-1 { grid-template-columns: 1fr; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 767px) {
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }
}

/* ===== RESPONSIVE TYPOGRAPHY ===== */
html {
    font-size: 16px;
}

@media (max-width: 767px) {
    html {
        font-size: 14px;
    }
}

/* ===== RESPONSIVE HEADER & NAVIGATION ===== */
.header {
    background: #2c3e50;
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    width: 100%;
    box-sizing: border-box;
    position: relative;
}

.header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    width: 100%;
    margin: 0 auto;
    padding: 0 15px;
    box-sizing: border-box;
}

@media (min-width: 576px) {
    .header-content {
        max-width: 540px;
    }
}

@media (min-width: 768px) {
    .header-content {
        max-width: 720px;
    }
}

@media (min-width: 992px) {
    .header-content {
        max-width: 960px;
    }
}

@media (min-width: 1200px) {
    .header-content {
        max-width: 1140px;
    }
}

@media (min-width: 1440px) {
    .header-content {
        max-width: 1440px;
    }
}

.site-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Orbitron', sans-serif;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    word-wrap: break-word;
    max-width: 100%;
}

.site-title:hover {
    color: #ecf0f1;
    text-decoration: none;
    transform: scale(1.05);
    transition: transform 0.2s ease;
}

.site-title .logo-text {
    display: inline-block;
}

.site-title .pinball {
    color: #ff6b6b;
    text-shadow: 2px 2px 4px rgba(255, 107, 107, 0.3);
}

.site-title .high {
    color: #4ecdc4;
    text-shadow: 2px 2px 4px rgba(78, 205, 196, 0.3);
}

.site-title .score {
    color: #ffe66d;
    text-shadow: 2px 2px 4px rgba(255, 230, 109, 0.3);
}

@media (min-width: 768px) {
    .header-content {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    
    .site-title {
        font-size: 1.8rem;
    }
}

.nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
}

@media (min-width: 768px) {
    .nav-links {
        justify-content: flex-end;
        width: auto;
    }
}

.nav-links a {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background-color 0.2s;
    font-weight: 500;
    white-space: nowrap;
}

.nav-links a:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.nav-links span {
    color: #bdc3c7;
    font-weight: 500;
    white-space: nowrap;
}

/* Mobile hamburger menu */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background-color 0.2s;
    /* Debug: Make sure button is visible */
    min-width: 44px;
    min-height: 44px;
    z-index: 1001;
}

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

@media (max-width: 1024px) {
    .header-content {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    
    .mobile-menu-toggle {
        display: block;
        background: none;
        border: none;
        color: white;
        font-size: 1.5rem;
        cursor: pointer;
        padding: 0.5rem;
        border-radius: 4px;
        transition: background-color 0.2s;
        min-width: 44px;
        min-height: 44px;
        z-index: 1001;
    }
    
    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: #2c3e50;
        flex-direction: column;
        padding: 1rem;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        z-index: 1000;
        width: 100%;
        box-sizing: border-box;
    }
    
    .nav-links.active {
        display: flex;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        z-index: 1000;
        width: 100%;
        box-sizing: border-box;
    }
    
    .nav-links a,
    .nav-links span {
        padding: 0.75rem 1rem;
        border-radius: 4px;
        text-align: center;
        width: 100%;
        box-sizing: border-box;
        white-space: normal;
        word-wrap: break-word;
    }
    
    .nav-links a:hover {
        background-color: rgba(255, 255, 255, 0.1);
    }
}

/* ===== RESPONSIVE FOOTER ===== */
.footer {
    background: #34495e;
    color: #ecf0f1;
    padding: 2rem 0;
    margin-top: 3rem;
    border-top: 1px solid #2c3e50;
    width: 100%;
    box-sizing: border-box;
}

.footer-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    text-align: center;
    width: 100%;
    margin: 0 auto;
    padding: 0 15px;
    box-sizing: border-box;
}

@media (min-width: 576px) {
    .footer-content {
        max-width: 540px;
    }
}

@media (min-width: 768px) {
    .footer-content {
        max-width: 720px;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        text-align: left;
    }
}

@media (min-width: 992px) {
    .footer-content {
        max-width: 960px;
    }
}

@media (min-width: 1200px) {
    .footer-content {
        max-width: 1140px;
    }
}

@media (min-width: 1440px) {
    .footer-content {
        max-width: 1440px;
    }
}

.footer-links {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

@media (min-width: 768px) {
    .footer-links {
        justify-content: flex-end;
    }
}

.footer-links a {
    color: #bdc3c7;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
    white-space: nowrap;
}

.footer-links a:hover {
    color: white;
}

.footer-copyright {
    color: #95a5a6;
    font-size: 0.9rem;
}

/* ===== RESPONSIVE CARDS ===== */
.card {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 1rem;
    box-sizing: border-box;
    width: 100%;
}

@media (max-width: 767px) {
    .card {
        padding: 1rem;
    }
}

/* ===== RESPONSIVE TABLES ===== */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    box-sizing: border-box;
}

.table-responsive {
    width: 100%;
    min-width: 600px; /* Minimum width for table content */
}

/* Stack table on mobile */
@media (max-width: 767px) {
    .table-stack {
        display: block;
    }
    
    .table-stack thead {
        display: none;
    }
    
    .table-stack tbody {
        display: block;
    }
    
    .table-stack tr {
        display: block;
        margin-bottom: 1rem;
        padding: 1rem;
        border: 1px solid #ddd;
        border-radius: 4px;
        background: white;
    }
    
    .table-stack td {
        display: block;
        text-align: left;
        padding: 0.5rem 0;
        border: none;
    }
    
    .table-stack td:before {
        content: attr(data-label) ": ";
        font-weight: bold;
        display: inline-block;
        width: 120px;
    }
}

/* ===== RESPONSIVE FORMS ===== */
.form-group {
    margin-bottom: 1rem;
    width: 100%;
    box-sizing: border-box;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
    word-wrap: break-word;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    box-sizing: border-box;
}

@media (max-width: 767px) {
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* ===== RESPONSIVE BUTTONS ===== */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
    min-height: 44px; /* Touch-friendly */
    min-width: 120px; /* Ensure minimum width for consistency */
    box-sizing: border-box;
    word-wrap: break-word;
    white-space: normal;
}

.btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

@media (max-width: 767px) {
    .btn {
        width: 100%;
        margin-bottom: 0.5rem;
        min-width: auto; /* Allow full width on mobile */
    }
    
    .btn-group {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
}

@media (min-width: 768px) {
    .btn {
        margin: 0 0.25rem;
    }
    
    .btn-group {
        display: flex;
        gap: 0.5rem;
        align-items: center;
    }
}

/* ===== RESPONSIVE LEADERBOARD ===== */
.leaderboard {
    margin-top: 1rem;
    width: 100%;
    box-sizing: border-box;
}

.leaderboard-row {
    display: grid;
    gap: 0.5rem;
    padding: 0.75rem;
    border-bottom: 1px solid #eee;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
}

@media (min-width: 768px) {
    .leaderboard-row {
        grid-template-columns: 30px 50px 1fr 150px;
        gap: 1rem;
        padding: 1rem;
    }
}

@media (max-width: 767px) {
    .leaderboard-row {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .leaderboard-row .position {
        font-size: 1.2rem;
        font-weight: bold;
        margin-bottom: 0.5rem;
    }
    
    .leaderboard-row .username {
        font-size: 1.1rem;
        margin-bottom: 0.25rem;
        word-wrap: break-word;
    }
    
    .leaderboard-row .score {
        font-size: 0.9rem;
        color: #666;
    }
}

/* ===== RESPONSIVE MACHINE GRIDS ===== */
.machine-grid {
    display: grid;
    gap: 1rem;
    width: 100%;
    box-sizing: border-box;
}

@media (min-width: 576px) {
    .machine-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }
}

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

/* ===== RESPONSIVE SPACING ===== */
.section {
    margin-bottom: 2rem;
    width: 100%;
    box-sizing: border-box;
}

@media (max-width: 767px) {
    .section {
        margin-bottom: 1.5rem;
    }
}

/* ===== RESPONSIVE HIDING/SHOWING ===== */
.hide-mobile {
    display: none;
}

@media (min-width: 768px) {
    .hide-mobile {
        display: block;
    }
    
    .hide-desktop {
        display: none;
    }
}

/* ===== RESPONSIVE TEXT ===== */
.text-center-mobile {
    text-align: center;
}

@media (min-width: 768px) {
    .text-center-mobile {
        text-align: left;
    }
}

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

/* ===== RESPONSIVE UTILITIES ===== */
.w-full { width: 100%; }
.h-full { height: 100%; }

.p-0 { padding: 0; }
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 1rem; }
.p-4 { padding: 1.5rem; }

.m-0 { margin: 0; }
.m-1 { margin: 0.25rem; }
.m-2 { margin: 0.5rem; }
.m-3 { margin: 1rem; }
.m-4 { margin: 1.5rem; }

@media (max-width: 767px) {
    .p-4 { padding: 1rem; }
    .m-4 { margin: 1rem; }
}

/* ===== RESPONSIVE FLEXBOX ===== */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }

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

/* ===== PRINT STYLES ===== */
@media print {
    .header,
    .nav-links,
    .btn {
        display: none;
    }
    
    .container {
        max-width: none;
        padding: 0;
    }
}

/* ===== ADDITIONAL MOBILE FIXES ===== */
@media (max-width: 767px) {
    /* Prevent text overflow */
    h1, h2, h3, h4, h5, h6 {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* Ensure proper text wrapping */
    p, span, div {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* Fix any remaining horizontal scroll issues */
    * {
        max-width: 100%;
    }
    
    /* Ensure forms don't overflow */
    form {
        width: 100%;
        box-sizing: border-box;
    }
    
    /* Fix input fields on mobile */
    input, select, textarea {
        max-width: 100%;
        box-sizing: border-box;
    }
    
    /* Ensure proper alignment for sections */
    .section {
        width: 100%;
        text-align: left;
    }
    
    /* Fix stats grid alignment */
    .stats {
        justify-items: stretch;
    }
    
    /* Ensure cards are properly aligned */
    .card, .stat-card, .tracking-card, .machine-card, .feature-card {
        width: 100%;
        text-align: left;
    }
    
    /* Fix button alignment */
    .btn-group {
        align-items: stretch;
    }
    
    /* Ensure proper text alignment */
    .empty-state {
        text-align: center;
    }
    
    /* Override any centering that might cause issues */
    .container > * {
        text-align: left;
    }
    
    /* Ensure proper grid alignment */
    .grid, .machine-grid {
        justify-items: stretch;
    }
    
    /* Fix any flex alignment issues */
    .flex {
        align-items: flex-start;
    }
}