/* CSS Variables for theming */
:root {
    --primary-color: #1e40af;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --neutral-color: #6b7280;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 0.5rem;
    --max-width: 1200px;
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 1rem;
}

/* Header styles */
header {
    text-align: center;
    padding: 2rem 0;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
}

/* Main content */
main {
    background: var(--bg-primary);
    border-radius: var(--radius);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-lg);
}

/* Balance Card */
.balance-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: var(--radius);
    padding: 2rem;
    margin-bottom: 2rem;
    color: white;
    box-shadow: var(--shadow-md);
    transition: transform 0.3s ease;
}

.balance-card:hover {
    transform: translateY(-2px);
}

.balance-content h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    opacity: 0.95;
}

.balance-display {
    text-align: center;
}

.balance-text {
    font-size: 2.5rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.balance-details {
    font-size: 1rem;
    opacity: 0.9;
}

/* Balance status specific styles */
.balance-card.owing {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.balance-card.owed {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.balance-card.even {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
}

/* Stats Container */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

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

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-primary);
}

.stat-value.win {
    color: var(--success-color);
}

.stat-value.loss {
    color: var(--danger-color);
}

/* History Section */
.history-section {
    margin-top: 2rem;
}

.history-section h2 {
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.history-container {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 1rem;
    border: 1px solid var(--border-color);
}

/* Bet Cards */
.bet-card {
    background: var(--bg-primary);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
    border-left: 4px solid transparent;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 1rem;
    align-items: center;
}

.bet-card:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
}

.bet-card.won {
    border-left-color: var(--success-color);
    background: linear-gradient(to right, rgba(16, 185, 129, 0.05), transparent);
}

.bet-card.lost {
    border-left-color: var(--danger-color);
    background: linear-gradient(to right, rgba(239, 68, 68, 0.05), transparent);
}

.bet-date {
    font-size: 0.875rem;
    color: var(--text-secondary);
    min-width: 100px;
}

.bet-info {
    flex: 1;
}

.bet-description {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

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

.bet-outcome {
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.bet-outcome.won {
    background: var(--success-color);
    color: white;
}

.bet-outcome.lost {
    background: var(--danger-color);
    color: white;
}

/* Instructions Card */
.instructions-card {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-top: 2rem;
    border: 1px solid var(--border-color);
}

.instructions-card h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.instructions-card ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.instructions-card li {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

code {
    background: var(--text-primary);
    color: white;
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    font-family: 'Consolas', 'Monaco', monospace;
}

/* Button styles */
.btn-refresh {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 1rem;
}

.btn-refresh:hover {
    background: #1e3a8a;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: var(--bg-primary);
    margin: 5% auto;
    padding: 2rem;
    border-radius: var(--radius);
    width: 90%;
    max-width: 600px;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close {
    color: var(--text-secondary);
    float: right;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
}

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

.modal-content h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.modal-content pre {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: var(--radius);
    overflow-x: auto;
    border: 1px solid var(--border-color);
}

.modal-content code {
    background: transparent;
    color: var(--text-primary);
    padding: 0;
    font-size: 0.875rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 0;
    color: white;
}

footer a {
    color: white;
    text-decoration: underline;
    opacity: 0.9;
    transition: opacity 0.3s ease;
}

footer a:hover {
    opacity: 1;
}

/* Loading state */
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Error state */
.error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 1rem;
    border-radius: var(--radius);
    margin: 1rem 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }
    
    .balance-text {
        font-size: 2rem;
    }
    
    main {
        padding: 1rem;
    }
    
    .stats-container {
        grid-template-columns: 1fr;
    }
    
    .bet-card {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .bet-date,
    .bet-outcome {
        justify-self: start;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.75rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .balance-text {
        font-size: 1.75rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
}

/* Print styles */
@media print {
    body {
        background: white;
    }
    
    header,
    footer,
    .instructions-card,
    .btn-refresh {
        display: none;
    }
    
    main {
        box-shadow: none;
        padding: 0;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1f2937;
        --bg-secondary: #111827;
        --text-primary: #f9fafb;
        --text-secondary: #9ca3af;
        --border-color: #374151;
    }
    
    body {
        background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    }
    
    code {
        background: #374151;
    }
    
    .error {
        background: #7f1d1d;
        border-color: #991b1b;
        color: #fecaca;
    }
}