:root {
    --bg-main: #0B1521;
    --table-blue: #1C3F60;
    --table-blue-light: #2A547E;
    --orange-primary: #FF6B00;
    --orange-glow: rgba(255, 107, 0, 0.4);
    --white: #FFFFFF;
    --text-muted: #A0B0C0;
    --glass-bg: rgba(28, 63, 96, 0.45);
    --glass-border: rgba(255, 255, 255, 0.1);
    --success: #10B981;
    --danger: #EF4444;
    --warning: #F59E0B;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', 'Roboto', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--white);
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(255, 107, 0, 0.05), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(28, 63, 96, 0.5), transparent 30%);
    background-attachment: fixed;
    min-height: 100vh;
    display: flex;
}

.text-orange { color: var(--orange-primary); }
.text-center { text-align: center; }
.w-100 { width: 100%; }
.mt-1 { margin-top: 1rem; }

/* Utilities */
.hidden { display: none !important; }

/* Glassmorphism */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* Layout */
.app-container {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* Navigation Sidebar */
.sidebar {
    width: 260px;
    background: rgba(14, 27, 43, 0.8);
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
}

.logo {
    padding: 2rem 1.5rem;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--glass-border);
}

.nav-links {
    list-style: none;
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0 1rem;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.8rem 1rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
    font-weight: 500;
}

.nav-links a:hover {
    color: var(--white);
    background: var(--table-blue);
}

.nav-links a.active {
    color: var(--white);
    background: var(--table-blue);
    border-left: 4px solid var(--orange-primary);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
    padding-left: 3rem;
    padding-right: 3rem;
    overflow-y: auto;
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 1rem;
}

.view-header h1 {
    font-size: 2rem;
    font-weight: 700;
    text-shadow: 0 0 10px rgba(255,255,255,0.1);
}

/* Buttons */
.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: 'Outfit', sans-serif;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--orange-primary);
    color: white;
    box-shadow: 0 4px 15px var(--orange-glow);
}
.btn-primary:hover:not(:disabled) {
    background: #E66000;
    box-shadow: 0 6px 20px var(--orange-glow);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--table-blue-light);
    color: white;
}
.btn-secondary:hover { background: #376A9E; }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #0EA5E9; }

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

.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #D97706; }

/* Tables */
.card {
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
}

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

table.data-table th {
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 1px;
}

table.data-table tbody tr { transition: background 0.2s; }
table.data-table tbody tr:hover { background: rgba(255, 255, 255, 0.05); }

/* Forms */
.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.form-group input, .form-group select {
    width: 100%;
    padding: 0.7rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.2);
    color: white;
    font-size: 1rem;
    transition: border-color 0.3s;
}
.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--orange-primary);
}
.form-group select option {
    background: var(--bg-main);
    color: white;
}

/* Modals */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(11, 21, 33, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--table-blue);
    width: 100%;
    max-width: 500px;
    padding: 2rem;
    position: relative;
    border-top: 4px solid var(--orange-primary);
}

.close-modal {
    position: absolute;
    top: 1rem; right: 1.5rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s;
}
.close-modal:hover { color: white; }

/* Grid Setup */
.setup-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

/* Player Selection List inside Setup */
.player-selection-list {
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}

.player-select-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}
.player-select-item:hover {
    background: rgba(255, 255, 255, 0.05);
}
.player-select-item.selected {
    border-color: var(--orange-primary);
    background: rgba(255, 107, 0, 0.1);
}
.player-select-item input[type="checkbox"] {
    accent-color: var(--orange-primary);
    width: 20px;
    height: 20px;
}

/* Search Box Autocomplete */
.search-dropdown {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    width: 100%;
    z-index: 10;
    max-height: 250px;
    overflow-y: auto;
    background: var(--table-blue);
    border: 1px solid var(--orange-primary);
    border-radius: 6px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}
.search-item {
    padding: 0.8rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    transition: background 0.2s;
}
.search-item:hover {
    background: rgba(255, 107, 0, 0.2);
}
.search-item:last-child { border-bottom: none; }

.remove-player-btn {
    background: none;
    border: none;
    color: var(--danger);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.2rem;
    margin-left: auto;
}
.remove-player-btn:hover { color: #FCA5A5; }

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    border-left: 4px solid;
}
.alert-info { background: rgba(14, 165, 233, 0.1); border-color: #0EA5E9; color: #E0F2FE; }

/* Matches Tab & Display */
.tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}
.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.3s;
}
.tab-btn.active {
    color: var(--white);
    border-bottom: 2px solid var(--orange-primary);
}
.tab-btn:hover:not(.active) { color: var(--white); }

.rounds-filter {
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Match Listing (Inline Row Layout) */
.matches-container {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.match-row-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    margin-bottom: 0.8rem;
    transition: all 0.3s ease;
}
.match-row-item.finished {
    background: rgba(40, 167, 69, 0.15); /* Jemná zelená pre uhádnuté zápasy */
    border-color: rgba(40, 167, 69, 0.3);
}
.mr-info {
    flex: 0 0 100px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 0.9em;
}
.mr-players {
    flex: 1 1 200px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 1.1em;
}
.mr-sets {
    flex: 2 1 300px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-start;
}
.mr-set-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}
.mr-set-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.mr-set-input {
    width: 45px;
    padding: 5px;
    text-align: center;
    border-radius: 4px;
    border: 1px solid rgba(255,107,0,0.5);
    background: rgba(0,0,0,0.6);
    color: white;
}
.mr-set-input:focus { border-color: var(--orange-primary); outline:none; }
.mr-actions {
    flex: 1 1 150px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    text-align: center;
}
.table-input {
    width: 40px;
    padding: 2px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.1);
    color: white;
    text-align: center;
}

.m-round-badge {
    background: var(--orange-primary);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
    display: inline-block;
    max-width: fit-content;
}

.m-players {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 1.1rem;
    font-weight: 500;
}

.m-player {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.m-player-winner { color: var(--orange-primary); font-weight: 700; }

/* Set outputs in match card */
.m-sets {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    gap: 0.5rem;
}
.m-set {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
}

/* Score Modal */
.score-modal { max-width: 600px; }
.match-players {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    font-size: 1.5rem;
    font-weight: 700;
    margin: 1.5rem 0;
    background: rgba(0, 0, 0, 0.2);
    padding: 1rem;
    border-radius: 8px;
}
.vs { color: var(--orange-primary); font-size: 1rem; }

.set-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.8rem;
}
.set-row input {
    width: 70px;
    text-align: center;
    font-size: 1.2rem;
    padding: 0.5rem;
}

.match-result-summary {
    text-align: center;
    font-size: 1.8rem;
    font-weight: 700;
    margin: 1.5rem 0;
    color: var(--orange-primary);
}

.format-info { color: var(--text-muted); margin-bottom: 1.5rem; }

/* Badges for Standings */
.badge {
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}
.badge-gold { background: linear-gradient(45deg, #F59E0B, #FCD34D); color: #78350F; }
.badge-silver { background: linear-gradient(45deg, #94A3B8, #E2E8F0); color: #1E293B; }
.badge-bronze { background: linear-gradient(45deg, #B45309, #F59E0B); color: #FFF; }
.rank-badge {
    background: var(--table-blue-light);
    width: 24px; height: 24px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
}

/* Floating Navigation for Matches */
.floating-nav {
    position: fixed;
    bottom: 30px;
    right: 30px;
    display: flex;
    gap: 10px;
    z-index: 1000;
    padding: 8px;
    background: rgba(40, 40, 40, 0.4);
    border-radius: 25px;
    backdrop-filter: blur(8px);
    opacity: 0.85;
    transition: opacity 0.3s;
}
.floating-nav:hover {
    opacity: 1;
}

@media (max-width: 600px) {
    .floating-nav {
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        bottom: 20px;
        width: max-content;
    }
}
