/* Competition Tracker - Mobile First CSS */
/* White and Dark Green Theme */

:root {
    --primary: #1a472a;
    --primary-dark: #0f2e1a;
    --primary-light: #2d6a3f;
    --accent: #4caf50;
    --bg: #f8faf8;
    --white: #ffffff;
    --text: #1a1a1a;
    --text-light: #555555;
    --border: #d4e5d7;
    --error: #c0392b;
    --success: #27ae60;
    --shadow: 0 2px 8px rgba(26, 71, 42, 0.12);
    --radius: 10px;
    --radius-sm: 6px;
}

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

html {
    font-size: 16px;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* Header */
header {
    background-color: var(--primary);
    color: var(--white);
    padding: 1rem;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.logo span {
    color: var(--accent);
}

.nav-links {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.nav-links a {
    color: var(--white);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.nav-links a:hover {
    background-color: rgba(255,255,255,0.15);
}

.user-info {
    font-size: 0.8rem;
    opacity: 0.9;
    margin-right: 0.5rem;
}

/* Main Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

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

label .optional {
    font-weight: 400;
    color: var(--text-light);
    font-size: 0.8rem;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="tel"],
select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    background: var(--white);
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

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

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%231a472a' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: transform 0.1s, box-shadow 0.2s, background 0.2s;
    width: 100%;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: translateY(1px);
}

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

.btn-primary:hover {
    background-color: var(--primary-dark);
}

.btn-secondary {
    background-color: var(--white);
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-secondary:hover {
    background-color: var(--primary);
    color: var(--white);
}

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

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

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    width: auto;
}

/* Alerts */
.alert {
    padding: 0.875rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.alert-error {
    background-color: #fdeaea;
    color: var(--error);
    border: 1px solid #f5c6cb;
}

.alert-success {
    background-color: #eafaf1;
    color: var(--success);
    border: 1px solid #c3e6cb;
}

/* Tables */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    min-width: 500px;
}

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background-color: var(--primary);
    color: var(--white);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

tbody tr:hover {
    background-color: #f0f5f1;
}

.score-cell {
    font-weight: 700;
    color: var(--primary);
    font-size: 1.05rem;
}

.rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.8rem;
    background: var(--primary);
    color: var(--white);
}

.rank-1 { background: #f1c40f; color: #333; }
.rank-2 { background: #bdc3c7; color: #333; }
.rank-3 { background: #cd7f32; color: #fff; }

/* Competition Cards Grid */
.competitions-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.competition-card {
    background: var(--white);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}

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

.competition-card h3 {
    color: var(--primary);
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.competition-card .meta {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* Login page specific */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

.login-card {
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.login-card .logo-icon {
    width: 64px;
    height: 64px;
    background: var(--primary);
    border-radius: var(--radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.login-card .logo-icon svg {
    width: 32px;
    height: 32px;
    fill: var(--white);
}

.login-card h1 {
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.login-card .subtitle {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

/* Section divider */
.section-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1.5rem 0 1rem;
    color: var(--text-light);
    font-size: 0.875rem;
    font-weight: 600;
}

.section-divider::before,
.section-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-light);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    fill: var(--border);
    margin-bottom: 0.75rem;
}

/* Tab Navigation */
.tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--border);
    overflow-x: auto;
}

.tab-btn {
    padding: 0.75rem 1rem;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-light);
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-panel {
    display: none;
}

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

/* Player list item for mobile-friendly display */
.player-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.player-item {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.player-item .player-rank {
    flex-shrink: 0;
}

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

.player-item .player-name {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.125rem;
}

.player-item .player-meta {
    font-size: 0.8rem;
    color: var(--text-light);
}

.player-item .player-score {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    flex-shrink: 0;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1rem;
}

.modal-overlay.active {
    display: flex;
}

.modal-card {
    background: var(--white);
    border-radius: var(--radius);
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    animation: modal-in 0.2s ease-out;
}

@keyframes modal-in {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    background: var(--primary);
    color: var(--white);
    padding: 1rem 1.25rem;
    border-radius: var(--radius) var(--radius) 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.25rem;
}

.modal-body {
    padding: 1.25rem;
}

.modal-row {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
}

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

.modal-label {
    color: var(--text-light);
    font-weight: 500;
}

.modal-value {
    color: var(--text);
    font-weight: 600;
    text-align: right;
    word-break: break-word;
    max-width: 60%;
}

/* Clickable player row */
.player-row {
    cursor: pointer;
}

.player-row:hover {
    background-color: #eaf1ec !important;
}

/* Desktop adjustments */
@media (min-width: 768px) {
    .container {
        padding: 2rem;
    }

    .card {
        padding: 2rem;
    }

    .btn {
        width: auto;
    }

    .competitions-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }
}

@media (min-width: 1024px) {
    .competitions-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
