/* Reset a zakladni styly */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #0096a1;
    --primary-dark: #063139;
    --primary-light: #d4f1f4;
    --success: #0096a1;
    --danger: #dc2626;
    --warning: #ea580c;
    --light-bg: #f8fafc;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.6;
    color: var(--text);
    background: var(--light-bg);
}

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

/* Navbar */
.navbar {
    background: white;
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
    margin-bottom: 2rem;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary);
    text-decoration: none;
}

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

.nav-links a {
    color: var(--text);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    transition: background 0.2s;
}

.nav-links a:hover {
    background: var(--light-bg);
}

/* Main content */
main {
    min-height: calc(100vh - 200px);
    padding-bottom: 3rem;
}

/* Footer */
footer {
    background: white;
    border-top: 1px solid var(--border);
    padding: 2rem 0;
    text-align: center;
    color: var(--text-muted);
}

/* Flash messages */
.flash-messages {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    max-width: 500px;
    width: 90%;
}

.alert {
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: opacity 0.3s ease, transform 0.3s ease;
    font-weight: 500;
}

.alert-success {
    background: #d4f1f4;
    color: #063139;
    border: 1px solid #0096a1;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.375rem;
    font-size: 1rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    font-weight: 500;
}

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

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

.btn-secondary {
    background: var(--text-muted);
    color: white;
}

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

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

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
}

.btn-block {
    width: 100%;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-size: 1rem;
}

.form-group input[type="radio"],
.form-group input[type="checkbox"] {
    margin-right: 0.5rem;
}

/* Badge */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
}

.badge-state {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.badge-registration {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.badge-tournament {
    background: #fef3c7;
    color: #92400e;
}

.badge-final {
    background: #fce7f3;
    color: #9f1239;
}

.badge-results {
    background: #d1fae5;
    color: #065f46;
}

.badge-success {
    background: #d4f1f4;
    color: #063139;
}

/* Sections */
section {
    background: white;
    padding: 2rem;
    border-radius: 0.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

section h2 {
    margin-bottom: 1.5rem;
    color: var(--text);
}

section h3 {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text);
}

/* Tournament header */
.tournament-header {
    text-align: center;
    margin-bottom: 2rem;
}

.tournament-header h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.tournament-state {
    margin-bottom: 1rem;
}

/* Registration */
.registration-form {
    max-width: 600px;
    margin: 0 auto;
}

.small-note-title {
    font-size: 0.9em;
    color: #666;
}

.small-note {
    font-size: 0.6em;
    color: #777;
}

.rules-agreement {
    text-align: center;
    margin: 0.75rem 0;
    color: var(--text-muted);
}

.rules-agreement a {
    color: var(--primary);
    text-decoration: none;
}

.rules-agreement a:hover {
    text-decoration: underline;
}

.players-count {
    text-align: center;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
}

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

table th {
    font-weight: 600;
    background: var(--light-bg);
}

.matches-table td:last-child {
    width: 220px;
    text-align: right;
    padding-right: 2rem;
}

.matches-table th:last-child {
    text-align: right;
    padding-right: 2rem;
}

.matches-table .inline-form {
    justify-content: flex-end;
}

.standings-table {
    font-size: 0.95rem;
}

.standings-table th,
.standings-table td {
    text-align: center;
}

.standings-table td:nth-child(2) {
    text-align: left;
    font-weight: 500;
}

.positive {
    color: var(--primary);
}

.negative {
    color: var(--danger);
}

/* Groups grid */
.group {
    margin-bottom: 2rem;
}

.group h3 {
    background: var(--light-bg);
    padding: 0.75rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

.tables-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.group-table {
    background: var(--light-bg);
    padding: 1rem;
    border-radius: 0.5rem;
}

/* Bracket (playoff) */
.bracket {
    display: flex;
    gap: 3rem;
    overflow-x: auto;
    padding: 2rem 0;
}

.round {
    display: flex;
    flex-direction: column;
    min-width: 200px;
}

.round h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    text-align: center;
}

.round-matches {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    justify-content: space-around;
    flex: 1;
}

.match-card {
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1rem;
    background: white;
}

.match-card .player {
    padding: 0.5rem;
    margin: 0.25rem 0;
    border-radius: 0.375rem;
    background: var(--light-bg);
}

.match-card .player.winner {
    background: #d4f1f4;
    font-weight: bold;
    color: var(--primary-dark);
}

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

.match-players label {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background 0.2s;
}

.match-players label:hover {
    background: var(--light-bg);
}

.match-form {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.match-form button {
    flex: 1;
}

/* Inline forms */
.inline-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.inline-form select {
    flex: 1;
}

/* Admin specific */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.admin-tournament-header {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 2rem;
}

.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.login-card {
    background: white;
    padding: 2rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

.login-form {
    margin-top: 1.5rem;
}

.form-container {
    max-width: 600px;
    margin: 0 auto;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.add-player-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.add-player-form input,
.add-player-form select {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
}

.add-player-form input[type="text"] {
    flex: 2;
}

.add-player-form select,
.add-player-form input[type="number"] {
    flex: 1;
}

.group-card,
.table-card {
    background: var(--light-bg);
    padding: 1.5rem;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
}

.config-form {
    max-width: 600px;
}

/* Centered message */
.centered-message {
    text-align: center;
    padding: 4rem 2rem;
}

.centered-message h1 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.text-muted {
    color: var(--text-muted);
}

/* Tooltips */
.tooltip-trigger {
    cursor: help;
    border-bottom: 1px dotted var(--text-muted);
}

.tooltip-trigger:hover {
    border-bottom-color: var(--primary);
}

/* Player label spacing */
.player-label {
    margin-left: 0.5rem;
}

/* Master badge */
.master-badge {
    display: inline-block;
    background: #fbbf24;
    color: #78350f;
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-weight: 600;
    margin-left: 0.5rem;
}

/* Skill explanation */
.skill-explanation {
    background: var(--primary-light);
    padding: 0.75rem;
    border-radius: 0.375rem;
    margin-bottom: 0.75rem;
    margin-top: -0.25rem;
    font-size: 0.875rem;
    border-left: 3px solid var(--primary);
    text-align: center;
}

.skill-explanation small {
    color: var(--primary-dark);
    line-height: 1.5;
}

.skill-explanation a {
    color: var(--primary-dark);
    font-weight: 600;
    text-decoration: underline;
}

.skill-explanation strong {
    color: var(--primary-dark);
}

.skill-explanation p {
    margin: 0.5rem 0;
}

/* Skill options */
.skill-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.skill-radio {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 2px solid var(--border);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.skill-radio:hover {
    border-color: var(--primary);
    background: var(--light-bg);
}

.skill-radio input[type="radio"] {
    width: 18px;
    height: 18px;
    margin-top: 0.15rem;
    cursor: pointer;
    flex-shrink: 0;
}

.skill-label {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    flex: 1;
}

.skill-label strong {
    font-size: 1rem;
    line-height: 1.3;
}

.skill-label small {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.3;
}

/* Registered players */
.registered-players {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.registered-players h3 {
    margin-bottom: 1rem;
}

.players-list-vertical {
    list-style: none;
    padding: 0;
    margin: 0;
}

.players-list-vertical li {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.player-name {
    font-weight: 500;
}

/* Master star */
.master-star {
    color: #fbbf24;
    font-size: 1.2rem;
    margin-left: 0.25rem;
}

.master-star-small {
    color: #fbbf24;
    font-size: 0.9rem;
    margin-left: 0.25rem;
}

/* Match display */
.match-player {
    font-weight: 500;
}

.match-vs {
    margin: 0 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Match legend */
.match-legend {
    margin-top: 1rem;
    padding: 0.75rem;
    background: var(--light-bg);
    border-radius: 0.375rem;
    color: var(--text-muted);
}

/* Playoff match form */
.playoff-match-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.player-button {
    background: var(--light-bg);
    border: 2px solid var(--border);
    padding: 1rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.player-button:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 187, 197, 0.3);
}

/* History section */
.history-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border);
}

.history-section h3 {
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: var(--text-muted);
}

/* Collapsible sections */
.collapsible-header {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.collapsible-header:hover {
    color: var(--primary);
}

.toggle-icon {
    font-size: 0.8rem;
    transition: transform 0.3s;
}

.collapsible-content {
    margin-top: 1rem;
}

/* Rules section */
.rules-section h2 {
    color: var(--primary-dark);
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.rules-section h2:first-of-type {
    margin-top: 0;
}

.rules-section p {
    margin-bottom: 1rem;
    line-height: 1.7;
}

.rules-section ul {
    margin: 1rem 0 1rem 2rem;
    line-height: 1.7;
}

/* Responsive */
@media (max-width: 768px) {
    .bracket {
        gap: 1.5rem;
    }

    .round {
        min-width: 150px;
    }

    .tables-grid {
        grid-template-columns: 1fr;
    }

    .skill-options {
        grid-template-columns: 1fr;
    }

    .admin-header,
    .admin-tournament-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .add-player-form {
        flex-direction: column;
    }
}
