:root {
    /* Tema BWF Solid: Merah BWF, Hitam, dan Putih */
    --primary: #d41b2c;      /* Merah BWF Utama */
    --primary-dark: #9e0a2b; /* Merah Gelap */
    --dark: #111111;         /* Hitam Pekat */
    --light: #ffffff;        /* Putih Murni */
    --bg-grey: #f4f4f4;      /* Abu-abu terang untuk kontras */
    --text-main: #111111;    
    --text-muted: #666666;   
    --court-color: #111111;  
}

* { box-sizing: border-box; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }

html, body {
    max-width: 100vw;
}

body { 
    /* BACKGROUND GAMBAR BADMINTON DENGAN OVERLAY MERAH BWF (Solid/Non-Glass) */
    background-image: 
        linear-gradient(135deg, rgba(122, 0, 29, 0.85) 0%, rgba(212, 27, 44, 0.75) 50%, rgba(74, 0, 16, 0.9) 100%),
        url('https://images.unsplash.com/photo-1626224583764-f87db24ac4ea?q=80&w=2000&auto=format&fit=crop'); 
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-color: var(--primary-dark); 
    
    color: var(--light); 
    margin: 0; 
    padding: 0; 
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- NAVBAR STYLES (Solid White - Sticky) --- */
.navbar {
    background-color: var(--light);
    padding: 0.8rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.nav-brand { display: flex; align-items: center; }
.nav-brand h1 { margin: 0; font-size: 1.4rem; color: var(--dark); text-transform: uppercase; letter-spacing: 1px; font-weight: 900;}
.nav-brand h1 span { color: var(--primary); font-weight: 700;}

.hamburger { display: none; flex-direction: column; justify-content: space-around; width: 26px; height: 22px; background: transparent; border: none; cursor: pointer; padding: 0; z-index: 101; }
.hamburger span { width: 100%; height: 3px; background-color: var(--dark); border-radius: 10px; transition: all 0.3s linear; transform-origin: 1px; }

.nav-menu { display: flex; gap: 8px; }
.tab { padding: 8px 16px; background: transparent; color: var(--text-muted); cursor: pointer; border-radius: 6px; font-weight: 800; transition: all 0.2s ease; border: 1px solid transparent; font-size: 0.9rem; }
.tab:hover { color: var(--primary); background: var(--bg-grey);}
.tab.active { background: var(--dark); color: var(--light); box-shadow: 0 3px 6px rgba(0,0,0,0.15); }

.nav-controls { display: flex; align-items: center; gap: 12px; }
#login-btn { background: var(--primary); color: var(--light); border: none; padding: 8px 18px; border-radius: 6px; cursor: pointer; font-weight: bold; transition: all 0.2s ease; font-size: 0.9rem; box-shadow: 0 3px 8px rgba(212, 27, 44, 0.4);}
#login-btn:hover { background: var(--primary-dark); transform: translateY(-1px);}
#admin-status { color: var(--dark); font-weight: bold; font-size: 0.85rem; }
.is-admin #admin-status { color: #008f39; }

/* --- MAIN CONTENT --- */
main { flex: 1; max-width: 1400px; margin: 0 auto; width: 100%; padding: 2rem 1.5rem; }
.container { display: none; }
.container.active { display: block; animation: fadeIn 0.3s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }

.info-text { color: var(--light); margin-bottom: 25px; line-height: 1.6; font-size: 0.95rem; text-shadow: 1px 1px 4px rgba(0,0,0,0.6);}
.info-text h2 { text-align: center; color: var(--light); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 1.5px; text-shadow: 2px 2px 5px rgba(0,0,0,0.6); font-weight: 900;}

/* Group Stage Styles */
.groups-wrapper { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); 
    gap: 2rem; 
    width: 100%;
}

/* === KOTAK GRUP === */
.group-card { 
    background: var(--light); 
    border-top: 6px solid var(--primary); 
    border-radius: 12px; 
    padding: 1.5rem; 
    box-shadow: 0 10px 25px rgba(0,0,0,0.4); 
    min-width: 0; 
    width: 100%;
}

.group-card h3 { 
    background: var(--dark);
    color: var(--light);
    display: inline-block;
    padding: 8px 24px 8px 18px;
    margin-top: -1.5rem;
    margin-left: -1.5rem;
    margin-bottom: 20px;
    text-transform: uppercase;
    font-size: 1.1rem;
    font-style: italic;
    font-weight: 900;
    border-radius: 10px 0 14px 0;
    box-shadow: 3px 3px 8px rgba(0,0,0,0.3);
    letter-spacing: 1px;
}

/* --- TABEL KLASEMEN --- */
.table-container { 
    width: 100%; 
    overflow-x: auto; 
    -webkit-overflow-scrolling: touch; 
    margin-bottom: 20px; 
    border-radius: 8px; 
    border: 1px solid #e0e0e0; 
    background: var(--light); 
}

table { 
    width: 100%; 
    min-width: 400px; 
    border-collapse: collapse; 
    margin-bottom: 0; 
}

tr:first-child { background: var(--primary); }

tr:first-child th {
    color: var(--light); 
    font-weight: 800; 
    text-transform: uppercase; 
    font-size: 0.75rem; 
    border: none; 
    padding: 12px 8px; 
    letter-spacing: 0.5px;
}

/* Lebarkan sedikit area nama tim di header */
th:first-child { padding-left: 14px; text-align: left; min-width: 150px; }
th:last-child { padding-right: 14px; }

th:not(:first-child), td:not(:first-child) { 
    text-align: center; 
    width: 42px; 
}

th[style*="color:green;"], th[style*="color:red;"], th[style*="color:blue;"] { 
    color: #ffffff !important; 
    text-shadow: none;
}

tr:not(:first-child) { 
    border-bottom: 1px solid #eee; 
    transition: background 0.2s ease;
}
tr:not(:first-child):last-child { border-bottom: none; }
tr:nth-child(even):not(:first-child) { background: var(--bg-grey); }
tr:not(:first-child):hover { background: #e9ecef; }

td { 
    color: var(--text-main); 
    font-weight: 800; 
    padding: 12px 8px; 
    vertical-align: middle; 
    font-size: 0.9rem;
}

/* PERBAIKAN: Layout Kolom Nama Tim */
td:first-child { 
    padding-left: 14px; 
    display: flex;
    align-items: center;
    gap: 12px;          /* Jarak rapi antara logo dan teks */
    min-height: 52px;   /* Menjaga tinggi baris saat teks turun (wrap) */
}

/* PERBAIKAN: Agar nama panjang otomatis turun ke bawah secara rapi */
td:first-child span {
    flex: 1;            /* Mengambil sisa ruang kolom */
    word-break: break-word; /* Memaksa kata panjang turun ke bawah */
    line-height: 1.3;
}

td:last-child { padding-right: 14px; }

tr:nth-child(2) td:first-child { border-left: 5px solid #008f39; }
tr:nth-child(3) td:first-child { border-left: 5px solid #0056b3; }
tr:nth-child(4) td:first-child, tr:nth-child(5) td:first-child { border-left: 5px solid transparent; }

/* --- LOGO TIM --- */
.team-logo {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    background-color: var(--dark);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: block;
    flex-shrink: 0; /* PERBAIKAN: Memastikan logo tidak menyusut jadi peyang saat nama timnya panjang */
}

.bracket .team-logo {
    width: 22px;
    height: 22px;
    margin-right: 8px;
}

.editable { cursor: pointer; transition: color 0.2s; }
.editable:hover { color: var(--primary); text-decoration: underline; }

/* Matches List Styles */
.match-list { font-size: 0.85rem; max-height: 260px; overflow-y: auto; padding-right: 8px; }
.match-list::-webkit-scrollbar { width: 6px; }
.match-list::-webkit-scrollbar-track { background: var(--bg-grey); border-radius: 4px;}
.match-list::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

.match-item { 
    background: var(--bg-grey); 
    color: var(--text-main);
    padding: 12px 14px; 
    margin-bottom: 10px; 
    border-radius: 8px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    border: 1px solid #e0e0e0;
    border-left: 6px solid var(--primary);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.court-badge { background: var(--dark); color: var(--light); font-weight: 800; font-size: 0.65rem; padding: 4px 8px; border-radius: 12px; margin-right: 6px; letter-spacing: 0.5px;}
.score-box { background: var(--light); border: 2px solid #ddd; padding: 6px 14px; border-radius: 6px; cursor: pointer; text-align: center; min-width: 60px; font-weight: 600; font-size: 0.6rem; color: var(--text-main); transition: all 0.2s;}
.score-box:hover.editable { background: var(--primary); color: var(--light); border-color: var(--primary); }
.team-winner { color: var(--primary); font-weight: 900; }

/* Bracket Styles */
.bracket-container { overflow-x: auto; padding-bottom: 2rem; margin-top: 1rem; border-top: 2px dashed rgba(255,255,255,0.5); padding-top: 2rem; width: 100%;}
.bracket { display: flex; min-width: max-content; }

.round { 
    display: flex; 
    flex-direction: column; 
    min-width: 250px; 
    width: auto; 
    max-width: 320px;
    padding: 0 16px; 
}

.round h2 { text-align: center; color: var(--light); font-size: 1.1rem; margin-bottom: 1.8rem; text-transform: uppercase; border-bottom: 3px solid var(--light); padding-bottom: 10px; font-weight: 900; text-shadow: 2px 2px 4px rgba(0,0,0,0.6);}
.round-wrapper { display: flex; flex-direction: column; justify-content: space-around; flex: 1; }

.matchup-pair { display: flex; flex-direction: column; justify-content: space-around; flex: 1; position: relative; min-height: 130px; }

.matchup-pair::after {
    content: ''; position: absolute; right: -20px; top: 25%; bottom: 25%; width: 20px;
    border-right: 2px solid rgba(255,255,255,0.9); border-top: 2px solid rgba(255,255,255,0.9); border-bottom: 2px solid rgba(255,255,255,0.9);
    border-radius: 0 8px 8px 0; z-index: 1;
}
.matchup-pair.single-match::after { display: none; }
.round:not(:first-child) .matchup::before {
    content: ''; position: absolute; left: -20px; top: 50%; width: 20px;
    border-top: 2px solid rgba(255,255,255,0.9); z-index: -1;
}

.matchup { 
    background: var(--light); 
    border-left: 6px solid var(--primary); 
    border-radius: 8px; 
    position: relative; 
    box-shadow: 0 6px 15px rgba(0,0,0,0.4); 
    z-index: 2; 
    min-height: 85px; 
    height: auto; 
    display: flex; 
    flex-direction: column; 
    justify-content: center; 
}

.team { 
    display: flex; 
    justify-content: flex-start; 
    padding: 8px 14px; 
    min-height: 42px; 
    height: auto;
    align-items: center; 
    border-bottom: 1px solid #e0e0e0; 
    font-size: 0.9rem; 
    color: var(--text-main); 
    font-weight: 800;
}

.team span {
    white-space: normal; 
    word-break: break-word; 
    padding-right: 35px; 
    line-height: 1.3;
}
.team:last-child { border-bottom: none; }

.knockout-score { position: absolute; right: -8px; top: 50%; transform: translateY(-50%); font-size: 0.85rem; background: var(--light); padding: 5px 10px; border-radius: 6px; color: var(--text-main); font-weight: 900; box-shadow: 0 3px 6px rgba(0,0,0,0.2); border: 2px solid #ddd;}
.knockout-score.editable { cursor: pointer; transition: all 0.2s; }
.knockout-score.editable:hover { background: var(--primary); color: var(--light); border-color: var(--primary); transform: translateY(-50%) scale(1.05);}

/* --- FOOTER --- */
footer {
    background-color: var(--dark);
    color: var(--light);
    text-align: center;
    padding: 1.8rem;
    margin-top: auto;
    border-top: 5px solid var(--primary);
    box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.5);
}
footer p { margin: 0; font-weight: 700; letter-spacing: 1.5px; font-size: 0.9rem; }
footer span { color: var(--primary); font-weight: 900;}

/* --- MEDIA QUERIES --- */
@media (max-width: 768px) {
    .navbar { padding: 0.8rem 1.2rem; flex-wrap: wrap; }
    .nav-brand h1 { font-size: 1.2rem; }
    .hamburger { display: flex; }
    .nav-menu, .nav-controls { display: none; width: 100%; flex-direction: column; align-items: stretch; text-align: center; }
    .nav-menu { margin-top: 15px; gap: 10px; order: 3; }
    .nav-controls { margin-top: 15px; padding-top: 15px; border-top: 1px solid rgba(0,0,0,0.1); order: 4; gap: 15px; justify-content: center;}
    .nav-menu.show, .nav-controls.show { display: flex; }
    .hamburger.active span:nth-child(1) { transform: rotate(45deg); }
    .hamburger.active span:nth-child(2) { opacity: 0; }
    .hamburger.active span:nth-child(3) { transform: rotate(-45deg); }
    .tab { padding: 12px; font-size: 1rem; border: 1px solid #ddd;}
    #login-btn { width: 100%; padding: 12px; font-size: 1rem; }
    
    main { padding: 1.5rem 0.8rem; }
    
    .groups-wrapper { grid-template-columns: 1fr; gap: 1.5rem; }
    .group-card { padding: 1.2rem; }
    .group-card h3 { margin-top: -1.2rem; margin-left: -1.2rem; }
    
    .round { min-width: 220px; padding: 0 09px; }
    .matchup-pair::after { width: 12px; right: -12px; }
    .round:not(:first-child) .matchup::before { width: 12px; left: -12px; }
}

/* Indikator Animasi LIVE */
.live-indicator { color: var(--primary); font-weight: 900; display: inline-flex; align-items: center; gap: 8px; font-size: 0.95rem; letter-spacing: 0.5px;}
.live-dot {
  width: 12px; height: 12px; background-color: var(--primary); border-radius: 50%; display: inline-block;
  animation: pulse-glow 1.5s ease-in-out infinite;
}
@keyframes pulse-glow {
  0% { transform: scale(0.9); opacity: 0.7; box-shadow: 0 0 0 0 rgba(212, 27, 44, 0.7); }
  50% { transform: scale(1); opacity: 1; box-shadow: 0 0 12px 6px rgba(212, 27, 44, 0.4); }
  100% { transform: scale(0.9); opacity: 0.7; box-shadow: 0 0 0 0 rgba(212, 27, 44, 0); }
}



#floating-search-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1001;
}

#search-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    transition: transform 0.3s ease;
}

#search-btn:hover { transform: scale(1.1); }

#search-panel {
    position: absolute;
    bottom: 60px;
    right: 0;
    width: 250px;
    background: white;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
}

#search-panel.visible { opacity: 1; visibility: visible; transform: translateY(0); }
#search-input { width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px; }