/*
Theme Name: Badminton Scoring System
Description: A custom theme for recording badminton game scores and calculating player rankings
Version: 1.0
Author: Badminton Meetup
*/

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header styles */
.site-header {
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
    color: white;
    padding: 20px 0;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.site-title {
    text-align: center;
    font-size: 2.5rem;
    font-weight: bold;
    margin-bottom: 10px;
}

.site-description {
    text-align: center;
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Organizer Menu Section */
.organizer-menu-section {
    text-align: center;
    margin: 20px 0;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.organizer-menu-section .btn {
    font-size: 16px;
    padding: 12px 24px;
    font-weight: 600;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.organizer-menu-section .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Main Navigation - Updated for toggle functionality */
.main-navigation {
    background: white;
    padding: 15px 0;
    margin: 20px 0;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.nav-menu {
    display: flex;
    justify-content: center;
    list-style: none;
    gap: 30px;
}

.nav-menu a {
    text-decoration: none;
    color: #333;
    font-weight: 500;
    padding: 10px 20px;
    border-radius: 25px;
    transition: all 0.3s ease;
}

.nav-menu a:hover,
.nav-menu a.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

/* Court management styles */
.court-management {
    background: white;
    border-radius: 10px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.section-title {
    font-size: 1.8rem;
    margin-bottom: 20px;
    color: #333;
    border-bottom: 3px solid #667eea;
    padding-bottom: 10px;
}

.court-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    flex-wrap: wrap;
    align-items: center;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, #51cf66 0%, #40c057 100%);
    color: white;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(81, 207, 102, 0.4);
}

.btn-warning {
    background: linear-gradient(135deg, #ffc107 0%, #e0a800 100%);
    color: white;
}

.btn-warning:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 193, 7, 0.4);
}

.input-group {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.form-control {
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    min-width: 200px;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Spreadsheet-style scoring interface */
.scoring-interface {
    background: white;
    border-radius: 10px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.court-section {
    margin-bottom: 40px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.court-header {
    padding: 15px 20px;
    font-size: 1.4rem;
    font-weight: bold;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.court-6 {
    background: #6c757d;
}

.court-5 {
    background: #6c757d;
}

.court-4 {
    background: #6c757d;
}

.court-3 {
    background: #6c757d;
}

.court-2 {
    background: #6c757d;
}

.court-1 {
    background: #6c757d;
}

.court-actions {
    display: flex;
    gap: 10px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: 15px;
}

.games-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    padding: 20px;
    background: #f8f9fa;
}

.games-block {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.games-title {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 15px;
    color: #333;
    text-align: center;
    padding-bottom: 10px;
    border-bottom: 2px solid #e9ecef;
}

/* Spreadsheet table styles */
.scoring-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.scoring-table th,
.scoring-table td {
    padding: 8px 6px;
    text-align: center;
    border: 1px solid #dee2e6;
    vertical-align: middle;
}

.scoring-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #495057;
    font-size: 0.8rem;
}

.scoring-table td {
    background: white;
}

.scoring-table tr:nth-child(even) td {
    background: #f8f9fa;
}

.scoring-table tr:hover td {
    background: #e3f2fd;
}

/* Score input cells */
.score-input {
    width: 50px;
    padding: 4px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    text-align: center;
    font-size: 0.8rem;
}

.score-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.score-input:invalid {
    border-color: #dc3545;
    background: #fff5f5;
}

/* Player name cells */
.player-name {
    font-weight: 500;
    color: #333;
    text-align: left;
    padding-left: 10px !important;
}

/* Winning rate and point difference cells */
.winning-rate-cell {
    font-weight: bold;
    color: #28a745;
    background: #f0fff4 !important;
}

.point-difference-cell {
    font-weight: bold;
    background: #f8f9fa !important;
}

.positive-diff {
    color: #28a745;
    font-weight: bold;
    background: #f0fff4 !important;
}

.negative-diff {
    color: #dc3545;
    font-weight: bold;
    background: #fff5f5 !important;
}

.neutral-diff {
    color: #6c757d;
    font-weight: bold;
    background: #f8f9fa !important;
}

.error-cell {
    color: #dc3545;
    font-style: italic;
    background: #fff5f5 !important;
}

/* Historical records section */
.historical-section {
    background: white;
    border-radius: 10px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.historical-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.historical-table th,
.historical-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

.historical-table th {
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
    color: white;
    font-weight: 600;
}

.historical-table tr:nth-child(even) {
    background: #f8f9fa;
}

.historical-table tr:hover {
    background: #e3f2fd;
}

/* Modal styles */
.modal {
    display: block;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 90%;
    max-width: 1400px;
    max-height: 85vh;
    overflow-y: auto;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    position: relative;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    top: 10px;
    right: 20px;
}

.close:hover,
.close:focus {
    color: #000;
    text-decoration: none;
}

.session-details h3 {
    margin-bottom: 20px;
    color: #333;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

.court-details {
    margin-bottom: 30px;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
}

.court-details h4 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.historical-games-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.historical-games-block {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
}

.historical-games-block h5 {
    color: #495057;
    margin-bottom: 10px;
    font-size: 1.1rem;
    text-align: center;
    border-bottom: 2px solid #dee2e6;
    padding-bottom: 5px;
}

.details-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.details-table th,
.details-table td {
    padding: 10px;
    text-align: center;
    border: 1px solid #dee2e6;
}

.details-table th {
    background: #e9ecef;
    font-weight: 600;
    color: #495057;
}

.details-table tr:nth-child(even) {
    background: white;
}

.details-table tr:hover {
    background: #f0f4ff;
}

/* Add player form */
.add-player-form {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.add-player-form .form-control {
    flex: 1;
    min-width: 150px;
    padding: 8px 12px;
    font-size: 0.9rem;
}

/* Player management */
.players-section {
    margin-top: 20px;
}

.players-title {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: #555;
    font-weight: 600;
}

.players-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

.player-item {
    background: #e9ecef;
    padding: 8px 12px;
    border-radius: 15px;
    border: 2px solid #dee2e6;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.player-item:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.player-name {
    font-weight: 500;
    color: #333;
}

.remove-player {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.remove-player:hover {
    background: #c82333;
    transform: scale(1.1);
}

/* Rankings section */
.rankings-section {
    background: white;
    border-radius: 10px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.rankings-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.rankings-table th,
.rankings-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

.rankings-table th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
}

.rankings-table tr:nth-child(even) {
    background: #f8f9fa;
}

.rankings-table tr:hover {
    background: #f0f4ff;
}

.rank-number {
    font-weight: bold;
    color: #667eea;
    font-size: 1.1rem;
}

.top-rank {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%) !important;
}

.rankings-table td[contenteditable="true"] {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    padding: 8px;
    cursor: text;
    transition: background-color 0.2s ease;
}

.rankings-table td[contenteditable="true"]:hover {
    background-color: #e9ecef;
}

.rankings-table td[contenteditable="true"]:focus {
    background-color: #fff;
    border: 2px solid #007bff;
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.rankings-table .player-name-cell {
    font-weight: bold;
    background-color: #f8f9fa;
}

.rankings-table .rank-number {
    font-weight: bold;
    text-align: center;
    background-color: #e9ecef;
}

/* Responsive design */
@media (max-width: 1200px) {
    .games-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .site-title {
        font-size: 2rem;
    }
    
    .nav-menu {
        flex-direction: column;
        gap: 10px;
    }
    
    .court-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .input-group {
        flex-direction: column;
        align-items: stretch;
    }
    
    .scoring-table {
        font-size: 0.8rem;
    }
    
    .score-input {
        width: 40px;
        font-size: 0.7rem;
    }
    
    .players-list {
        flex-direction: column;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 20px;
    }
    
    .actions-cell .btn {
        padding: 3px 6px;
        font-size: 0.6rem;
        min-width: 50px;
    }
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin-right: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Success/Error messages */
.message {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 500;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.message.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Keyboard shortcuts help */
.keyboard-shortcuts {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    font-size: 12px;
    z-index: 1000;
    max-width: 200px;
}

.keyboard-shortcuts h4 {
    margin: 0 0 10px 0;
    color: #333;
}

.keyboard-shortcuts ul {
    margin: 0;
    padding-left: 20px;
}

.keyboard-shortcuts li {
    margin-bottom: 5px;
} 

/* End Games Section */
.end-games-section {
    background: white;
    border-radius: 10px;
    padding: 30px;
    margin: 30px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    text-align: center;
}

.end-games-container {
    max-width: 600px;
    margin: 0 auto;
}

.end-games-container .btn {
    padding: 15px 30px;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 15px;
}

.end-games-note {
    color: #6c757d;
    font-size: 0.9rem;
    margin: 0;
    font-style: italic;
}

.btn-lg {
    padding: 15px 30px;
    font-size: 1.1rem;
    font-weight: 600;
} 

/* Auto-sync Status Display */
.sync-status-container {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.sync-status {
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    min-width: 200px;
    text-align: center;
}

.sync-status.idle {
    background: #e9ecef;
    color: #6c757d;
    border: 1px solid #ced4da;
}

.sync-status.syncing {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
    animation: pulse 1.5s infinite;
}

.sync-status.synced {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.sync-status.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.sync-status.no-data {
    background: #e2e3e5;
    color: #383d41;
    border: 1px solid #d6d8db;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 4px;
}

.btn-warning {
    background: #ffc107;
    color: #212529;
    border: 1px solid #ffc107;
}

.btn-warning:hover {
    background: #e0a800;
    border-color: #d39e00;
}

/* Responsive design for sync status */
@media (max-width: 768px) {
    .sync-status-container {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .sync-status {
        min-width: auto;
    }
}

/* Mobile horizontal scrolling support */
@media (max-width: 768px) {
    /* Enable horizontal scrolling for wide content */
    .container {
        overflow-x: auto;
        min-width: 100%;
    }
    
    /* Make scoring interface scrollable horizontally */
    .scoring-interface {
        overflow-x: auto;
        min-width: 100%;
    }
    
    /* Make individual court sections scrollable */
    .court-section {
        overflow-x: auto;
        min-width: 100%;
    }
    
    /* Make games container scrollable */
    .games-container {
        overflow-x: auto;
        min-width: 100%;
    }
    
    /* Make scoring tables scrollable */
    .scoring-table {
        overflow-x: auto;
        min-width: 100%;
        white-space: nowrap;
    }
    
    /* Make historical table scrollable */
    .historical-table {
        overflow-x: auto;
        min-width: 100%;
        white-space: nowrap;
    }
    
    /* Make rankings table scrollable */
    .rankings-table {
        overflow-x: auto;
        min-width: 100%;
        white-space: nowrap;
    }
    
    /* Make modal content scrollable */
    .modal-content {
        overflow-x: auto;
        max-width: 95vw;
        min-width: 100%;
    }
    
    /* Make details table scrollable */
    .details-table {
        overflow-x: auto;
        min-width: 100%;
        white-space: nowrap;
    }
    
    /* Ensure body allows horizontal scrolling */
    body {
        overflow-x: auto;
        min-width: 100%;
    }
    
    /* Make sure tables don't break layout */
    table {
        min-width: 100%;
        table-layout: auto;
    }
    
    /* Ensure table cells don't wrap unnecessarily */
    th, td {
        white-space: nowrap;
        min-width: auto;
    }
    
    /* Allow some flexibility for player names */
    .player-name {
        white-space: normal;
        word-break: break-word;
        min-width: 80px;
    }
    
    /* Make score inputs maintain size */
    .score-input {
        min-width: 40px;
        width: 40px;
    }
} 