/* === Palet Warna & Font Kustom === */
:root {
    --color-primary: #1e3a8a;
    /* Biru Tua */
    --color-secondary: #fcd34d;
    /* Kuning */
    --color-light-bg: #f9fafb;
    --color-text: #374151;
    --color-white: #ffffff;
    --font-heading: 'Poppins', sans-serif;
    --font-body: 'Inter', sans-serif;
}

/* === Style Dasar Halaman === */
body {
    background-color: var(--color-light-bg) !important;
    color: var(--color-text);
    font-family: var(--font-body);
    padding-bottom: 70px;
}

h1,
h3,
h5 {
    font-family: var(--font-heading);
    color: var(--color-primary);
}

.text-primary {
    color: var(--color-primary) !important;
}

.btn-primary {
    background-color: var(--color-primary);
    color: var(--color-white);
}

.btn-primary:hover {
    background-color: #1e40af;
}

/* STYLE KHUSUS: Button Warning (Kuning/Secondary) */
.btn-warning {
    background-color: var(--color-secondary);
    border-color: var(--color-secondary);
    color: var(--color-primary);
    font-weight: 600;
}

.btn-warning:hover {
    background-color: #f5b72e;
    border-color: #f5b72e;
    color: var(--color-primary);
}

/* STYLE KHUSUS: Button Success (Hijau untuk Sertifikat) */
.btn-success {
    background-color: #047857;
    border-color: #047857;
    color: var(--color-white);
    font-weight: 600;
}

.btn-success:hover {
    background-color: #065f46;
    border-color: #065f46;
    color: var(--color-white);
}

/* === STYLE KHUSUS: Badge Juara (UI/UX) === */
.badge-winner-emas {
    background-color: #ffd700;
    /* Emas */
    color: #5d4a00;
    font-weight: 700;
}

.badge-winner-perak {
    background-color: #c0c0c0;
    /* Perak */
    color: #3b3b3b;
    font-weight: 700;
}

.badge-winner-perunggu {
    background-color: #cd7f32;
    /* Perunggu */
    color: #5a3915;
    font-weight: 700;
}

.badge-winner-harapan {
    background-color: var(--color-primary);
    /* Biru Primary */
    color: var(--color-white);
    font-weight: 700;
}

/* AKHIR STYLE KHUSUS BADGE */

/* === BARU: Style untuk Baris Juara di Tabel === */
.table-winner-emas {
    background-color: #fffbe6 !important;
    /* Kuning muda/krem */
    border-left: 5px solid #ffd700 !important;
    /* Emas */
}

.table-winner-perak {
    background-color: #f8f9fa !important;
    /* Abu-abu sangat muda */
    border-left: 5px solid #c0c0c0 !important;
    /* Perak */
}

.table-winner-perunggu {
    background-color: #f7f3f1 !important;
    /* Coklat muda/hangat */
    border-left: 5px solid #cd7f32 !important;
    /* Perunggu */
}

.table-winner-harapan {
    background-color: #eef4ff !important;
    /* Biru muda */
    border-left: 5px solid var(--color-primary) !important;
    /* Primary Blue */
}

/* Styling Khusus Konten Deskripsi dari Database */
.description-content {
    line-height: 1.8;
    color: #4b5563;
    font-size: 1.05rem;
    word-wrap: break-word;
}

/* Merapikan Paragraf */
.description-content p {
    margin-bottom: 1.25rem;
}

/* Memperbaiki List/Daftar (Sering tidak muncul bullet/angkanya) */
.description-content ul, 
.description-content ol {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
}

.description-content ul {
    list-style-type: disc !important;
}

.description-content ol {
    list-style-type: decimal !important;
}

.description-content li {
    margin-bottom: 0.5rem;
    display: list-item; /* Memastikan marker muncul */
}

/* Menangani Judul di dalam Deskripsi */
.description-content h1, 
.description-content h2, 
.description-content h3, 
.description-content h4 {
    color: #1e3a8a;
    font-weight: 700;
    margin-top: 1.8rem;
    margin-bottom: 1rem;
    line-height: 1.3;
}

/* Memastikan Gambar Responsif */
.description-content img {
    max-width: 100%;
    height: auto !important;
    border-radius: 8px;
    margin: 1.5rem 0;
    display: block;
}

/* Merapikan Tabel jika user memasukkan tabel ke deskripsi */
.description-content table {
    width: 100% !important;
    margin-bottom: 1.5rem;
    border-collapse: collapse;
    overflow-x: auto;
    display: block; /* Membuat tabel bisa scroll di mobile */
}

.description-content table td, 
.description-content table th {
    border: 1px solid #e5e7eb;
    padding: 12px;
}

/* Merapikan Link */
.description-content a {
    color: #1e3a8a;
    text-decoration: underline;
    transition: opacity 0.2s;
}

.description-content a:hover {
    opacity: 0.8;
}

/* Penyesuaian Mobile */
@media (max-width: 768px) {
    .description-content {
        font-size: 0.95rem;
        line-height: 1.7;
    }
}

/* BARU: Style untuk Judul Tabel Juara (di atas setiap tabel) */
.winner-table-title {
    background-color: var(--color-primary);
    color: var(--color-white);
    padding: 0.75rem 1rem;
    margin-top: 1.5rem;
    margin-bottom: 0;
    border-radius: 0.5rem 0.5rem 0 0;
    font-weight: 700;
    font-size: 1.1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.winner-table-container {
    margin-bottom: 2rem;
}

/* === Style Navbar Kustom (Desktop & Mobile) === */
.navbar-logo {
    height: 40px;
}

/* Tab Navigation (Desktop) */
.nav-tabs {
    border-bottom: 2px solid #e5e7eb;
}

.nav-tabs .nav-link {
    border: none;
    color: var(--color-text);
    font-weight: 500;
    padding: 1rem 1.5rem;
    transition: color 0.2s, border-bottom-color 0.2s;
}

.nav-tabs .nav-link.active {
    color: var(--color-primary);
    border-bottom: 3px solid var(--color-primary);
    background-color: transparent;
    font-weight: 600;
}

/* DataTables Styling */
.dataTables_wrapper {
    font-size: 0.9rem;
}

.table-rounded {
    border-radius: 0.5rem;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}

.table-rounded thead th {
    background-color: var(--color-primary);
    color: var(--color-white);
    font-weight: 600;
    white-space: nowrap;
}

/* PERBAIKAN: Style untuk input pencarian DataTables */
.dataTables_filter input {
    border: 2px solid var(--color-primary) !important;
    border-radius: 0.5rem !important;
    padding: 0.5rem 0.75rem !important;
    box-shadow: none !important;
}

.dataTables_filter input:focus {
    box-shadow: 0 0 0 0.25rem rgba(30, 58, 138, 0.25) !important;
    border-color: var(--color-primary) !important;
}

/* Tambahan style untuk judul card E-Sertifikat */
.e-certificate-title {
    background-color: var(--color-primary);
    color: var(--color-white);
    padding: 0.5rem 1rem;
    margin: -1rem -1rem 1rem -1rem;
    border-radius: 0.25rem 0.25rem 0 0;
    text-align: center;
}

/* === Penyesuaian UI/UX Filter DataTables === */
.dataTables_wrapper .row:first-child {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    margin-bottom: 15px;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* Penempatan Length (Tampilkan X data) */
.dataTables_length {
    margin-bottom: 0px !important;
    display: flex !important;
    align-items: center;
    gap: 5px;
}

/* Kontrol Label dan Input Search Bawaan DataTables */
.dataTables_filter {
    margin-bottom: 0px !important;
    display: flex !important;
    align-items: center;
    gap: 15px;
    justify-content: flex-end;
}

.dataTables_filter label {
    margin-bottom: 0 !important;
    display: flex;
    align-items: center;
    gap: 5px;
    flex-grow: 0;
    white-space: nowrap;
}

/* Search Input Bawaan DataTables */
.dataTables_filter label input {
    width: 180px !important;
}

/* === CUSTOM DT-CONTROL STYLING (Untuk Tabel Peserta yang Dikelompokkan) === */

/* Gaya Baris Detail Terbuka */
table.dataTable tbody tr.dt-shading>.dt-control,
table.dataTable tbody tr.dt-shading>.dt-control i {
    background-color: #e6e6fa;
}

/* Gaya Tombol Detail (+) */
table.dataTable td.dt-control {
    text-align: center;
    cursor: pointer;
    width: 30px;
}

/* Style untuk judul detail lomba (di dalam format(d)) */
.detail-title-wrapper {
    background-color: var(--color-primary);
    padding: 0.5rem 1rem;
    margin: -0.75rem -1rem 1rem -1rem;
    border-radius: 0.25rem 0.25rem 0 0;
}

.detail-title-wrapper h6 {
    color: var(--color-white) !important;
    margin-bottom: 0 !important;
}

/* Akhir Custom DT-Control Styling */

/* ========================================================= */

/* === KODE LAINNYA (Poster, Timeline, Navbar Mobile) === */

/* PERBAIKAN UTAMA #1: Memberi Batas yang Jelas pada Kontainer Utama */
.poster-container,
.main-content-card {
    border: 1px solid #e5e7eb !important;
    /* Batas abu-abu terang */
    border-radius: 0.5rem;
    /* Pastikan padding card body tetap 1.5rem untuk ruang bernapas */
}

/* PERBAIKAN UTAMA #2: Penambahan Batas pada Action Button Container */
.action-buttons-container {
    border-top: 1px solid #e5e7eb;
    /* Garis pemisah di atas tombol aksi */
    padding-top: 1.5rem;
    margin-top: 1.5rem;
}

/* PERBAIKAN UTAMA #3: Penanda Visual pada Card E-Sertifikat */
.participant-action-container .card {
    border-left: 5px solid var(--color-primary) !important;
    /* Batas tebal biru di kiri */
}

/* PERBAIKAN: Aturan Poster Container Default (Mobile) */
.poster-container {
    display: flex;
    align-items: center;
    justify-content: center;
}

.poster-image {
    width: 100%;
    height: auto;
    max-width: 450px;
    object-fit: contain;
    border-radius: 0.75rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
}

.timeline {
    border-left: 3px solid var(--color-primary);
    padding-left: 20px;
    position: relative;
    min-height: 200px;
}

.timeline-item-detail {
    margin-bottom: 1.5rem;
    position: relative;
}

.timeline-item-detail::before {
    content: '';
    position: absolute;
    left: -28px;
    top: 5px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background-color: var(--color-primary);
    border: 3px solid var(--color-white);
    box-shadow: 0 0 0 3px var(--color-primary);
}

.timeline-date {
    font-weight: 600;
    color: var(--color-primary);
}

.navbar-bottom-mobile {
    box-shadow: 0 -5px 10px rgba(0, 0, 0, 0.05);
    align-items: center;
    height: 60px;
}

.navbar-bottom-mobile .nav-link-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    padding: 0 5px;
    color: #6c757d;
    transition: color 0.2s;
    text-decoration: none;
    font-weight: 500;
}

.navbar-bottom-mobile .nav-link-item i {
    margin-bottom: 2px;
    font-size: 1.2rem;
}

.navbar-bottom-mobile .nav-link-item.active {
    color: var(--color-primary) !important;
    font-weight: 600;
}

.navbar-bottom-mobile small {
    font-size: 10px;
}

/* === Media Query Mobile (Lebar < 992px) === */
@media (max-width: 991px) {

    .dataTables_wrapper .row:first-child>div:first-child,
    .dataTables_wrapper .row:first-child>div:last-child {
        width: 100%;
    }

    .dataTables_length {
        margin-bottom: 10px !important;
        justify-content: flex-start !important;
    }

    .dataTables_filter {
        width: 100% !important;
        justify-content: flex-start;
        gap: 5px;
    }

    .dataTables_filter label {
        width: 100%;
    }

    .dataTables_filter label .d-md-block {
        display: none !important;
    }

    .dataTables_filter label input {
        width: 100% !important;
    }

    .navbar-top-desktop {
        display: none !important;
    }

    .navbar-bottom-mobile {
        display: flex !important;
    }

    .pb-mobile-safe {
        padding-bottom: 70px !important;
    }

    .nav-tabs-desktop-only {
        display: none !important;
    }

    .poster-container {
        margin-bottom: 1.5rem;
    }

    .poster-image {
        max-width: 80%;
        max-height: 400px;
        width: auto;
    }

    .timeline {
        min-height: auto;
    }

    .col-lg-3,
    .col-lg-9 {
        width: 100%;
        max-width: 100%;
    }
}

/* === Media Query Desktop (Lebar >= 992px) === */
@media (min-width: 992px) {

    /* Fix Navbar Mobile disembunyikan di Desktop */
    .navbar-bottom-mobile {
        display: none !important;
    }

    .navbar-top-desktop {
        display: flex !important;
    }

    .main-content-card {
        min-height: 80vh;
    }

    /* Terapkan style tinggi poster HANYA di Desktop */
    .poster-container {
        min-height: 80vh;
        align-items: flex-start;
    }
}