/* Turnier Management Styles */
:root {
    --primary: #3498db;
    --primary-dark: #2980b9;
    --success: #27ae60;
    --success-dark: #219a52;
    --danger: #e74c3c;
    --danger-dark: #c0392b;
    --warning: #f39c12;
    --info: #17a2b8;
    --secondary: #6c757d;
    --light: #f8f9fa;
    --dark: #343a40;
    --white: #ffffff;
    --border: #dee2e6;
    --shadow: 0 2px 15px rgba(0, 0, 0, 0.08);
    --radius: 12px;
}

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

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #e74c3c 0%, #ffffff 100%);
    min-height: 100vh;
    padding: 20px;
    color: var(--dark);
}

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

/* Header */
.header {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px 30px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.header h1 {
    font-size: 1.8rem;
    color: var(--dark);
}

.nav-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.card h2 {
    font-size: 1.4rem;
    margin-bottom: 20px;
    color: var(--dark);
    border-bottom: 2px solid var(--primary);
    padding-bottom: 10px;
}

/* Admin Tabs */
.admin-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    background: var(--white);
    padding: 10px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    flex-wrap: wrap;
}

.tab-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    background: var(--light);
    color: var(--dark);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.tab-btn.active {
    background: var(--primary);
    color: var(--white);
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
}

.tab-content {
    display: none;
}

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

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
}

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

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

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

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

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

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

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

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

.btn-warning {
    background: var(--warning);
    color: var(--dark);
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-large {
    padding: 15px 30px;
    font-size: 1.1rem;
}

/* Button rows */
.button-row {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.control-buttons {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

/* Forms */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--dark);
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 10px 15px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* Config Grid */
.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.config-item label {
    font-size: 0.9rem;
    color: var(--secondary);
    margin-bottom: 5px;
    display: block;
}

.config-item input,
.config-item select {
    width: 100%;
}

/* Tournament Select */
.turnier-select-row {
    display: flex;
    gap: 15px;
    align-items: center;
}

.turnier-select-row select {
    flex: 1;
    max-width: 400px;
}

/* Team Stats */
.team-stats {
    display: flex;
    gap: 30px;
    padding: 15px;
    background: var(--light);
    border-radius: 8px;
    margin-bottom: 15px;
}

.team-stats span {
    font-size: 1rem;
}

.team-stats strong {
    color: var(--primary);
    font-size: 1.2rem;
}

/* Filter Row */
.filter-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.filter-row input,
.filter-row select {
    width: auto;
    min-width: 200px;
}

/* Tables */
.table-container {
    overflow-x: auto;
    margin-top: 15px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
}

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

.action-btns {
    display: inline-flex;
    gap: 6px;
    justify-content: center;
    align-items: center;
    min-width: 110px;
}

th:last-child,
td.action-btns {
    text-align: center;
}

th {
    background: var(--light);
    font-weight: 600;
    color: var(--dark);
    position: sticky;
    top: 0;
}

tr:hover {
    background: rgba(52, 152, 219, 0.05);
}

/* Status badges */
.status-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    display: inline-block;
}

.status-geplant {
    background: var(--light);
    color: var(--secondary);
}

.status-bereit {
    background: #e3f2fd;
    color: #1976d2;
}

.status-laeuft {
    background: #fff3e0;
    color: #e65100;
}

.status-beendet {
    background: #e8f5e9;
    color: #2e7d32;
}

.status-wartend_bestaetigung {
    background: #fff8e1;
    color: #f57c00;
}

.status-wartend {
    background: #f3e5f5;
    color: #7b1fa2;
}

.status-angemeldet {
    background: #e3f2fd;
    color: #1976d2;
}

.status-bestaetigt {
    background: #e8f5e9;
    color: #2e7d32;
}

.status-abgemeldet {
    background: #ffebee;
    color: #c62828;
}

/* Modals */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--white);
    border-radius: var(--radius);
    padding: 30px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

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

.modal h3 {
    margin-bottom: 20px;
    color: var(--dark);
    font-size: 1.4rem;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: flex-end;
}

.hint {
    font-size: 0.85rem;
    color: var(--secondary);
    margin-bottom: 10px;
}

textarea {
    min-height: 150px;
    resize: vertical;
}

/* Result editing */
.result-teams {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: var(--light);
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 600;
}

.result-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.satz-inputs {
    margin-bottom: 20px;
}

.satz-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.satz-row span:first-child {
    width: 100px;
}

.satz-input {
    width: 80px !important;
    text-align: center;
}

/* Meldungen Container */
#meldungen-container {
    max-height: 400px;
    overflow-y: auto;
}

.meldung-item {
    padding: 15px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 10px;
    background: var(--light);
}

.meldung-item h4 {
    margin-bottom: 10px;
    color: var(--dark);
}

.meldung-info {
    font-size: 0.9rem;
    color: var(--secondary);
    margin-bottom: 10px;
}

.meldung-result {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 10px;
}

.meldung-actions {
    display: flex;
    gap: 10px;
}

/* Confirmation code display */
.meldung-code {
    background: #e3f2fd;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.meldung-code .code-display {
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--primary-dark);
    background: var(--white);
    padding: 4px 10px;
    border-radius: 4px;
    margin-left: 8px;
    letter-spacing: 2px;
}

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

    .header {
        flex-direction: column;
        text-align: center;
    }

    .header h1 {
        font-size: 1.4rem;
    }

    .nav-buttons {
        width: 100%;
        justify-content: center;
    }

    .card {
        padding: 15px;
    }

    .admin-tabs {
        flex-direction: column;
        gap: 8px;
    }

    .tab-btn {
        width: 100%;
        justify-content: center;
    }

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

    .turnier-select-row {
        flex-direction: column;
    }

    .turnier-select-row select {
        max-width: 100%;
    }

    .team-stats {
        flex-direction: column;
        gap: 10px;
    }

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

    .filter-row input,
    .filter-row select {
        width: 100%;
        min-width: auto;
    }

    .control-buttons {
        flex-direction: column;
    }

    .control-buttons .btn {
        width: 100%;
        justify-content: center;
    }

    table {
        font-size: 0.85rem;
    }

    th, td {
        padding: 8px 10px;
    }

    .result-inputs {
        grid-template-columns: 1fr;
    }

    .modal {
        padding: 20px;
    }

    .teams-pagination-controls {
        flex-direction: column;
        text-align: center;
    }
}

/* Print styles */
@media print {
    body {
        background: white;
        padding: 0;
    }

    .header nav,
    .btn,
    .filter-row,
    .modal-overlay {
        display: none !important;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
}

.toast {
    background: var(--dark);
    color: var(--white);
    padding: 15px 25px;
    border-radius: 8px;
    margin-top: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    animation: slideIn 0.3s ease;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

.toast.warning {
    background: var(--warning);
    color: var(--dark);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Loading spinner */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--white);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Action buttons in table */
.action-btns {
    display: flex;
    gap: 5px;
}

.action-btns .btn {
    padding: 5px 10px;
    font-size: 0.8rem;
}

/* Winner/Loser highlighting */
.winner {
    color: var(--success);
    font-weight: 600;
}

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

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--secondary);
}

.empty-state h3 {
    margin-bottom: 10px;
}

/* Teams pagination controls */
.teams-pagination-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 15px;
    margin-top: 10px;
    background: var(--light);
    border-radius: 8px;
}

.teams-info {
    font-size: 0.9rem;
    color: var(--secondary);
}

/* Games Section Styles */
.games-section {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

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

.section-title {
    font-size: 1.1rem;
    color: var(--dark);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title.collapsible {
    cursor: pointer;
    user-select: none;
    transition: color 0.2s;
}

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

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
}

.games-grid.collapsed {
    display: none;
}

/* Generic collapsed class for all sections */
.collapsed {
    display: none;
}

.game-card {
    background: var(--light);
    border-radius: 10px;
    padding: 15px;
    position: relative;
    transition: all 0.2s ease;
}

.game-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.game-card.active {
    border-left: 4px solid var(--warning);
    background: linear-gradient(135deg, #fff8e1 0%, var(--light) 100%);
}

.game-card.pending {
    border-left: 4px solid var(--info);
    background: linear-gradient(135deg, #e3f2fd 0%, var(--light) 100%);
}

.game-card.vorschau {
    border-left: 4px solid #9c27b0;
    background: linear-gradient(135deg, #f3e5f5 0%, var(--light) 100%);
}

.game-card.finished {
    border-left: 4px solid var(--success);
    background: linear-gradient(135deg, #e8f5e9 0%, var(--light) 100%);
}

.game-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.game-card-number {
    font-weight: 600;
    color: var(--primary);
}

.game-card-field {
    font-size: 0.85rem;
    color: var(--info);
    background: rgba(23, 162, 184, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
}

.game-card-field.no-field {
    color: var(--secondary);
    background: rgba(108, 117, 125, 0.1);
}

.game-card-phase-info {
    margin-bottom: 8px;
}

.game-card-phase {
    font-size: 0.8rem;
    color: #9c27b0;
    background: rgba(156, 39, 176, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
}

.game-card-schiri-info {
    margin-bottom: 8px;
}

.game-card-schiri {
    font-size: 0.8rem;
    color: #2196f3;
    background: rgba(33, 150, 243, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    display: inline-block;
}

.game-card-schiri.no-schiri {
    color: #999;
    background: rgba(0, 0, 0, 0.05);
}

.game-card-teams {
    margin-bottom: 10px;
}

.game-card-team {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    margin-bottom: 5px;
    background: var(--white);
    border-radius: 6px;
}

.game-card-team.winner {
    background: #c8e6c9;
    font-weight: 600;
}

.game-card-team.loser {
    background: #ffcdd2;
    color: var(--secondary);
}

.game-card-team-name {
    flex: 1;
    font-size: 0.95rem;
}

.game-card-team-score {
    font-weight: 600;
    font-size: 1.1rem;
    min-width: 30px;
    text-align: center;
}

.game-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--secondary);
}

.game-card-actions {
    display: flex;
    gap: 5px;
}

.game-card-actions .btn {
    padding: 4px 8px;
    font-size: 0.75rem;
}

/* Help text */
.help-text {
    display: block;
    margin-top: 5px;
    font-size: 0.85rem;
    color: var(--info);
    font-style: italic;
}

/* Result Notification Badge */
.result-notification-badge {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--danger);
    color: white;
    padding: 12px 20px;
    border-radius: 25px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: pulse 2s infinite;
    z-index: 1000;
    font-weight: 600;
}

.result-notification-badge:hover {
    background: #c62828;
    transform: scale(1.05);
}

#notification-count {
    background: white;
    color: var(--danger);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}

.notification-text {
    font-size: 0.95rem;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    }
    50% {
        box-shadow: 0 4px 16px rgba(244, 67, 54, 0.6);
    }
}

/* Accessibility: Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .result-notification-badge {
        animation: none;
    }
    
    .result-notification-badge:hover {
        transform: none;
    }
}
