@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@300;500;700&family=Inter:wght@300;400;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #00a86b;
    --primary-dark: #008556;
    --accent: #ffd700;
    --accent-dark: #e6c200;
    --bg: #0a0e27;
    --bg-card: #151932;
    --bg-card-hover: #1a1f3a;
    --text: #e8ecf5;
    --text-dim: #9ca3af;
    --border: #252a41;
    --win: #22c55e;
    --loss: #ef4444;
    --win-bg: rgba(34, 197, 94, 0.1);
    --loss-bg: rgba(239, 68, 68, 0.1);
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    background-image:
        radial-gradient(circle at 10% 20%, rgba(0, 168, 107, 0.1) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(255, 215, 0, 0.05) 0%, transparent 20%);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
}

header {
    text-align: center;
    padding: 2rem 1rem;
    margin-bottom: 2rem;
}

h1 {
    font-family: 'Rajdhani', sans-serif;
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
    letter-spacing: 0.02em;
}

.subtitle {
    color: var(--text-dim);
    font-size: 0.95rem;
    letter-spacing: 0.05em;
}

/* ============================================
   API STATUS
   ============================================ */

.api-status {
    position: fixed;
    top: 1rem;
    right: 1rem;
    background: var(--bg-card);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--border);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 1000;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--win);
    animation: pulse 2s infinite;
}

.status-dot.error {
    background: var(--loss);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ============================================
   TABS
   ============================================ */

.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    overflow-x: auto;
    padding: 0.5rem;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.tab {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.3s;
    white-space: nowrap;
    font-family: 'Rajdhani', sans-serif;
    letter-spacing: 0.03em;
}

.tab:hover {
    background: var(--bg-card-hover);
    color: var(--text);
}

.tab.active {
    background: var(--primary);
    color: white;
    font-weight: 600;
}

.tab-content {
    display: none;
    animation: fadeIn 0.4s ease-in;
}

.tab-content.active {
    display: block;
}

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

/* ============================================
   CARDS
   ============================================ */

.card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
    transition: all 0.3s;
}

.card:hover {
    border-color: var(--primary);
    box-shadow: 0 0 20px rgba(0, 168, 107, 0.1);
}

.card-title {
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text);
}

/* ============================================
   STATS
   ============================================ */

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

.stat-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    text-align: center;
    transition: all 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
    box-shadow: 0 10px 30px rgba(0, 168, 107, 0.15);
}

.stat-value {
    font-family: 'Rajdhani', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    color: var(--text-dim);
    font-size: 0.9rem;
    margin-top: 0.5rem;
    font-weight: 500;
}

/* ============================================
   FORMS
   ============================================ */

.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text);
    font-weight: 600;
    font-size: 0.95rem;
}

input, select, textarea {
    width: 100%;
    padding: 0.875rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
    transition: all 0.3s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 168, 107, 0.1);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.score-input {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
}

.score-input input {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    font-family: 'Rajdhani', sans-serif;
}

.vs {
    color: var(--text-dim);
    font-weight: 700;
    font-size: 1.2rem;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    padding: 0.875rem 2rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s;
    font-family: 'Rajdhani', sans-serif;
    letter-spacing: 0.03em;
}

.btn:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0, 168, 107, 0.3);
}

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

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

.btn-secondary {
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.btn-danger {
    background: var(--loss);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

.btn-edit {
    background: var(--accent);
    color: #000;
}

.btn-edit:hover:not(:disabled) {
    background: var(--accent-dark);
}

/* ============================================
   OPPONENT HISTORY
   ============================================ */

.opponent-history {
    background: var(--bg);
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
    border: 1px solid var(--border);
}

.opponent-history.found {
    border-color: var(--accent);
    background: rgba(255, 215, 0, 0.05);
}

.history-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.win-loss {
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
}

.win {
    color: var(--win);
}

.loss {
    color: var(--loss);
}

/* ============================================
   MATCH LIST
   ============================================ */

.match-list {
    list-style: none;
}

.match-item {
    background: var(--bg-card);
    padding: 1rem;
    margin-bottom: 0.75rem;
    border-radius: 8px;
    border-left: 4px solid var(--border);
    transition: all 0.3s;
    cursor: pointer;
}

.match-item:hover {
    transform: translateX(5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.match-item.win {
    border-left-color: var(--win);
    background: var(--win-bg);
}

.match-item.loss {
    border-left-color: var(--loss);
    background: var(--loss-bg);
}

.match-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.match-opponent {
    font-weight: 700;
    font-size: 1.1rem;
    font-family: 'Rajdhani', sans-serif;
}

.match-date {
    color: var(--text-dim);
    font-size: 0.85rem;
}

.match-score {
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.match-tournament {
    color: var(--text-dim);
    font-size: 0.9rem;
}

.match-partners {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-top: 0.25rem;
}

/* ============================================
   MATCH TYPE BADGES
   ============================================ */

.match-mixed-badge {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: 0.5rem;
    text-transform: uppercase;
}

.match-singles-badge {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: 0.5rem;
    text-transform: uppercase;
}

/* ============================================
   MATCH TYPE SELECTOR
   ============================================ */

.match-type-selector {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
}

.radio-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    background: var(--bg-card-hover);
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.radio-option input[type="radio"] {
    margin-right: 0.5rem;
    cursor: pointer;
}

.radio-option:hover {
    border-color: var(--primary);
}

.radio-option input[type="radio"]:checked + span {
    color: var(--primary);
    font-weight: 600;
}

.radio-option input[type="radio"]:checked {
    accent-color: var(--primary);
}

/* ============================================
   OPPONENT CARDS
   ============================================ */

.opponent-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 1rem;
    transition: all 0.3s;
    cursor: pointer;
}

.opponent-card:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(0, 168, 107, 0.15);
}

.opponent-name {
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.opponent-stats {
    display: flex;
    gap: 2rem;
    margin-top: 0.75rem;
}

.opponent-stat {
    display: flex;
    flex-direction: column;
}

.opponent-stat-value {
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
}

.opponent-stat-label {
    color: var(--text-dim);
    font-size: 0.85rem;
}

/* ============================================
   OPPONENTS FILTER
   ============================================ */

.opponents-filter {
    margin-bottom: 1.5rem;
}

.opponents-filter input {
    margin-bottom: 0.75rem;
}

.opponents-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.opponents-chips:empty {
    display: none;
}

.opponent-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--primary);
    color: white;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: 'Rajdhani', sans-serif;
    letter-spacing: 0.02em;
    animation: fadeIn 0.2s ease-in;
}

.opponent-chip-remove {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0;
    line-height: 1;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.opponent-chip-remove:hover {
    color: white;
    background: rgba(255, 255, 255, 0.2);
}

.opponents-chips-toggle {
    display: inline-flex;
    align-items: center;
    background: var(--bg);
    color: var(--text-dim);
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.opponents-chips-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.opponents-chips-toggle.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.opponents-chips-clear {
    display: inline-flex;
    align-items: center;
    background: var(--bg);
    color: var(--text-dim);
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.opponents-chips-clear:hover {
    border-color: var(--loss);
    color: var(--loss);
}

.opponent-card-pin {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-dim);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.2s;
    flex-shrink: 0;
}

.opponent-card-pin:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.opponent-card-pin.pinned {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.opponent-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ============================================
   QUICK STATS
   ============================================ */

.quick-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.quick-stat {
    background: var(--bg);
    padding: 0.75rem;
    border-radius: 6px;
    text-align: center;
}

.quick-stat-value {
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.quick-stat-label {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-top: 0.25rem;
}

/* ============================================
   OTHER UI ELEMENTS
   ============================================ */

.add-set-btn {
    margin-top: 0.5rem;
}

.notes-preview {
    color: var(--text-dim);
    font-size: 0.9rem;
    font-style: italic;
    margin-top: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-dim);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.filter-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.filter-bar select {
    flex: 1;
    min-width: 200px;
}

.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-dim);
}

.loading::after {
    content: '...';
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

.error-message {
    background: var(--loss-bg);
    color: var(--loss);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border: 1px solid var(--loss);
}

.api-config {
    background: var(--bg);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}

/* ============================================
   MODAL
   ============================================ */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 2rem;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--border);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-title {
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s;
}

.modal-close:hover {
    background: var(--bg);
    color: var(--text);
}

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

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

@media (max-width: 768px) {
    .container {
        padding: 0.5rem;
    }

    h1 {
        font-size: 2.5rem;
    }

    .tabs {
        overflow-x: auto;
    }

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

    .opponent-stats {
        flex-direction: column;
        gap: 0.5rem;
    }

    .filter-bar {
        flex-direction: column;
    }

    .filter-bar select {
        width: 100%;
    }
}
