/* ============================================
   Bad Games - Pages CSS
   Home, Auth, Profile, Lobby, Leaderboard, Friends
   ============================================ */

/* ===========================================
   Home Page
   =========================================== */
.view-home {
    text-align: center;
}

.hero {
    padding: 60px 20px;
    max-width: 600px;
    margin: 0 auto;
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.hero-actions {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.games-showcase {
    padding: 48px 0;
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-top: 24px;
}

.game-card {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    padding: 32px;
    text-align: left;
}

.game-card-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.game-card h3 {
    margin-bottom: 8px;
}

.game-card p {
    color: var(--text-secondary);
}

.game-features {
    list-style: none;
    margin-top: 16px;
}

.game-features li {
    padding: 6px 0;
    padding-left: 24px;
    position: relative;
    color: var(--text-secondary);
}

.game-features li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--success);
}

.features {
    padding: 48px 0;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
    margin-top: 24px;
}

.feature-item {
    text-align: center;
    padding: 24px;
}

.feature-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 12px;
}

.feature-item h4 {
    margin-bottom: 8px;
}

.feature-item p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ===========================================
   Auth Pages
   =========================================== */
.view-auth {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 200px);
}

/* ===========================================
   Profile Page
   =========================================== */
.view-profile {
    max-width: 800px;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
    padding: 20px;
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
}

.profile-avatar {
    width: 64px;
    height: 64px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.profile-avatar-img {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.profile-info h1 {
    margin-bottom: 2px;
    font-size: 1.5rem;
}

.profile-email,
.profile-joined {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-bottom: 0;
}

.profile-sections {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.profile-section {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    padding: 20px;
}

.profile-section h2 {
    margin-bottom: 12px;
    font-size: 1.125rem;
}

.section-description {
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-size: 0.875rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.stat-card {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 16px;
}

.stat-card h4 {
    margin-bottom: 12px;
    text-transform: capitalize;
    font-size: 1rem;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-label {
    color: var(--text-secondary);
}

.stat-win { color: var(--success); }
.stat-loss { color: var(--error); }
.stat-rating { color: var(--accent); font-weight: 600; }

/* Invites */
.generate-invite-form {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.invite-counter {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.invite-limit-reached {
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 16px;
    font-size: 0.875rem;
}

.invites-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.invite-card {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 16px;
}

.invite-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.invite-code-display {
    display: flex;
    align-items: center;
    gap: 12px;
}

.invite-code {
    font-family: 'Courier New', monospace;
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--accent);
}

.status-available {
    color: var(--success);
    font-size: 0.875rem;
}

.status-used {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.status-used strong {
    color: var(--accent);
}

.invite-card.used {
    opacity: 0.7;
    background: var(--bg-secondary);
}

.invite-qr {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.qr-code canvas {
    border-radius: var(--border-radius);
}

.invite-link {
    width: 100%;
}

.invite-link input {
    text-align: center;
    font-size: 0.875rem;
}

/* Nickname Form */
.nickname-form {
    max-width: 400px;
}

.nickname-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
}

.nickname-input-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.nickname-input-row input {
    flex: 1;
    min-width: 0;
}

.nickname-input-row .btn {
    flex-shrink: 0;
}

/* Game History */
.games-history {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
}

.history-info {
    display: flex;
    align-items: center;
}

.history-type {
    font-weight: 500;
    text-transform: capitalize;
}

.history-date {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-left: 12px;
}

.history-result {
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.875rem;
}

.history-result.win {
    background: rgba(74, 222, 128, 0.2);
    color: var(--success);
}

.history-result.loss {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
}

.history-result.draw {
    background: rgba(251, 191, 36, 0.2);
    color: var(--warning);
}

/* ===========================================
   Lobby Page
   =========================================== */
.view-lobby {
    max-width: 800px;
}

.lobby-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.lobby-header h1 {
    font-size: 1.5rem;
    margin: 0;
}

.game-type-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.game-type-btn {
    padding: 8px 16px;
    font-size: 0.875rem;
    background: var(--bg-card);
    border: none;
    border-radius: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.game-type-btn:hover {
    color: var(--text-primary);
}

.game-type-btn.active {
    background: var(--accent);
    color: white;
}

.games-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.game-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--bg-card);
    border-radius: var(--border-radius);
}

.game-item-info h4 {
    margin-bottom: 2px;
    font-size: 1rem;
}

.game-item-info p {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin: 0;
}

.game-item-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}

.player-count {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* In Progress Sessions */
.in-progress-section {
    margin-bottom: 32px;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.section-header h2 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0;
}

.session-count {
    background: var(--accent);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}

.in-progress-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

/* Session Tiles */
.session-tile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-card);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
}

.session-tile:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}

.tile-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--text-muted);
}

.session-tile.active .tile-status-dot {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.session-tile.waiting .tile-status-dot {
    background: var(--warning);
}

.tile-info {
    flex: 1;
    min-width: 0;
}

.tile-opponent {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.tile-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.tile-close {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0.5;
    transition: all 0.15s ease;
}

.session-tile:hover .tile-close {
    opacity: 1;
}

.tile-close:hover {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
}

.section-title {
    font-size: 1rem;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

/* Friend Games Section */
.friend-games-section {
    margin-bottom: 24px;
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    padding: 16px 20px;
}

.friend-games-section h2 {
    margin-bottom: 12px;
    font-size: 1rem;
}

.friend-games-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}

.friend-game-card {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 14px 16px;
    border: 1px solid var(--border-color);
}

.friend-game-card:hover {
    border-color: var(--accent);
}

.friend-game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.friend-game-type {
    font-weight: 600;
    font-size: 0.9rem;
}

.friend-game-host {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.friend-game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.friend-game-players {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Game Creation Modal */
.visibility-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}

.visibility-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 8px;
    cursor: pointer;
}

.visibility-option:hover {
    background: var(--bg-card);
}

.visibility-option input[type="radio"] {
    width: auto;
    margin: 0;
}

.visibility-option label {
    cursor: pointer;
    flex: 1;
}

.friends-select {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.friends-select h4 {
    margin-bottom: 12px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.friends-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.friend-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
}

.friend-checkbox input[type="checkbox"] {
    width: auto;
    margin: 0;
}

/* ===========================================
   Leaderboard Page
   =========================================== */
.leaderboard-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

.tab-btn {
    padding: 10px 24px;
    background: var(--bg-card);
    border: none;
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--accent);
    color: white;
}

.leaderboard-table table {
    width: 100%;
    border-collapse: collapse;
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 14px 16px;
    text-align: left;
}

.leaderboard-table th {
    background: var(--bg-card);
    color: var(--text-secondary);
    font-weight: 500;
}

.leaderboard-table tr:nth-child(even) {
    background: var(--bg-secondary);
}

.leaderboard-table .rank {
    width: 60px;
    font-weight: 600;
    color: var(--accent);
}

.leaderboard-table .rating {
    font-weight: 600;
}

/* ===========================================
   Friends Page
   =========================================== */
.view-friends {
    max-width: 800px;
}

.view-friends h1 {
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.friends-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.friends-grid .card {
    padding: 20px;
}

.friends-grid .card h3 {
    margin-bottom: 12px;
    font-size: 1rem;
}

.add-friend-form .form-row {
    display: flex;
    gap: 10px;
}

.add-friend-form input {
    flex: 1;
    padding: 10px 14px;
}

.requests-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.request-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.request-from, .request-to {
    font-weight: 500;
    font-size: 0.9rem;
}

.request-actions {
    display: flex;
    gap: 6px;
}

.request-status {
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 10px;
    background: var(--bg-card);
}

.request-status.pending {
    color: var(--warning);
}

.friends-list-card {
    padding: 20px;
}

.friends-list-card h3 {
    margin-bottom: 12px;
    font-size: 1rem;
}

.friends-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
}

.friend-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.friend-nickname {
    font-weight: 500;
    font-size: 1rem;
}

.friend-actions form {
    margin: 0;
}

/* Page Header */
.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    margin-bottom: 0.25rem;
}

.page-header .text-muted {
    color: var(--text-secondary);
    margin: 0;
}

/* ===========================================
   Responsive
   =========================================== */
@media (max-width: 768px) {
    .hero h1 {
        font-size: 2rem;
    }

    .hero-subtitle {
        font-size: 1rem;
    }

    .profile-header {
        flex-direction: column;
        text-align: center;
    }

    .game-item {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }

    .game-item-meta {
        width: 100%;
        justify-content: center;
    }

    .invite-main {
        flex-direction: column;
        text-align: center;
    }

    .leaderboard-table {
        overflow-x: auto;
    }
}

@media (max-width: 640px) {
    .in-progress-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .add-friend-form .form-row {
        flex-direction: column;
    }

    .request-item {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .hero {
        padding: 40px 16px;
    }

    .hero-actions {
        flex-direction: column;
    }

    .hero-actions .btn {
        width: 100%;
    }

    .view {
        padding: 16px;
    }
}
