/* ==========================================================================
   1. CORE DESIGN SYSTEM (FONTS, COLORS, VARIABLES)
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Brand Colors - Modern Indigo Theme */
    --primary: #4f46e5;       /* Indigo 600 */
    --primary-hover: #4338ca; /* Indigo 700 */
    --danger: #ef4444;        /* Red 500 */
    --danger-hover: #dc2626;  /* Red 600 */
    --success: #10b981;       /* Emerald 500 */
    
    /* Backgrounds */
    --bg-body: #f8fafc;       /* Slate 50 */
    --bg-surface: #ffffff;
    --bg-header: #1e293b;     /* Slate 800 */
    
    /* Typography Colors */
    --text-main: #0f172a;     /* Slate 900 */
    --text-muted: #64748b;    /* Slate 500 */
    --text-light: #94a3b8;    /* Slate 400 */
    
    /* Borders & Shadows */
    --border-color: #e2e8f0;  /* Slate 200 */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    
    /* Elevation */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

/* Base Reset */
body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    padding-bottom: 3rem;
}

/* Animation */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.container, .container-fluid {
    animation: fadeIn 0.4s ease-out;
}

/* ==========================================================================
   2. NAVBAR
   ========================================================================== */
.navbar {
    background-color: var(--bg-header) !important;
    box-shadow: var(--shadow-md);
    padding: 0.75rem 0;
    margin-bottom: 2rem;
}

.navbar-brand {
    font-weight: 700;
    letter-spacing: -0.5px;
    font-size: 1.1rem;
    color: #ffffff !important;
}

/* ==========================================================================
   3. FILTER BAR (INDEX PAGE) - Fixed Layout
   ========================================================================== */
.filter-bar {
    background: var(--bg-surface);
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.filter-bar .input-group-text {
    background-color: #f1f5f9;
    border-color: var(--border-color);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
}

.filter-bar .form-control, .filter-bar .form-select {
    border-color: var(--border-color);
    font-size: 0.9rem;
    font-weight: 500;
}

.filter-bar .btn-group .btn {
    display: flex;
    align-items: center;
    gap: 6px;
    border-radius: var(--radius-sm);
    margin: 0 2px;
}

/* ==========================================================================
   4. MANAGEMENT TABLE (THE CORE REQUEST)
   ========================================================================== */
/* Card Container Table */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden; /* Penting untuk radius */
}

.card-header {
    background-color: #fff;
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem;
}

/* Table Layout Fixes */
.table-responsive {
    overflow-x: auto;
}

.table {
    margin-bottom: 0;
    width: 100%;
    vertical-align: middle;
}

/* Header Table Styling */
.table thead th {
    background-color: #f8fafc;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

/* Body Cell Styling */
.table tbody td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 0.9rem;
    vertical-align: middle !important; /* Pastikan selalu di tengah vertikal */
}

/* --- KOLOM SPESIFIK (AGAR RAPI) --- */

/* 1. Kolom Task & Desc (Lebar Fleksibel tapi Terkontrol) */
.table td:first-child {
    min-width: 280px;
    max-width: 450px;
    white-space: normal !important; /* Izinkan text wrap */
}

.table td .fw-bold {
    color: var(--primary);
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
    display: block;
    line-height: 1.3;
}

.table td .text-muted {
    font-size: 0.8rem;
    color: #64748b !important;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Batasi deskripsi max 2 baris */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 2. Kolom Atribut (Kategori, Status, dll) - Tengah & Rapi */
.table td:nth-child(2), /* Kategori */
.table td:nth-child(3), /* Prioritas */
.table td:nth-child(4), /* Status */
.table td:nth-child(5), /* Impact */
.table td:nth-child(6), /* PIC */
.table td:nth-child(7)  /* Deadline */
{
    white-space: nowrap; /* Jangan turun baris */
}

/* 3. Kolom Action (Tombol Edit/Hapus) - SOLUSI BERTUMPUK */
.table td:last-child {
    white-space: nowrap;
    width: 1%; /* Shrink to fit content */
    text-align: right;
}

/* Container untuk tombol action agar sejajar */
.table td:last-child .d-flex-action { 
    /* Anda mungkin perlu menambahkan div wrapper di PHP, 
       tapi ini cara CSS menanganinya jika tombol langsung di dalam TD */
    display: inline-flex; 
    gap: 8px;
    align-items: center;
}

/* Override gaya tombol di dalam tabel agar kecil & rapi */
.table .btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    height: 32px; /* Paksa tinggi seragam */
}

/* Tombol Edit */
.table .btn-outline-primary {
    color: var(--primary);
    border-color: #e0e7ff;
    background: #eef2ff;
}
.table .btn-outline-primary:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Tombol Hapus */
.table .btn-outline-danger {
    color: var(--danger);
    border-color: #fee2e2;
    background: #fef2f2;
}
.table .btn-outline-danger:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

/* ==========================================================================
   5. BADGES (Status & Priority Pills)
   ========================================================================== */
.badge {
    padding: 0.4em 0.8em;
    font-weight: 600;
    font-size: 0.7rem;
    border-radius: 20px; /* Pill shape */
    letter-spacing: 0.3px;
    border: 1px solid transparent;
}

/* Kategori Badge (Kotak tumpul) */
.badge-category {
    background-color: #f1f5f9;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-radius: 6px; /* Kotak */
    font-weight: 500;
}

/* Priority Colors */
.priority-high { color: var(--danger); background: #fef2f2; border-color: #fee2e2; }
.priority-med  { color: #d97706; background: #fffbeb; border-color: #fde68a; }
.priority-low  { color: var(--text-muted); background: #f1f5f9; border-color: #e2e8f0; }

/* Status Colors */
.bg-secondary { background: #f1f5f9 !important; color: var(--text-muted); border: 1px solid #e2e8f0; } /* To Do */
.bg-primary   { background: #e0e7ff !important; color: var(--primary); border: 1px solid #c7d2fe; } /* In Progress */
.bg-success   { background: #dcfce7 !important; color: var(--success); border: 1px solid #86efac; } /* Done */

/* ==========================================================================
   6. FORMS (INPUT EDIT/CREATE)
   ========================================================================== */
.form-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.form-control, .form-select {
    display: block;
    width: 100%;
    padding: 0.65rem 1rem;
    font-size: 0.95rem;
    color: var(--text-main);
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1); /* Glow Indigo */
    outline: none;
}

/* Tombol Submit Besar */
.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
}
/* ==========================================================================
   9. MOBILE RESPONSIVE (THE ULTIMATE MOBILE FIX)
   ========================================================================== */
@media (max-width: 768px) {

    /* --- A. LAYOUT UMUM --- */
    .container, .container-fluid {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    .navbar-brand {
        font-size: 1rem; /* Perkecil font logo */
    }

    /* --- B. FILTER BAR (INDEX.PHP) --- */
    /* Agar filter bar tidak berantakan di HP */
    .filter-bar .row {
        gap: 0.5rem; /* Jarak antar elemen vertikal */
    }
    
    .filter-bar .input-group {
        width: 100% !important; /* Input lebar penuh */
        margin-bottom: 0.5rem;
    }
    
    .filter-bar .btn {
        width: 100%; /* Tombol lebar penuh */
        justify-content: center;
    }
    
    .filter-bar .badge {
        display: block;
        width: 100%;
        margin: 0.5rem 0;
    }

    /* --- C. TABEL TRANSFORMASI MENJADI KARTU (CARD VIEW) --- */
    /* Sembunyikan Header Tabel karena kita pakai Label manual */
    .table thead {
        display: none;
    }

    /* Ubah Baris (TR) menjadi Kartu */
    .table tbody tr {
        display: block;
        background: #fff;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        margin-bottom: 1rem;
        box-shadow: var(--shadow-sm);
        padding: 1.25rem;
        position: relative;
    }

    /* Ubah Sel (TD) menjadi Baris Flex */
    .table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 0;
        border-bottom: 1px solid #f1f5f9;
        text-align: right;
        font-size: 0.9rem;
        white-space: normal !important; /* Izinkan text wrap di HP */
    }

    /* Hapus garis bawah pada elemen terakhir */
    .table tbody td:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }

    /* --- D. LABEL OTOMATIS DI SEBELAH KIRI (PSEUDO-ELEMENTS) --- */
    /* Ini membuat teks "STATUS:", "PIC:", dll muncul otomatis */
    .table tbody td::before {
        content: attr(data-label); /* Fallback */
        font-weight: 700;
        font-size: 0.7rem;
        text-transform: uppercase;
        color: var(--text-muted);
        text-align: left;
        margin-right: auto; /* Dorong isi ke kanan */
        padding-right: 1rem;
    }

    /* --- E. SPESIFIK UNTUK MANAGE_TASK.PHP (Admin) --- */
    /* Mapping Label Kolom Sesuai Urutan di PHP */
    
    /* Kolom 1: Task & Desc (Tampilan Judul Besar) */
    .table tbody td:first-child {
        display: block;
        text-align: left;
        border-bottom: none;
        padding-top: 0;
        margin-bottom: 0.5rem;
    }
    .table tbody td:first-child::before { display: none; } /* Hapus label untuk judul */
    .table tbody td:first-child .fw-bold { 
        font-size: 1.1rem; 
        color: var(--primary);
        margin-bottom: 0.25rem;
    }
    .table tbody td:first-child .text-muted {
        font-size: 0.85rem;
        display: block; /* Tampilkan deskripsi full */
        -webkit-line-clamp: unset; /* Matikan pemotong teks */
    }

    /* Kolom 2: Kategori */
    .table tbody td:nth-of-type(2)::before { content: "Kategori"; }
    
    /* Kolom 3: Prioritas */
    .table tbody td:nth-of-type(3)::before { content: "Prioritas"; }
    
    /* Kolom 4: Status */
    .table tbody td:nth-of-type(4)::before { content: "Status"; }
    
    /* Kolom 5: Impact */
    .table tbody td:nth-of-type(5)::before { content: "Impact"; }
    
    /* Kolom 6: PIC */
    .table tbody td:nth-of-type(6)::before { content: "PIC"; }
    
    /* Kolom 7: Deadline */
    .table tbody td:nth-of-type(7)::before { content: "Deadline"; }
    
    /* Kolom 8: Action (Tombol) */
    .table tbody td:last-child {
        display: flex;
        gap: 0.5rem;
        justify-content: flex-end; /* Tombol rata kanan */
        padding-top: 1rem;
        border-top: 1px dashed var(--border-color); /* Garis pemisah */
    }
    .table tbody td:last-child::before { display: none; } /* Hapus label action */
    
    /* Tombol Action di HP lebih besar biar gampang dipencet */
    .table .btn-sm {
        padding: 0.5rem 1rem; 
        font-size: 0.85rem;
        height: auto;
    }

    /* --- F. SPESIFIK UNTUK INDEX.PHP (Monitoring) --- */
    /* Karena urutan kolom di index.php berbeda, kita override labelnya */
    
    /* Gunakan class khusus .table-master yang ada di index.php */
    .table-master tbody td:nth-of-type(1)::before { content: "Prioritas"; }
    
    .table-master tbody td:nth-of-type(2) { /* Judul Task */
        display: block; 
        text-align: left;
        border-bottom: none;
    }
    .table-master tbody td:nth-of-type(2)::before { display: none; }
    
    .table-master tbody td:nth-of-type(3)::before { content: "Detail"; }
    .table-master tbody td:nth-of-type(4)::before { content: "Status"; }
    .table-master tbody td:nth-of-type(5)::before { content: "Kategori"; }
    .table-master tbody td:nth-of-type(6)::before { content: "Dampak"; }
    .table-master tbody td:nth-of-type(7)::before { content: "PIC"; }
    .table-master tbody td:nth-of-type(8)::before { content: "Deadline"; }
}