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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #1a73e8, #4285f4);
    color: white;
    border-radius: 10px;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 5px;
}

header p {
    opacity: 0.9;
}

section {
    background: white;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

h2 {
    color: #1a73e8;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

h3 {
    color: #555;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.stat-card {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid #e0e0e0;
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: bold;
    color: #1a73e8;
}

.stat-label {
    color: #666;
    font-size: 0.9rem;
}

/* Parser controls */
.parser-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.parser-form {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.form-row label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 0.9rem;
    color: #555;
}

.form-row input[type="number"] {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    width: 120px;
}

.checkbox-label {
    flex-direction: row !important;
    align-items: center;
}

.checkbox-label input {
    width: auto;
    margin-right: 8px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.btn-primary {
    background: #1a73e8;
    color: white;
}

.btn-primary:hover {
    background: #1557b0;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #545b62;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

/* Progress */
.progress-section {
    background: #e8f0fe;
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
}

.progress-bar-container {
    background: #ddd;
    border-radius: 10px;
    height: 30px;
    position: relative;
    overflow: hidden;
    margin-bottom: 15px;
}

.progress-bar {
    background: linear-gradient(90deg, #1a73e8, #4285f4);
    height: 100%;
    width: 0%;
    transition: width 0.3s;
    border-radius: 10px;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: bold;
    color: #333;
}

.progress-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 5px;
    margin-bottom: 15px;
}

.progress-info p {
    font-size: 0.9rem;
    color: #555;
}

.progress-info span {
    font-weight: bold;
    color: #333;
}

.error-text {
    color: #dc3545 !important;
    grid-column: 1 / -1;
}

.progress-controls {
    display: flex;
    gap: 10px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 5px;
}

.tab-btn {
    padding: 10px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1rem;
    color: #666;
    border-radius: 5px 5px 0 0;
    transition: all 0.2s;
}

.tab-btn:hover {
    background: #f0f0f0;
}

.tab-btn.active {
    background: #1a73e8;
    color: white;
}

.tab-content {
    display: none;
}

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

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th, td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

th {
    background: #f8f9fa;
    font-weight: 600;
    color: #555;
}

tr:hover {
    background: #f8f9fa;
}

/* Pagination */
.pagination {
    display: flex;
    gap: 5px;
    margin-top: 15px;
    justify-content: center;
}

.pagination button {
    padding: 8px 12px;
    border: 1px solid #ddd;
    background: white;
    cursor: pointer;
    border-radius: 4px;
}

.pagination button:hover {
    background: #f0f0f0;
}

.pagination button.active {
    background: #1a73e8;
    color: white;
    border-color: #1a73e8;
}

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

.clickable-row:hover {
    background: #e8f0fe !important;
}

.player-row {
    cursor: help;
}

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

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow-y: auto;
    padding: 20px;
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 30px;
    max-width: 600px;
    width: 100%;
    position: relative;
    margin: 40px 0;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.modal-large {
    max-width: 900px;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
    color: #888;
    line-height: 1;
}

.modal-close:hover {
    color: #333;
}

/* Match detail styles */
.match-date {
    color: #666;
    margin-bottom: 10px;
}

.tournament-path {
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 20px;
}

.match-score-block {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
}

.team-name {
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
    flex: 1;
}

.team-name.clickable {
    cursor: pointer;
    color: #1a73e8;
}

.team-name.clickable:hover {
    text-decoration: underline;
}

.score-big {
    font-size: 2rem;
    font-weight: bold;
    color: #1a73e8;
}

.set-scores {
    text-align: center;
    color: #666;
    margin-bottom: 20px;
}

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

.detail-section {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.detail-section h3 {
    margin-bottom: 10px;
    color: #1a73e8;
}

.rosters-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.roster-section {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.roster-section h3 {
    margin-bottom: 10px;
    color: #1a73e8;
    font-size: 1rem;
}

.roster-list {
    list-style: none;
    max-height: 300px;
    overflow-y: auto;
}

.roster-list li {
    padding: 8px 0;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.roster-list li:last-child {
    border-bottom: none;
}

.player-link {
    cursor: pointer;
    color: #1a73e8;
}

.player-link:hover {
    text-decoration: underline;
}

.player-info {
    font-size: 0.85rem;
    color: #888;
    margin-left: 10px;
}

.player-with-photo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.player-mini-photo {
    width: 32px;
    height: 40px;
    object-fit: cover;
    border-radius: 3px;
    flex-shrink: 0;
}

.player-mini-photo-placeholder {
    width: 32px;
    height: 40px;
    background: #e0e0e0;
    border-radius: 3px;
    flex-shrink: 0;
}

.player-name {
    flex: 1;
}

/* Team detail styles */
.team-site-id {
    color: #888;
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.team-stats {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.stat-item {
    background: #f8f9fa;
    padding: 15px 25px;
    border-radius: 8px;
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 1.8rem;
    font-weight: bold;
    color: #1a73e8;
}

.stat-text {
    font-size: 0.85rem;
    color: #666;
}

.team-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.matches-list {
    list-style: none;
    max-height: 300px;
    overflow-y: auto;
}

.match-link {
    display: flex;
    gap: 10px;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 5px;
    cursor: pointer;
    background: #fff;
    border: 1px solid #e0e0e0;
}

.match-link:hover {
    background: #e8f0fe;
}

.match-link.win {
    border-left: 3px solid #28a745;
}

.match-link.loss {
    border-left: 3px solid #dc3545;
}

.match-link .match-date {
    font-size: 0.85rem;
    color: #888;
    min-width: 80px;
}

.match-link .match-opponent {
    flex: 1;
}

.match-link .match-score {
    font-weight: bold;
}

/* Player tooltip */
.tooltip {
    display: none;
    position: absolute;
    background: #333;
    color: white;
    padding: 0;
    border-radius: 8px;
    z-index: 2000;
    max-width: 300px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

.tooltip.active {
    display: block;
}

.tooltip-header {
    background: #1a73e8;
    padding: 10px 15px;
    border-radius: 8px 8px 0 0;
    font-weight: bold;
}

.tooltip-body {
    padding: 10px 15px;
    display: flex;
    gap: 12px;
}

.tooltip-photo {
    width: 80px;
    height: 100px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.tooltip-info {
    flex: 1;
}

.tooltip-info p {
    margin: 4px 0;
    font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .parser-controls {
        grid-template-columns: 1fr;
    }

    .form-row {
        flex-direction: column;
    }

    .form-row input[type="number"] {
        width: 100%;
    }

    table {
        font-size: 0.8rem;
    }

    th, td {
        padding: 8px;
    }

    .rosters-grid,
    .team-details-grid {
        grid-template-columns: 1fr;
    }

    .match-score-block {
        flex-direction: column;
        gap: 15px;
    }

    .modal-content {
        padding: 20px;
        margin: 20px 0;
    }
}

/* Search Box */
.search-box {
    margin-bottom: 15px;
}

.search-input {
    width: 100%;
    max-width: 400px;
    padding: 10px 15px;
    font-size: 14px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}

.search-input::placeholder {
    color: #999;
}

/* Player Detail Page */
.player-header {
    display: flex;
    gap: 25px;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.player-detail-photo {
    width: 150px;
    height: 180px;
    object-fit: cover;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.player-header-info h2 {
    margin-bottom: 10px;
    color: #333;
}

.player-details {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 15px;
    color: #666;
}

.player-details span {
    background: #f5f5f5;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 14px;
}

.player-teams {
    margin-top: 10px;
}

.team-badge {
    display: inline-block;
    background: #e3f2fd;
    color: #1565c0;
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 13px;
    margin-right: 8px;
    margin-bottom: 5px;
}

.team-badge.clickable {
    cursor: pointer;
    transition: background 0.2s;
}

.team-badge.clickable:hover {
    background: #bbdefb;
}

.player-stats-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 25px;
}

.player-stats-grid .stat-item {
    flex: 1;
    min-width: 100px;
    text-align: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.player-stats-grid .stat-item.highlight {
    background: linear-gradient(135deg, #fff3e0, #ffe0b2);
}

.player-stats-grid .stat-number {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: #1a73e8;
}

.player-stats-grid .stat-item.highlight .stat-number {
    color: #e65100;
}

.player-stats-grid .stat-text {
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
}

.referee-section {
    background: #f0f7ff;
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 25px;
}

.referee-section h3 {
    margin-bottom: 10px;
    color: #1565c0;
}

.referee-stats {
    display: flex;
    gap: 25px;
    flex-wrap: wrap;
}

.referee-stats span {
    color: #555;
}

.referee-stats strong {
    color: #1a73e8;
}

.matches-section h3 {
    margin-bottom: 15px;
    color: #333;
}

.matches-list-full {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
}

.match-row {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 15px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.15s;
}

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

.match-row:hover {
    background: #f5f5f5;
}

.match-row.win {
    border-left: 4px solid #4caf50;
}

.match-row.loss {
    border-left: 4px solid #f44336;
}

.match-row .match-date {
    width: 90px;
    color: #666;
    font-size: 13px;
}

.match-row .match-team {
    width: 150px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.match-row .match-vs {
    width: 25px;
    color: #999;
    text-align: center;
}

.match-row .match-opponent {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.match-row .match-score {
    width: 50px;
    font-weight: 600;
    text-align: center;
}

.match-row .match-sets {
    width: 150px;
    color: #666;
    font-size: 12px;
    text-align: right;
}

/* Player link styling */
.player-link {
    cursor: pointer;
}

.player-link:hover {
    color: #1a73e8;
}
