/* Base styles and reset */
* {
    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 {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

/* Typography */
h1, h2, h3, h4 {
    margin-bottom: 1rem;
    color: #2c3e50;
}

h1 {
    font-size: 1.8rem;
    text-align: center;
}

h2 {
    font-size: 1.5rem;
    border-bottom: 2px solid #3498db;
    padding-bottom: 0.5rem;
    margin-top: 1.5rem;
}

h3 {
    font-size: 1.2rem;
}

h4 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

/* Header */
header {
    background-color: #3498db;
    color: white;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

header h1 {
    color: white;
    margin-bottom: 0;
}

/* Sections */
section {
    background-color: white;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* Rules info */
.rules-info {
    background-color: #f8f9fa;
    padding: 0.8rem;
    border-radius: 4px;
    border-left: 4px solid #3498db;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

/* Form styles */
form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sets-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.set {
    background-color: #f9f9f9;
    padding: 1rem;
    border-radius: 6px;
    border: 1px solid #eee;
}

.set h3 {
    font-size: 1.1rem;
    margin-bottom: 0.8rem;
    color: #3498db;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.5rem;
}

.set-scores {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.player-set {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-weight: bold;
}

/* Improved input styles for mobile */
input {
    padding: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1.2rem; /* Larger font size for better readability */
    width: 100%;
    height: 50px; /* Taller input boxes for easier tapping */
    text-align: center; /* Center the numbers */
    -webkit-appearance: none; /* Remove default iOS styling */
    -moz-appearance: textfield; /* Remove spinner for Firefox */
    appearance: none;
    background-color: white;
}

/* Remove spinner buttons for number inputs */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Focus state for inputs */
input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.3);
}

button {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: background-color 0.3s;
    height: 50px; /* Match height with inputs for consistency */
}

button:hover {
    background-color: #2980b9;
}

.danger-button {
    background-color: #e74c3c;
    margin-top: 1rem;
}

.danger-button:hover {
    background-color: #c0392b;
}

.form-actions {
    display: flex;
    justify-content: center;
    margin-top: 1.5rem;
}

.form-actions button {
    width: 100%;
    max-width: 300px;
    height: 60px; /* Larger submit button */
    font-size: 1.2rem;
}

.data-actions {
    display: flex;
    justify-content: center;
    margin-top: 1.5rem;
}

/* Match history */
#history-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.match-item {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 1rem;
    padding: 1rem;
    position: relative;
}

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

.match-date {
    font-size: 0.9rem;
    color: #7f8c8d;
}

.match-winner {
    font-weight: 500;
}

.winner {
    color: #2ecc71;
    font-weight: bold;
}

.match-sets {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.set-result {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    border-bottom: 1px dashed #eee;
}

.set-result:last-child {
    border-bottom: none;
}

/* Delete match button */
.delete-match-btn {
    background-color: #e74c3c;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background-color 0.2s;
}

.delete-match-btn:hover {
    background-color: #c0392b;
}

/* Data actions */
.data-actions {
    margin-top: 1rem;
    display: flex;
    justify-content: flex-end;
}

/* Odds section */
.odds-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #eee;
}

.odds-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.odds-title {
    font-size: 1.2rem;
    color: #3498db;
    margin-bottom: 1rem;
}

.odds-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    text-align: center;
}

.player-odds {
    padding: 1rem;
    background-color: #f9f9f9;
    border-radius: 4px;
}

.player-odds p {
    font-size: 1.5rem;
    font-weight: bold;
    color: #e74c3c;
}

.exact-score-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.exact-score-odds {
    background-color: #f9f9f9;
    padding: 1rem;
    border-radius: 4px;
}

.exact-score-odds h4 {
    text-align: center;
    margin-bottom: 0.8rem;
    color: #3498db;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.5rem;
}

.exact-score-players {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.exact-score-player {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem;
}

.exact-score-player span:last-child {
    font-weight: bold;
    color: #e74c3c;
}

/* Footer */
footer {
    text-align: center;
    padding: 1rem;
    color: #7f8c8d;
    font-size: 0.9rem;
}

/* Media queries for larger screens */
@media (min-width: 768px) {
    h1 {
        font-size: 2.2rem;
    }
    
    .sets-container {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    #set5-container {
        grid-column: span 2;
        max-width: 50%;
        margin: 0 auto;
    }
    
    .odds-container {
        flex-direction: row;
        justify-content: space-around;
    }
    
    .player-odds {
        width: 45%;
    }
    
    .exact-score-container {
        flex-direction: row;
        justify-content: space-between;
    }
    
    .exact-score-odds {
        width: 32%;
    }
    
    .match-item {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
    
    .match-sets {
        display: flex;
        flex-direction: row;
        gap: 1rem;
        margin-top: 0;
    }
    
    .set-result {
        border-bottom: none;
        border-right: 1px dotted #ddd;
        padding: 0 0.5rem;
    }
    
    .set-result:last-child {
        border-right: none;
    }
    
    /* Desktop input styles */
    input {
        height: 45px;
        font-size: 1.1rem;
    }
    
    .form-actions button {
        height: 50px;
    }
}

/* Loading indicator */
.loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    margin-bottom: 20px;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Refresh indicator */
.refresh-indicator {
    display: inline-flex;
    align-items: center;
    font-size: 0.8rem;
    margin-left: 15px;
    color: #666;
}

.refresh-time {
    margin-right: 10px;
}

.server-status {
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: bold;
}

.server-status.online {
    background-color: #4CAF50;
    color: white;
}

.server-status.offline {
    background-color: #f44336;
    color: white;
}

/* Save confirmation message */
.save-confirmation {
    margin-top: 10px;
    padding: 10px;
    background-color: #4CAF50;
    color: white;
    border-radius: 4px;
    text-align: center;
    animation: fadeIn 0.3s ease-in-out;
}

.save-confirmation.warning {
    background-color: #ff9800;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Form state indicator */
.form-has-data {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #ff9800;
    color: white;
    padding: 10px 15px;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 100;
    font-size: 0.9rem;
}

/* Mobile-specific improvements */
@media (max-width: 767px) {
    /* Increase spacing between set containers */
    .sets-container {
        gap: 2rem;
    }
    
    /* Make set containers more distinct */
    .set {
        padding: 1.2rem;
        border: 1px solid #ddd;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }
    
    /* Improve spacing in set scores */
    .set-scores {
        gap: 1.5rem;
    }
    
    /* Add visual cue for active input */
    input:focus {
        transform: scale(1.02);
    }
    
    /* Larger submit button for mobile */
    .form-actions button {
        height: 60px;
        font-size: 1.2rem;
        width: 100%;
    }
    
    /* Improve tap targets */
    .player-set label {
        font-size: 1.1rem;
        padding: 0.3rem 0;
    }
    
    /* Fix iOS zoom on input focus */
    @media screen and (-webkit-min-device-pixel-ratio:0) { 
        select,
        textarea,
        input {
            font-size: 16px;
        }
    }
} 