/**
 * GameVerse - Ana Stil Dosyası
 * Responsive, modern ve performans optimize edilmiş CSS
 * 
 * @version 1.0.0
 * @author GameVerse Team
 */

/* ==================== RESET & BASE ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    touch-action: manipulation;
    transition: background 0.3s ease, color 0.3s ease;
    line-height: 1.6;
}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg2);
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--primary2);
}

/* ==================== TYPOGRAPHY ==================== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 0.5em;
}

h1 { font-size: 2.5em; }
h2 { font-size: 2em; }
h3 { font-size: 1.5em; }
h4 { font-size: 1.25em; }
h5 { font-size: 1em; }
h6 { font-size: 0.875em; }

p {
    margin-bottom: 1em;
}

a {
    color: var(--primary2);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--accent);
}

/* ==================== FORMS ==================== */
button, input, select, textarea {
    font-family: var(--font);
    font-size: inherit;
}

input, select, textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--r);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1);
}

input::placeholder, textarea::placeholder {
    color: var(--text3);
}

/* ==================== BUTTONS ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--r);
    font-weight: 600;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

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

.btn-p {
    background: var(--gradient);
    color: #fff;
}

.btn-a {
    background: var(--gradient2);
    color: #000;
}

.btn-o {
    background: transparent;
    border: 2px solid var(--border2);
    color: var(--text);
}

.btn-d {
    background: var(--danger);
    color: #fff;
}

.btn-s {
    background: var(--bg3);
    color: var(--text);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8em;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1em;
}

.btn-full {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ==================== CARDS ==================== */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r2);
    padding: 18px;
    transition: all 0.3s ease;
}

.card:hover {
    border-color: var(--border2);
    box-shadow: var(--shadow);
}

/* ==================== STATS ==================== */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.stat {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r2);
    padding: 16px;
    text-align: center;
}

.stat-icon {
    font-size: 2em;
    margin-bottom: 8px;
}

.stat-val {
    font-size: 1.8em;
    font-weight: 800;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 0.78em;
    color: var(--text2);
    margin-top: 4px;
}

/* ==================== GAMES GRID ==================== */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.game-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r2);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.game-card:hover {
    border-color: var(--primary);
    transform: translateY(-6px);
    box-shadow: 0 12px 40px rgba(108, 92, 231, 0.25);
}

.game-thumb {
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4em;
    background: linear-gradient(135deg, var(--bg3), var(--bg2));
}

.game-info {
    padding: 14px;
}

.game-info h3 {
    font-size: 1em;
    margin-bottom: 4px;
}

.game-info p {
    font-size: 0.8em;
    color: var(--text2);
    margin-bottom: 8px;
}

.game-players-count {
    font-size: 0.8em;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 4px;
}

.game-tag {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.7em;
    font-weight: 700;
    color: #fff;
}

.game-tag.hot { background: var(--danger); }
.game-tag.new { background: var(--success); color: #000; }
.game-tag.pop { background: var(--primary); }

/* ==================== LOBBY & ROOMS ==================== */
.lobby-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    flex-wrap: wrap;
    gap: 10px;
}

.lobby-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.rooms-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.room {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r);
    font-size: 0.9em;
    flex-wrap: wrap;
    transition: all 0.2s ease;
}

.room:hover {
    border-color: var(--primary);
    background: var(--card2);
}

.room-id {
    color: var(--text3);
    font-family: var(--mono);
    font-size: 0.85em;
}

.room-name {
    font-weight: 600;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.room-status {
    padding: 3px 10px;
    border-radius: 8px;
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
}

.room-status.waiting { background: var(--warning); color: #000; }
.room-status.playing { background: var(--primary); color: #fff; }
.room-status.full { background: var(--danger); color: #fff; }

/* ==================== MODALS ==================== */
.modal-bg {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

.modal-bg.show {
    display: flex;
}

.modal {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--r2);
    padding: 24px;
    max-width: 600px;
    width: 92%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    animation: slideUp 0.3s ease;
}

.modal-x {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    color: var(--text3);
    font-size: 1.5em;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.modal-x:hover {
    background: var(--card);
    color: var(--text);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* ==================== TOAST NOTIFICATIONS ==================== */
.toast-wrap {
    position: fixed;
    top: 70px;
    right: 16px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    max-height: 70vh;
    overflow: hidden;
}

.toast {
    padding: 12px 18px;
    border-radius: var(--r);
    background: var(--bg2);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastIn 0.3s ease;
    min-width: 280px;
    pointer-events: auto;
    font-size: 0.9em;
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.info { border-color: var(--primary); }
.toast.warning { border-color: var(--warning); }

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

/* ==================== SPINNER ==================== */
.spinner {
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==================== UTILITY CLASSES ==================== */
.center { text-align: center; }
.left { text-align: left; }
.right { text-align: right; }

.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.ml { margin-left: 16px; }
.mr { margin-right: 16px; }

.mt-2 { margin-top: 8px; }
.mb-2 { margin-bottom: 8px; }

.hidden { display: none !important; }
.visible { display: block !important; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }

.text-primary { color: var(--primary); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--text2); }

.bg-primary { background: var(--primary); }
.bg-accent { background: var(--accent); }
.bg-success { background: var(--success); }
.bg-danger { background: var(--danger); }

.rounded { border-radius: var(--r); }
.rounded-full { border-radius: 50%; }

.shadow { box-shadow: var(--shadow); }
.glow { box-shadow: var(--glow); }

/* ==================== RESPONSIVE DESIGN ==================== */

/* Tablet */
@media (max-width: 1024px) {
    html {
        font-size: 15px;
    }
    
    .games-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
    
    .sidebar {
        width: 200px;
    }
    
    .right-panel {
        width: 250px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    html {
        font-size: 14px;
    }
    
    .header {
        height: 50px;
        padding: 0 12px;
    }
    
    .hamburger {
        display: block;
    }
    
    .nav {
        display: none;
        position: absolute;
        top: 50px;
        left: 0;
        right: 0;
        background: var(--bg2);
        flex-direction: column;
        padding: 10px;
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow);
    }
    
    .nav.active {
        display: flex;
    }
    
    .nav-btn {
        padding: 12px;
        justify-content: center;
    }
    
    .layout {
        flex-direction: column;
        height: calc(100vh - 50px);
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    
    .right-panel {
        display: none;
    }
    
    .content {
        padding: 12px;
    }
    
    .games-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
    }
    
    .game-thumb {
        height: 100px;
        font-size: 3em;
    }
    
    .stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .modal {
        width: 95%;
        padding: 18px;
    }
    
    .toast-wrap {
        right: 12px;
        top: 60px;
    }
    
    .toast {
        min-width: auto;
        width: calc(100vw - 40px);
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    html {
        font-size: 13px;
    }
    
    .games-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .game-card {
        border-radius: var(--r);
    }
    
    .game-thumb {
        height: 80px;
        font-size: 2.5em;
    }
    
    .btn {
        padding: 8px 16px;
        font-size: 0.85em;
    }
    
    .btn-sm {
        padding: 5px 10px;
        font-size: 0.75em;
    }
    
    .btn-lg {
        padding: 12px 24px;
    }
}

/* Landscape Mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .layout {
        flex-direction: column;
    }
    
    .sidebar {
        max-height: 150px;
    }
    
    .modal {
        max-height: 90vh;
    }
}

/* Print Styles */
@media print {
    body {
        background: #fff;
        color: #000;
    }
    
    .header,
    .sidebar,
    .right-panel,
    .btn,
    .modal-bg,
    .toast-wrap {
        display: none !important;
    }
    
    .content {
        padding: 0;
    }
    
    .card {
        break-inside: avoid;
        border: 1px solid #ccc;
        box-shadow: none;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    html {
        scroll-behavior: auto;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --border: rgba(255, 255, 255, 0.3);
        --border2: rgba(255, 255, 255, 0.5);
    }
    
    .btn {
        border: 2px solid currentColor;
    }
}

/* Dark Mode Specific Adjustments */
[data-theme="dark"] {
    /* Dark mode already defined in index.html */
}

/* Light Mode Specific Adjustments */
[data-theme="light"] {
    .game-thumb {
        background: linear-gradient(135deg, #f0f2f5, #ffffff);
    }
}
