/* ==================== Variables ==================== */
:root {
    --primary: #2196F3;
    --primary-dark: #1976D2;
    --success: #4CAF50;
    --warning: #FF9800;
    --danger: #F44336;
    --bg: #F5F5F5;
    --card-bg: #FFFFFF;
    --text: #212121;
    --text-secondary: #757575;
    --border: #E0E0E0;
    --shadow: rgba(0, 0, 0, 0.1);
    --radius-sm: 10px;
    --radius-md: 12px;
    --radius-lg: 14px;
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.12);
    --focus-ring: 0 0 0 3px rgba(33, 150, 243, 0.22);
    --padding-md: 1rem;
}

/* ==================== Reset ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Vazirmatn', sans-serif;
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button, input, textarea {
    font-family: inherit;
}

button {
    -webkit-tap-highlight-color: transparent;
}

/* ==================== Loading ==================== */
.loading {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    z-index: 9999;
}

.spinner {
    font-size: 4rem;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==================== Header ==================== */
.header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.user-name {
    font-size: 1.1rem;
    font-weight: 600;
}

.user-level {
    font-size: 0.85rem;
    opacity: 0.9;
}

.user-stats {
    display: flex;
    gap: 1rem;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 1rem;
    font-weight: 600;
}

.stat-item .icon {
    font-size: 1.2rem;
}

/* ==================== Navigation ==================== */
.nav {
    display: flex;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
}

.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s;
}

.nav-btn .icon {
    font-size: 1.5rem;
}

.nav-btn span:last-child {
    font-size: 0.75rem;
}

.nav-btn.active {
    color: var(--primary);
    background: rgba(33, 150, 243, 0.1);
}

/* ==================== Main ==================== */
.main {
    padding: 1rem;
    padding-bottom: 5rem;
    min-height: calc(100vh - 80px);
}

.page {
    display: none;
    animation: fadeIn 0.3s;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.page-header h2 {
    font-size: 1.5rem;
    color: var(--text);
}

/* ==================== Cards ==================== */
.match-card, .prediction-card, .marketplace-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s;
}

.match-card, .prediction-card, .marketplace-card {
    border: 1px solid rgba(224, 224, 224, 0.7);
}

.match-card:active {
    transform: scale(0.98);
}

.match-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.league-name {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.match-time {
    font-size: 0.85rem;
    color: var(--primary);
    font-weight: 600;
}

.match-teams {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 1rem 0;
}

.team {
    flex: 1;
    text-align: center;
}

.team-name {
    font-weight: 600;
    margin-top: 0.5rem;
}

.team-logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.vs {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-secondary);
    padding: 0 1rem;
}

.match-actions {
    display: flex;
    gap: 0.5rem;
}

 .match-actions .btn {
    flex: 1;
}

.filters {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: var(--padding-md);
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.filters-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
 .filters-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    font-weight: 600;
    color: var(--text-secondary);
 }

 .filters-check input {
    width: 18px;
    height: 18px;
 }

 .match-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
 }

 .status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
 }

 .status-not-started {
    background: rgba(33, 150, 243, 0.12);
    color: var(--primary);
 }

 .status-live {
    background: rgba(244, 67, 54, 0.12);
    color: var(--danger);
 }

 .status-finished {
    background: rgba(76, 175, 80, 0.12);
    color: var(--success);
 }

 .status-paused {
    background: rgba(255, 152, 0, 0.12);
    color: var(--warning);
 }

/* ==================== Buttons ==================== */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--text-secondary);
    color: white;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==================== Daily Limit ==================== */
.daily-limit {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ==================== Tabs ==================== */
.tabs {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    border-bottom: none;
    background: rgba(33, 150, 243, 0.06);
    padding: 0.5rem;
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
}

.tab-btn {
    flex: 1;
    padding: 0.7rem 0.75rem;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.82);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 12px;
}

.tab-btn.active {
    color: var(--primary);
    background: rgba(33, 150, 243, 0.14);
    border-color: rgba(33, 150, 243, 0.3);
    box-shadow: 0 8px 18px rgba(33, 150, 243, 0.12);
}

.muted {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.empty-state .muted {
    margin-top: 0.5rem;
    line-height: 1.6;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* ==================== Marketplace polish ==================== */
.marketplace-card {
    padding: 0.9rem;
}

.card-top {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.card-meta {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.card-league {
    font-weight: 800;
    font-size: 0.95rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-date {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.card-price {
    text-align: left;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
    flex: 0 0 auto;
}

.card-price .price {
    font-weight: 900;
    color: var(--primary);
}

.card-price .sub {
    font-size: 0.85rem;
}

.card-match {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 0.5rem;
    align-items: center;
    padding: 0.65rem;
    border: 1px solid rgba(224, 224, 224, 0.7);
    border-radius: 12px;
    background: var(--bg);
    margin-bottom: 0.75rem;
}

.card-match .team-name {
    font-weight: 800;
    font-size: 0.95rem;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.card-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.card-info .row {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    font-size: 0.85rem;
}

.card-info .k {
    color: var(--text-secondary);
    font-weight: 700;
    white-space: nowrap;
}

.card-info .v {
    color: var(--text);
    font-weight: 800;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
    border: 1px solid rgba(224, 224, 224, 0.9);
    background: rgba(255, 255, 255, 0.7);
    color: var(--text-secondary);
}

.pill-success {
    border-color: rgba(76, 175, 80, 0.35);
    background: rgba(76, 175, 80, 0.12);
    color: var(--success);
}

.pill-warning {
    border-color: rgba(255, 152, 0, 0.35);
    background: rgba(255, 152, 0, 0.12);
    color: var(--warning);
}

.pill-danger {
    border-color: rgba(244, 67, 54, 0.35);
    background: rgba(244, 67, 54, 0.12);
    color: var(--danger);
}

/* ==================== Profile ==================== */
.profile-card {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    margin-bottom: 1.5rem;
}

.profile-avatar {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.profile-name {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.profile-level {
    font-size: 1rem;
    opacity: 0.9;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.stat-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    box-shadow: 0 2px 8px var(--shadow);
}

.stat-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

 .settings-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1rem;
    margin-top: 1.25rem;
    box-shadow: 0 2px 8px var(--shadow);
 }

 .settings-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
 }

 .settings-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
 }

 .settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
 }

 .settings-row .label {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
 }

 .settings-row .label .title {
    font-weight: 700;
    color: var(--text);
 }

 .settings-row .label .desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
 }

 .switch {
    position: relative;
    width: 46px;
    height: 28px;
    flex: 0 0 46px;
 }

 .switch input {
    opacity: 0;
    width: 0;
    height: 0;
 }

 .slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #cfd8dc;
    border-radius: 999px;
    transition: all 0.25s;
 }

 .slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    top: 3px;
    background: white;
    border-radius: 50%;
    transition: all 0.25s;
 }

 .switch input:checked + .slider {
    background: var(--primary);
 }

 .switch input:checked + .slider:before {
    transform: translateX(-18px);
 }

/* ==================== Modal ==================== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s;
}

@keyframes slideUp {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1.25rem;
}

.modal-close {
    font-size: 2rem;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
}

.modal-body {
    padding: 1rem;
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    border-top: 1px solid var(--border);
}

/* ==================== Score Input ==================== */
.score-input {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1rem;
}

.score-team {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.score-team label {
    font-weight: 600;
    color: var(--text-secondary);
}

.score-team input {
    width: 80px;
    height: 80px;
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
}

.form-control:focus {
    box-shadow: var(--focus-ring);
}

.score-team input:focus {
    outline: none;
    border-color: var(--primary);
}

/* ==================== Form ==================== */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    background: var(--bg);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

/* ==================== Toast ==================== */
.toast {
    position: fixed;
    bottom: 6rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--shadow);
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s;
    max-width: 90%;
    text-align: center;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

/* ==================== Busy Overlay ==================== */
.busy {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.busy-card {
    width: 100%;
    max-width: 320px;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1rem;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}

.busy-spinner {
    font-size: 1.8rem;
    animation: spin 1s linear infinite;
}

.busy-text {
    font-weight: 700;
    color: var(--text);
}

/* ==================== Badges ==================== */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

.badge-success {
    background: rgba(76, 175, 80, 0.2);
    color: var(--success);
}

.badge-warning {
    background: rgba(255, 152, 0, 0.2);
    color: var(--warning);
}

.badge-danger {
    background: rgba(244, 67, 54, 0.2);
    color: var(--danger);
}

/* ==================== Empty State ==================== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-state .icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    font-size: 1.1rem;
}

/* ==================== Responsive ==================== */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .score-team input {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }
}
