/* style.css */

/* --- Global & Modern Reset --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box; /* Ini SANGAT penting untuk layout */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f8f9fa; /* Warna abu-abu yang lebih cerah */
    color: #333;
    line-height: 1.6;
    padding: 10px; /* Padding untuk mobile */
}

h2 {
    margin-bottom: 20px;
    color: #212529;
}

/* --- Layout Container Utama --- */
.container {
    width: 100%;
    max-width: 1100px; /* Lebar maksimum di desktop */
    margin: 10px auto;
    background: #ffffff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* --- Navigasi --- */
nav {
    margin-bottom: 25px;
    display: flex;
    flex-wrap: wrap; /* Tombol akan turun ke bawah di mobile */
    gap: 10px; /* Jarak antar tombol */
}
nav a {
    text-decoration: none;
    padding: 10px 15px;
    background: #6c757d;
    color: white;
    border-radius: 8px;
    font-weight: 500;
    transition: background-color 0.2s ease;
    flex-grow: 1; /* Biarkan tombol membesar di mobile */
    text-align: center;
}
nav a:hover {
    background-color: #5a6268;
}
nav a.input { background-color: #28a745; }
nav a.input:hover { background-color: #218838; }
nav a.active { background-color: #007bff; }
nav a.active:hover { background-color: #0069d9; }

/* --- Dashboard Summary Cards --- */
.summary {
    display: grid;
    /* Ini adalah magic-nya: 
       - auto-fit: Isi kolom sebanyak mungkin
       - minmax: Setiap kolom minimal 200px, tapi boleh membesar (1fr)
       Di mobile, ini akan otomatis jadi 1 kolom. Di tablet/desktop jadi 2-5 kolom.
    */
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}
.card {
    background: #f1f3f5;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
}
.card h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.1rem;
    color: #495057;
}
.card p {
    font-size: 1.5rem;
    font-weight: bold;
    margin: 5px 0;
}
.card.stok {
    background: #e6f7ff;
    border: 1px solid #b3e0ff;
}
.card.stok p { color: #0056b3; }
.profit { color: #28a745; }
.loss { color: #dc3545; }

/* --- Styling Form (input_data.php) --- */
.form-group {
    margin-bottom: 15px;
}
.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}
.form-group input[type="text"],
.form-group input[type="number"],
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ced4da;
    border-radius: 8px;
    font-size: 1rem;
}
button[type="submit"] {
    width: 100%;
    background-color: #007BFF;
    color: white;
    padding: 12px 15px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    transition: background-color 0.2s ease;
}
button[type="submit"]:hover {
    background-color: #0056b3;
}
.pesan {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}
.pesan.error {
    background: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

/* --- STYLING TABEL YANG RESPONSIVE --- */
.table-wrapper {
    overflow-x: auto; /* Fallback jika ada tabel yg aneh, bisa di-scroll horizontal */
}
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}
th, td {
    padding: 12px 15px;
    border: 1px solid #dee2e6;
    text-align: left;
}
th {
    background-color: #f8f9fa;
}
/* Pewarnaan Tipe */
.tipe-masuk { color: #28a745; font-weight: 500; }
.tipe-modal { color: #dc3545; font-weight: 500; }
.tipe-operasional { color: #fd7e14; font-weight: 500; }


/* --- GANTI BLOK @media LAMA ANDA DENGAN INI --- */

@media (max-width: 768px) {
    body {
        padding: 5px;
    }
    .container {
        padding: 15px;
        box-shadow: none;
    }
    nav a {
        font-size: 0.9rem;
    }

    /* --- GAYA KARTU BARU UNTUK TABEL --- */
    
    .table-wrapper {
        /* Hapus scroll horizontal jika ada */
        overflow-x: hidden; 
    }

    /* Sembunyikan header tabel di mobile */
    table thead {
        display: none;
    }
    
    /* Ubah setiap baris (tr) menjadi kartu */
    table tr {
        display: block; /* Tumpuk kartu ke bawah */
        border: 1px solid #dee2e6;
        border-radius: 8px;
        margin-bottom: 15px;
        background: #ffffff;
        box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    }
    
    /* Sel (td) sekarang menumpuk di dalam kartu */
    table td {
        display: block; /* Tumpuk data di dalam kartu */
        border: none;
        border-bottom: 1px solid #f0f0f0; /* Garis pemisah tipis */
        padding: 12px 15px;
        text-align: left; /* Rata kiri semua */
    }

    /* Sel terakhir di kartu tidak perlu garis pemisah */
    table tr td:last-child {
        border-bottom: 0;
    }
    
    /* Ini adalah "Label" yang kita ambil dari data-label */
    table td:before {
        content: attr(data-label); /* Ambil teks label */
        display: block;
        font-weight: 600;      /* Labelnya bold */
        font-size: 0.8rem;     /* Label lebih kecil */
        color: #6c757d;      /* Label warna abu-abu */
        text-transform: uppercase;
        margin-bottom: 5px;
        
        /* Hapus semua style lama */
        position: static;
        padding: 0;
        width: auto;
    }
    
    /* Beri style khusus pada nilainya (bukan labelnya) */
    table td[data-label="Qty (Barang)"],
    table td[data-label="Jumlah (Rp)"] {
        font-size: 1.1rem;
        font-weight: 500;
    }
    
    /* Khusus untuk Keterangan, buat lebih kecil */
    table td[data-label="Keterangan"] {
        font-size: 0.95rem;
        color: #333;
    }
}
/* Styling untuk Grup Radio Button */
.radio-group {
    display: flex;
    flex-direction: column; /* Tumpuk ke bawah di mobile */
    gap: 10px;
    border: 1px solid #ced4da;
    border-radius: 8px;
    padding: 10px;
}
.radio-option {
    display: flex;
    align-items: center;
    padding: 10px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}
.radio-option:hover {
    background-color: #f8f9fa;
}
.radio-option input[type="radio"] {
    margin-right: 12px;
    /* Memberi ukuran yang lebih besar agar mudah disentuh */
    width: 1.2em;
    height: 1.2em;
}
.radio-option label {
    margin-bottom: 0; /* Override style label global */
    font-weight: 500;
}

/* Di layar lebih besar, buat jadi 3 kolom */
@media (min-width: 600px) {
    .radio-group {
        flex-direction: row; /* Berjejer ke samping */
    }
    .radio-option {
        flex: 1; /* Bagi rata lebarnya */
        justify-content: center;
    }
}
/* --- Tambahkan ini di AKHIR file style.css --- */

.main-footer {
    text-align: center;
    padding: 20px 0;
    margin-top: 20px;
    color: #868e96; /* Warna abu-abu */
    font-size: 0.9rem;
}
.main-footer strong {
    color: #495057; /* Warna abu-abu lebih gelap */
}
/* Tambahkan di akhir style.css */
.product-list {
    max-height: 250px;
    overflow-y: auto;
}
.radio-option.product {
    flex: 1 1 100%; /* Buat 1 baris 1 produk agar jelas */
}
.radio-option.product label {
    display: flex;
    justify-content: space-between;
    width: 100%;
}
.radio-option.product small {
    color: #007bff;
    font-weight: bold;
}
/* --- Tambahkan ini di AKHIR file style.css --- */

/* Tombol Aksi di dalam Tabel */
.btn-aksi {
    display: inline-block;
    padding: 6px 12px;
    margin: 2px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    color: white;
}
.btn-edit {
    background-color: #007bff;
}
.btn-edit:hover {
    background-color: #0069d9;
}
.btn-hapus {
    background-color: #dc3545;
}
.btn-hapus:hover {
    background-color: #c82333;
}

/* Tombol Disabled (untuk Hapus saat stok > 0) */
.btn-disabled {
    background-color: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Tombol Batal (di Form Edit) */
.btn-batal {
    display: inline-block;
    padding: 12px 15px;
    background-color: #6c757d;
    color: white;
    border-radius: 8px;
    text-decoration: none;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 10px;
}
.btn-batal:hover {
    background-color: #5a6268;
}

/* Di mobile, buat tombol Batal jadi 100% */
@media (max-width: 768px) {
    .btn-batal {
        width: 100%;
    }
}