/* ==========================================================================
   Simple Tournament Bracket Stylesheet (Modern Gentle White Theme)
   ========================================================================== */

.wp-tournament-container {
    --bg-primary: #f7fafc;
    --bg-secondary: #ffffff;
    --border-color: #e2e8f0;
    --line-color: #cbd5e1;
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --accent-color: #6366f1; /* Soft Indigo */
    --accent-glow: rgba(99, 102, 241, 0.15);
    --success-color: #10b981; /* Soft Emerald */
    --danger-color: #ef4444; /* Soft Rose Red */
    --gold-color: #f59e0b; /* Soft Amber */
    --line-green: #06c755; /* Official LINE Green */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --border-radius-lg: 20px;
    --border-radius-md: 12px;
    --border-radius-sm: 8px;
    --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    
    font-family: var(--font-family);
    color: var(--text-primary);
    background-color: var(--bg-primary);
    padding: 30px;
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.03);
    max-width: 100%;
    box-sizing: border-box;
    margin: 20px auto;
    position: relative;
    overflow: hidden;
}

.wp-tournament-container * {
    box-sizing: border-box;
}

/* Header design */
.wp-tournament-header {
    text-align: center;
    margin-bottom: 30px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 20px;
}

.wp-tournament-header h2 {
    font-size: 2rem;
    margin: 0 0 8px 0;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.wp-tournament-header p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin: 0;
}

/* Cards & Layout */
.tournament-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.015);
    transition: var(--transition-smooth);
}

.tournament-card h3 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.15rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    border-left: 4px solid var(--accent-color);
    padding-left: 10px;
    color: var(--text-primary);
}

/* Form inputs & Textarea */
#player-names-input {
    width: 100%;
    min-height: 160px;
    background: #ffffff;
    border: 1.5px solid #e2e8f0;
    border-radius: var(--border-radius-md);
    padding: 15px;
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.6;
    resize: vertical;
    transition: var(--transition-smooth);
}

#player-names-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 4px var(--accent-glow);
}

.setup-controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.setup-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

/* Custom Checkbox */
.custom-checkbox {
    display: flex;
    align-items: center;
    position: relative;
    padding-left: 28px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    user-select: none;
}

.custom-checkbox input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    height: 18px;
    width: 18px;
    background-color: #fff;
    border: 1.5px solid #cbd5e1;
    border-radius: 4px;
    transition: var(--transition-smooth);
}

.custom-checkbox:hover input ~ .checkmark {
    border-color: var(--accent-color);
}

.custom-checkbox input:checked ~ .checkmark {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.custom-checkbox input:checked ~ .checkmark:after {
    display: block;
}

.custom-checkbox .checkmark:after {
    left: 6px;
    top: 2px;
    width: 4px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Buttons */
.btn {
    padding: 10px 22px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--border-radius-sm);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition-smooth);
}

.btn-primary {
    background: var(--accent-color);
    color: #fff;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.2);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(99, 102, 241, 0.35);
    background: #4f46e5;
}

.btn-secondary {
    background: #f1f5f9;
    color: var(--text-primary);
    border: 1px solid #e2e8f0;
}

.btn-secondary:hover {
    background: #e2e8f0;
}

.btn-danger {
    background: #fef2f2;
    color: var(--danger-color);
    border: 1.5px solid #fecaca;
}

.btn-danger:hover {
    background: var(--danger-color);
    color: #fff;
    border-color: var(--danger-color);
}

/* LINE Green Button */
.btn-line {
    background: var(--line-green);
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(6, 199, 85, 0.2);
}

.btn-line:hover {
    background: #05b04b;
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(6, 199, 85, 0.35);
}

/* Share Actions Group layout */
.share-actions-group {
    display: inline-flex;
    gap: 10px;
}

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

/* Floating Toast Notification */
.toast-notification {
    position: fixed;
    top: -50px; /* Start hidden above the viewport */
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.9);
    color: #ffffff;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 700;
    border-radius: 30px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    pointer-events: none;
    transition: top 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
    opacity: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast-notification.visible {
    top: 30px; /* Animate into view */
    opacity: 1;
}

/* Tournament Bracket Structure */
.bracket-actions {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.bracket-scroll-wrapper {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 15px 5px 25px 5px;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
    -webkit-overflow-scrolling: touch;
}

.bracket-scroll-wrapper::-webkit-scrollbar {
    height: 8px;
}

.bracket-scroll-wrapper::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.bracket-scroll-wrapper::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 4px;
}

.bracket-viewport {
    display: flex;
    gap: 50px; /* Space between rounds */
    min-width: max-content;
    padding: 10px 0;
    position: relative;
}

/* Round columns */
.round-column {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    width: 220px;
    position: relative;
    z-index: 2;
}

.round-header {
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-secondary);
    padding: 8px 12px;
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    margin-bottom: 15px;
}

/* Match container */
.match-container {
    display: flex;
    align-items: center;
    position: relative;
    padding: 15px 0;
}

/* Match Card */
.match-card {
    background: #ffffff;
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius-md);
    width: 100%;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.02);
    transition: var(--transition-smooth);
    position: relative;
    z-index: 3;
}

.match-card:hover {
    border-color: var(--accent-color);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.1);
    transform: translateY(-2px);
}

.match-card-header {
    font-size: 9px;
    font-weight: 700;
    color: var(--text-secondary);
    padding: 6px 12px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
}

/* Participant rows inside Match Card */
.match-participant {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    transition: var(--transition-smooth);
    border-bottom: 1px solid #f1f5f9;
}

.match-participant:last-child {
    border-bottom: none;
}

.match-participant:hover {
    background: #f8fafc;
}

/* Winner/Loser visual indicators */
.match-participant.winner {
    background: #ecfdf5;
    color: var(--success-color);
}

.match-participant.winner::after {
    content: "✓";
    font-size: 12px;
    font-weight: 800;
}

.match-participant.loser {
    opacity: 0.45;
}

.match-participant.tbd {
    font-style: italic;
    color: #94a3b8;
    font-weight: 400;
    pointer-events: none;
}

/* Special Seed Container UI */
.seed-card {
    border: 1.5px dashed var(--accent-color);
    background: #faf5ff;
}

.seed-card:hover {
    box-shadow: 0 8px 20px rgba(123, 44, 191, 0.08);
    border-color: var(--accent-color);
}

.seed-card .match-card-header {
    background: #f3e8ff;
    color: var(--accent-color);
    border-bottom: 1px dashed var(--accent-color);
}

.seed-active {
    background: #faf5ff;
    cursor: default;
    color: var(--text-primary);
    pointer-events: none;
}

.seed-active i {
    font-size: 10px;
    color: var(--accent-color);
    font-style: normal;
    font-weight: 700;
}

/* Highlight connection path when winner is selected */
.match-card.completed {
    border-color: var(--success-color);
}

/* Winner Overlay Animation */
.winner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

.winner-content {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 40px;
    text-align: center;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.12);
    animation: scaleUp 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.trophy-emoji {
    font-size: 64px;
    margin-bottom: 15px;
    animation: bounce 2s infinite;
}

.winner-content h3 {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin: 0;
}

.winner-content h1 {
    font-size: 2.25rem;
    font-weight: 800;
    margin: 15px 0 25px 0;
    background: linear-gradient(135deg, var(--gold-color) 0%, #d97706 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

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

@keyframes scaleUp {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .wp-tournament-container {
        padding: 15px;
        border-radius: var(--border-radius-md);
    }
    
    .wp-tournament-header h2 {
        font-size: 1.6rem;
    }
    
    .bracket-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .share-actions-group {
        width: 100%;
        display: flex;
    }

    .share-actions-group .btn {
        flex: 1;
    }
    
    .setup-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .btn {
        width: 100%;
    }
    
    .round-column {
        width: 190px;
        gap: 20px;
    }
    
    .match-participant {
        padding: 10px 12px;
        font-size: 13px;
    }
}
