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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f5f5;
    color: #333;
    display: flex; /* Menggunakan flexbox untuk tata letak utama */
    min-height: 100vh; /* Pastikan body mengambil tinggi penuh viewport */
}

/* Sidebar Styles */
.sidebar {
    width: 250px; /* Lebar default sidebar */
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    overflow-y: auto;
    flex-shrink: 0; /* Mencegah sidebar menyusut */
    display: flex; /* Menggunakan flexbox untuk konten sidebar */
    flex-direction: column; /* Mengatur item secara vertikal */
}

.sidebar h2 {
    margin-bottom: 30px;
    text-align: center;
    font-size: 24px;
}

.sidebar ul {
    list-style: none; /* Hapus bullet point */
    padding: 0;
    margin: 0;
    flex-grow: 1; /* Pastikan daftar menu mengambil ruang yang tersisa */
}

.sidebar ul li {
    margin: 5px 0;
}

.sidebar ul li a {
    display: block;
    color: white;
    text-decoration: none;
    padding: 15px;
    border-radius: 8px;
    transition: 0.3s;
}

.sidebar ul li a:hover,
.sidebar ul li a.active {
    background: rgba(255, 255, 255, 0.2);
    transform: translateX(5px);
}

.sidebar ul li a i {
    margin-right: 10px;
    width: 20px;
}

.sidebar a.logout {
    display: block;
    color: white;
    text-decoration: none;
    padding: 15px;
    margin-top: auto; /* Dorong tombol logout ke bawah */
    border-radius: 8px;
    transition: 0.3s;
    text-align: center;
    background: rgba(255, 255, 255, 0.1); /* Background sedikit berbeda untuk logout */
}

.sidebar a.logout:hover {
    background: rgba(255, 255, 255, 0.3);
}

.sidebar a.logout i {
    margin-right: 10px;
}

/* Main Content Styles */
.main-content {
    flex-grow: 1; /* Konten utama akan mengambil sisa ruang yang tersedia */
    padding: 20px;
    overflow-x: hidden; /* Mencegah overflow horizontal */
}

.header {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.07);
    margin-bottom: 20px;
}

.header h1 {
    font-size: 28px;
    display: flex;
    align-items: center;
}

.header h1 i {
    margin-right: 10px;
} /* Ikon di samping judul */

.content-card {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.07);
    margin-bottom: 20px; /* Tambahkan margin bawah agar tidak terlalu mepet dengan kartu berikutnya */
}

/* Flash Messages */
.flash-messages {
    margin: 1rem auto 20px auto; /* Atur margin agar di tengah dan ada jarak bawah */
    max-width: 900px; /* Lebar maksimal sesuai konten */
    text-align: center; /* Teks di tengah */
}

.alert {
    padding: 12px 20px;
    border-radius: 8px; /* Lebih halus */
    margin-bottom: 10px;
    font-weight: 500;
}

.alert-success {
    background: #e6ffe6; /* Lebih cerah */
    color: #28a745; /* Hijau cerah */
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #ffe6e6; /* Lebih cerah */
    color: #dc3545; /* Merah cerah */
    border: 1px solid #f5c6cb;
}

.alert-info { /* Tambahkan jika ada kategori info */
    background: #e0f7fa;
    color: #17a2b8;
    border: 1px solid #bee5eb;
}

/* Runner Specific Styles */
.runner-header {
    display: grid; /* Menggunakan grid untuk stat-card */
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); /* Kolom responsif */
    gap: 20px; /* Jarak antar stat-card */
    margin-bottom: 20px;
    /* background, shadow sudah di handle content-card */
}

.stat-card {
    background: linear-gradient(45deg, #a1c4fd 0%, #c2e9fb 100%); /* Warna gradien menarik */
    color: #333; /* Warna teks yang kontras */
    padding: 25px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.stat-card:nth-child(2) {
    background: linear-gradient(45deg, #fbc2eb 0%, #a6c1ee 100%);
} /* Warna berbeda */

.stat-card:nth-child(3) {
    background: linear-gradient(45deg, #84fab0 0%, #8fd3f4 100%);
}

.stat-card:nth-child(4) {
    background: linear-gradient(45deg, #ffecd2 0%, #fcb69f 100%);
}

.stat-card:nth-child(5) {
    background: linear-gradient(45deg, #dae2f8 0%, #d6a4a4 100%);
} /* Warna untuk success rate */

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.stat-card h3 {
    font-size: 1.1em;
    margin-bottom: 10px;
    color: #555;
}

.stat-card .stat-num {
    font-size: 2.2em;
    font-weight: 700;
    color: #333;
}

.stat-card .stat-label {
    font-size: 0.98rem;
    color: #888;
}

.section-title {
    font-size: 1.5em; /* Lebih besar dari sebelumnya */
    margin: 2rem 0 1rem 0;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
}

.section-title i {
    margin-right: 10px;
    color: #667eea;
}

.table-responsive {
    overflow-x: auto;
    /* background: #fff; border-radius: 10px; box-shadow: 0 2px 8px #0001; margin-bottom: 2rem; (Ini sudah di handle oleh content-card) */
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px; /* Minimal width untuk tabel di desktop */
}

th,
td {
    padding: 15px; /* Sedikit lebih besar dari sebelumnya */
    border-bottom: 1px solid #eee;
    font-size: 0.95rem; /* Ukuran font standar */
    text-align: left;
}

th {
    background: #f8f8f8;
    color: #555; /* Warna teks yang konsisten */
    font-weight: 600;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover {
    background-color: #f0f0f0;
}

/* Status colors */
.status-pending {
    color: #f39c12;
    font-weight: 600;
} /* Orange */

.status-running {
    color: #3498db;
    font-weight: 600;
} /* Blue */

.status-done {
    color: #27ae60;
    font-weight: 600;
} /* Green */

.status-failed {
    color: #e74c3c;
    font-weight: 600;
} /* Red */

.status-paused {
    color: #7f8c8d;
    font-weight: 600;
} /* Grey */

.btn-action {
    border: none;
    border-radius: 5px; /* Sedikit lebih besar */
    padding: 8px 15px; /* Padding lebih nyaman */
    margin: 4px 2px; /* Margin antar tombol */
    font-size: 0.9rem;
    cursor: pointer;
    color: #fff;
    background: #3498db; /* Default biru */
    transition: background 0.3s ease;
    white-space: nowrap; /* Mencegah tombol putus baris */
}

.btn-action:hover {
    opacity: 0.9;
}

.btn-action.delete {
    background: #dc3545;
} /* Merah */

.btn-action.delete:hover {
    background: #c82333;
}

.btn-action.pause {
    background: #ffc107;
    color: #333;
} /* Kuning gelap, teks gelap */

.btn-action.pause:hover {
    background: #e0a800;
}

.btn-action.resume {
    background: #28a745;
} /* Hijau */

.btn-action.resume:hover {
    background: #218838;
}

.btn-action.log {
    background: #6c757d;
} /* Abu-abu gelap */

.btn-action.log:hover {
    background: #5a6268;
}

.quick-actions {
    margin-top: 30px; /* Jarak dari tabel */
    display: flex;
    flex-wrap: wrap; /* Izinkan wrap di layar kecil */
    gap: 15px; /* Jarak antar tombol */
    justify-content: flex-start; /* Sejajarkan ke kiri */
}

.quick-actions button {
    border: none;
    border-radius: 8px; /* Lebih konsisten dengan form */
    padding: 12px 20px; /* Padding lebih besar */
    font-size: 16px;
    color: #fff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); /* Mirip btn-start */
    cursor: pointer;
    font-weight: 600;
    transition: opacity 0.3s ease;
}

.quick-actions button:hover {
    opacity: 0.9;
}

.quick-actions .delete {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5253 100%);
} /* Merah gradien */

.quick-actions .delete:hover {
    opacity: 0.9;
}

.quick-actions .pause {
    background: linear-gradient(135deg, #ffeb3b 0%, #fbc02d 100%);
    color: #333;
} /* Kuning gradien */

.quick-actions .pause:hover {
    opacity: 0.9;
}

.quick-actions .resume {
    background: linear-gradient(135deg, #4CAF50 0%, #8bc34a 100%);
} /* Hijau gradien */

.quick-actions .resume:hover {
    opacity: 0.9;
}

/* Modal Log Activity */
.activity-log-modal {
    display: none; /* Hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%; /* Gunakan 100% untuk kompatibilitas */
    height: 100%;
    background: rgba(0, 0, 0, 0.4); /* Lebih gelap sedikit */
    z-index: 10000; /* Lebih tinggi dari yang lain */
    display: flex; /* Menggunakan flexbox untuk centering */
    align-items: center;
    justify-content: center;
    padding: 20px; /* Padding agar tidak terlalu mepet di mobile */
    box-sizing: border-box; /* Pastikan padding tidak menambah lebar */
}

.activity-log-content {
    background: #fff;
    border-radius: 12px; /* Lebih halus */
    padding: 25px; /* Lebih nyaman */
    min-width: 350px;
    max-width: 90vw;
    max-height: 85vh; /* Sedikit lebih tinggi */
    overflow-y: auto;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2); /* Bayangan lebih kuat */
    position: relative; /* Untuk posisi tombol close */
}

.activity-log-content h4 {
    margin-top: 0;
    margin-bottom: 20px; /* Jarak bawah */
    font-size: 1.4em;
    color: #333;
}

.activity-log-content table {
    min-width: auto; /* Biarkan tabel responsif */
    font-size: 0.9em;
}

.activity-log-content th,
.activity-log-content td {
    padding: 10px;
}

.activity-log-close {
    background: #dc3545; /* Merah */
    color: #fff;
    border: none;
    border-radius: 50%; /* Bulat */
    width: 30px; /* Ukuran tombol */
    height: 30px;
    line-height: 30px;
    text-align: center;
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 1.5rem; /* Ukuran X */
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: background 0.2s;
}

.activity-log-close:hover {
    background: #c82333;
}

.activity-log-content em {
    display: block;
    text-align: center;
    padding: 20px;
    color: #888;
}

/* MEDIA QUERY UNTUK MOBILE */
@media (max-width: 768px) {
    .sidebar {
        width: 70px; /* Sidebar lebih kecil di mobile */
        padding: 10px;
    }

    .sidebar h2 {
        font-size: 18px; /* Ukuran font lebih kecil */
        margin-bottom: 15px;
    }

    .sidebar ul li a {
        padding: 10px;
        text-align: center; /* Teks di tengah */
    }

    .sidebar ul li a span {
        display: none; /* Sembunyikan teks menu, hanya tampilkan ikon */
    }

    .sidebar ul li a i {
        margin-right: 0; /* Hapus margin kanan ikon */
    }

    .sidebar a.logout {
        padding: 10px;
        text-align: center;
        margin-top: 15px; /* Sesuaikan margin top */
    }

    .sidebar a.logout span {
        display: none; /* Sembunyikan teks logout */
    }

    .sidebar a.logout i {
        margin-right: 0; /* Hapus margin kanan ikon logout */
    }

    .main-content {
        padding: 10px; /* Kurangi padding konten utama */
    }

    .header h1 {
        font-size: 22px; /* Ukuran font lebih kecil di header */
    }

    .runner-header {
        grid-template-columns: 1fr; /* Stat-card menjadi satu kolom di mobile */
    }

    .stat-card {
        padding: 20px;
    }

    .stat-card p {
        font-size: 1.8em;
    }

    .section-title {
        font-size: 1.3em;
    }

    table {
        min-width: 400px; /* Pertahankan minimal width untuk tabel horizontal scroll */
        font-size: 13px;
    }

    th,
    td {
        padding: 10px;
    }

    .btn-action {
        padding: 6px 10px;
        font-size: 12px;
        margin: 2px 1px;
    }

    .quick-actions {
        flex-direction: column; /* Tombol quick actions menumpuk */
        gap: 10px;
    }

    .quick-actions button {
        width: 100%; /* Lebar penuh */
        font-size: 14px;
    }

    .activity-log-content {
        min-width: auto;
        padding: 15px;
    }

    .activity-log-content h4 {
        font-size: 1.2em;
    }

    .activity-log-content table {
        font-size: 0.85em;
    }
}

@media (max-width: 480px) {
    /* Untuk layar yang sangat kecil, sidebar akan menumpuk di atas */
    body {
        flex-direction: column; /* Sidebar di atas konten */
    }

    .sidebar {
        width: 100%; /* Lebar penuh */
        height: auto;
        position: relative; /* Hapus position fixed */
        display: flex; /* Untuk menata item menu secara horizontal */
        flex-direction: row; /* Teks menu horizontal */
        justify-content: space-around;
        padding: 10px 0;
    }

    .sidebar h2 {
        display: none; /* Sembunyikan judul di layar sangat kecil */
    }

    .sidebar ul {
        display: flex;
        flex-grow: 1;
        justify-content: space-around;
    }

    .sidebar ul li {
        flex: 1; /* Setiap item menu akan mengambil ruang yang sama */
        margin: 0 5px;
    }

    .sidebar ul li a {
        padding: 5px; /* Kurangi padding untuk item menu */
    }

    .sidebar ul li a span {
        display: block; /* Tampilkan kembali teks di bawah ikon */
        font-size: 12px;
        margin-top: 5px;
    }

    .sidebar ul li a i {
        display: block; /* Pastikan ikon di atas teks */
    }

    .sidebar a.logout {
        display: none; /* Sembunyikan tombol logout di layar sangat kecil untuk menghemat ruang */
    }

    .main-content {
        padding: 15px;
    }

    .header h1 {
        font-size: 20px;
    }

    .runner-header {
        gap: 15px; /* Kurangi jarak antar stat-card */
    }

    table {
        min-width: 320px; /* Minimal width yang lebih kecil */
    }
}
