@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;800&family=Montserrat:wght@300;400;600&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Palette Emas Mewah */
    --gold: #D4AF37;
    --gold-light: #F7E7CE;
    --gold-dim: #8a6e1e;
    --gold-gradient: linear-gradient(135deg, #D4AF37 0%, #F9E79F 50%, #B7950B 100%);
    --gold-shadow: rgba(212, 175, 55, 0.4);

    /* Palette Hitam Elegan */
    --black: #000000;
    --dark-bg: #0a0a0a;
    --dark-card: #141414;
    --dark-input: #1f1f1f;
    --border-dim: rgba(255, 255, 255, 0.1);

    /* Typography & Text */
    --font-heading: 'Cinzel', serif;
    --font-body: 'Montserrat', sans-serif;
    --text-main: #e0e0e0;
    --text-muted: #888888;
    --text-on-gold: #1a1a1a;

    /* UI Elements */
    --radius: 12px;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

body {
    font-family: var(--font-body);
    background-color: var(--black);
    background-image: 
        radial-gradient(circle at 50% 0%, #1a1a1a 0%, transparent 70%),
        radial-gradient(circle at 80% 80%, #151515 0%, transparent 50%);
    min-height: 100vh;
    padding: 20px;
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* Scrollbar Mewah */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--black); }
::-webkit-scrollbar-thumb { background: var(--gold-dim); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold); }

/* =========================
   OFFLINE STATUS
========================= */
.status-offline {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #721c24;
    color: #fff;
    padding: 8px 20px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.85rem;
    z-index: 1001;
    border: 1px solid #f5c6cb;
    box-shadow: 0 0 15px rgba(220, 53, 69, 0.5);
    font-family: var(--font-body);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* =========================
   MAIN CONTAINER
========================= */
.container {
    width: 100%;
    max-width: 950px;
    margin: 20px auto;
    background: rgba(20, 20, 20, 0.85);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--gold-dim);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 
        0 20px 50px rgba(0, 0, 0, 0.8),
        0 0 0 1px rgba(212, 175, 55, 0.15);
    animation: fadeInContainer 0.8s ease-out;
}

@keyframes fadeInContainer {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================
   HEADER
========================= */
header {
    background: linear-gradient(180deg, #0f0f0f 0%, #1a1a1a 100%);
    color: var(--gold);
    padding: 40px 30px;
    text-align: center;
    border-bottom: 2px solid var(--gold-dim);
    position: relative;
}

header::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--gold-gradient);
    box-shadow: 0 0 10px var(--gold);
}

header h1 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    letter-spacing: 2px;
    font-weight: 800;
    text-transform: uppercase;
    background: var(--gold-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 2px 20px rgba(212, 175, 55, 0.2);
}

/* =========================
   TAB NAVIGATION
========================= */
.main-content .tab-nav {
    display: flex;
    background: #000;
    border-bottom: 1px solid var(--border-dim);
}

.tab-btn {
    flex: 1;
    padding: 22px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    color: var(--gold-light);
    background: rgba(212, 175, 55, 0.05);
}

.tab-btn.active {
    color: var(--gold);
    background: linear-gradient(180deg, rgba(212,175,55,0.08), transparent);
    border-bottom-color: var(--gold);
    text-shadow: 0 0 8px rgba(212, 175, 55, 0.4);
}

/* =========================
   TAB CONTENT
========================= */
.tab-content {
    display: none;
    padding: 40px;
    background: var(--dark-bg);
}

.tab-content.active {
    display: block;
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================
   FORM ELEMENTS
========================= */
.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 12px;
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--gold);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.form-control, 
input[type="text"], 
input[type="number"], 
input[type="password"], 
input[type="date"] {
    width: 100%;
    padding: 16px 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border-dim);
    background: var(--dark-input);
    color: var(--text-main);
    font-size: 1.1rem;
    font-family: var(--font-body);
    transition: var(--transition);
}

.form-control:focus,
input:focus {
    outline: none;
    border-color: var(--gold);
    background: #252525;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.15);
}

./* INPUT HARGA (RUPIAH) - RATA KIRI (SEPERTI YANG DIMINTA) */
.input-rupiah {
    text-align: left;  /* 🔥 DIUBAH DARI right KE left */
    font-weight: 600;
    color: var(--gold-light);
    font-family: 'Courier New', monospace;
}

/* INPUT BERAT (GRAM) - TETAP RATA KANAN (BIAR RAPI) */
.input-gram {
    text-align: right;
    font-weight: 600;
    color: var(--gold-light);
    font-family: 'Courier New', monospace;
}

select.form-control, select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23D4AF37' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 18px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    margin-bottom: 30px;
}

/* =========================
   TOTAL DISPLAY
========================= */
.total-display {
    width: 100%;
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 25px;
    border-radius: var(--radius);
    background: linear-gradient(90deg, rgba(20,20,20,1) 0%, rgba(30,30,30,1) 100%);
    border: 1px solid var(--gold-dim);
    margin-bottom: 30px;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
}

.total-display span:first-child {
    color: var(--text-muted);
    font-family: var(--font-heading);
    font-size: 1.1rem;
    text-transform: uppercase;
}

.total-display span:last-child {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    color: var(--gold);
    font-weight: 700;
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
}

/* =========================
   BUTTONS
========================= */
.btn {
    width: 100%;
    padding: 18px;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    position: relative;
    overflow: hidden;
}

.btn-buy,
.btn-sell,
.btn-save {
    background: var(--gold-gradient);
    color: var(--text-on-gold);
    border: 1px solid transparent;
    box-shadow: 0 5px 20px rgba(212, 175, 55, 0.3);
}

.btn-buy:hover,
.btn-sell:hover,
.btn-save:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(212, 175, 55, 0.5);
    filter: brightness(1.1);
}

.btn:active { transform: translateY(-1px); }

/* =========================
   RIWAYAT (HISTORY)
========================= */
.riwayat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 30px;
    border-bottom: 1px solid var(--border-dim);
    padding-bottom: 20px;
}

.header-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex: 1;
    align-items: flex-end;
}

.search-container {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px;
    border-radius: 50px;
    background: #0f0f0f;
    border: 1px solid var(--border-dim);
}

.search-date {
    padding: 12px 20px;
    border-radius: 50px;
    border: 1px solid var(--border-dim);
    background: var(--dark-input);
    color: var(--gold);
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    color-scheme: dark;
}

.search-date:focus { outline: none; border-color: var(--gold); }

.btn-search,
.btn-clear-search,
.btn-print,
.btn-clear {
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 700;
    font-family: var(--font-body);
    transition: var(--transition);
    padding: 12px 24px;
    text-transform: uppercase;
    font-size: 0.85rem;
}

.btn-search, .btn-print {
    background: transparent;
    border: 1px solid var(--gold);
    color: var(--gold);
}

.btn-search:hover, .btn-print:hover {
    background: var(--gold);
    color: #000;
    box-shadow: 0 0 15px var(--gold-shadow);
}

.btn-clear-search, .btn-clear {
    background: transparent;
    border: 1px solid #dc3545;
    color: #dc3545;
}

.btn-clear-search:hover, .btn-clear:hover {
    background: #dc3545;
    color: white;
    box-shadow: 0 0 15px rgba(220, 53, 69, 0.4);
}

.header-buttons {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    width: 100%;
    justify-content: flex-end;
}

.riwayat-list {
    max-height: 450px;
    overflow-y: auto;
    padding-right: 10px;
    margin-bottom: 30px;
}

.riwayat-item {
    background: linear-gradient(145deg, #1a1a1a, #141414);
    border-radius: var(--radius);
    padding: 25px;
    margin-bottom: 15px;
    border-left: 4px solid var(--gold);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
}

.riwayat-item:hover {
    transform: translateX(5px);
    background: linear-gradient(145deg, #222, #1a1a1a);
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.riwayat-item.beli { border-left-color: #28a745; }
.riwayat-item.jual { border-left-color: #dc3545; }

.riwayat-item h4 {
    margin-bottom: 5px;
    color: var(--gold-light);
    font-family: var(--font-heading);
    font-size: 1.2rem;
}

.riwayat-item p {
    color: var(--text-muted);
    margin-bottom: 3px;
    font-size: 0.9rem;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-style: italic;
    background: rgba(255,255,255,0.02);
    border-radius: var(--radius);
    border: 1px dashed var(--border-dim);
}

.summary {
    background: linear-gradient(135deg, #000 0%, #111 100%);
    border: 1px solid var(--gold-dim);
    border-radius: var(--radius);
    padding: 30px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.summary-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.summary-item span:first-child {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.summary-item span:last-child {
    color: var(--gold);
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 700;
}

.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.btn-edit, .btn-delete, .btn-print-small {
    flex: 1;
    border: none;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    font-weight: 700;
    color: white;
    transition: var(--transition);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.btn-edit { background: linear-gradient(135deg, #2980b9, #2c3e50); }
.btn-delete { background: linear-gradient(135deg, #c0392b, #8e44ad); }
.btn-print-small { background: linear-gradient(135deg, #16a085, #2c3e50); }

.btn-edit:hover, .btn-delete:hover, .btn-print-small:hover {
    transform: translateY(-2px);
    filter: brightness(1.2);
}

/* =========================
   MODAL
========================= */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(5px);
}

.modal-content {
    width: 90%;
    max-width: 500px;
    margin: 8% auto;
    border-radius: var(--radius);
    overflow: hidden;
    background: #1a1a1a;
    border: 1px solid var(--gold-dim);
    box-shadow: 0 25px 60px rgba(0,0,0,0.8);
    animation: slideIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-header {
    padding: 25px 30px;
    background: #000;
    color: var(--gold);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-dim);
}

.modal-header h3 {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    text-transform: uppercase;
}

.modal-body { padding: 30px; }

.close {
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
    line-height: 1;
}

.close:hover { color: var(--gold); }

@keyframes slideIn {
    from { transform: translateY(-50px) scale(0.9); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

/* =========================
   LOGIN MODAL OVERRIDE (KHUSUS)
========================= */
#modalLogin .modal-content {
    border: 1px solid var(--gold-dim);
    box-shadow: 0 20px 50px rgba(0,0,0,0.8);
}

#modalLogin .modal-header {
    background: linear-gradient(180deg, #0f0f0f 0%, #1a1a1a 100%);
    text-align: center;
    justify-content: center;
    border-bottom: 2px solid var(--gold-dim);
}

#modalLogin .modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
    background: var(--gold-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Custom Checkbox untuk Login */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    margin-bottom: 20px;
}

.checkbox-wrapper input { display: none; }

.checkmark {
    width: 20px;
    height: 20px;
    background-color: var(--dark-input);
    border: 1px solid var(--border-dim);
    border-radius: 4px;
    margin-right: 10px;
    position: relative;
    transition: var(--transition);
}

.checkbox-wrapper:hover .checkmark { border-color: var(--gold-dim); }

.checkbox-wrapper input:checked + .checkmark {
    background-color: var(--gold);
    border-color: var(--gold);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid var(--black);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-wrapper input:checked + .checkmark:after { display: block; }

.checkbox-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-family: var(--font-body);
}

/* =========================
   RESPONSIVE
========================= */
@media (max-width: 768px) {
    body { padding: 10px; }
    .form-row, .summary { grid-template-columns: 1fr; }
    .tab-content { padding: 25px 20px; }
    .riwayat-header { flex-direction: column; align-items: stretch; }
    .header-controls { align-items: stretch; }
    .search-container { flex-wrap: wrap; justify-content: center; background: transparent; border: none; }
    .header-buttons { width: 100%; flex-direction: column; }
    .btn-print, .btn-clear { width: 100%; }
}

/* =========================
   PRINT
========================= */
@media print {
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    body { background: white !important; color: black !important; padding: 0; }
    .container { box-shadow: none; border: none; background: white !important; }
    .tab-nav, .btn, .header-controls, .action-buttons, .search-container { display: none !important; }
    .tab-content { display: block !important; padding: 0; }
    * { color: black !important; text-shadow: none !important; }
    .riwayat-item {
        border: 1px solid #ddd;
        box-shadow: none;
        background: white !important;
        color: black !important;
        break-inside: avoid;
    }
    .riwayat-item h4, .riwayat-item p { color: black !important; }
}
/* =========================================
   SCROLLABLE EDIT MODAL (FIX OVERFLOW)
   ========================================= */

/* 1. Atur container modal edit */
#modalEdit .modal-content {
    display: flex;         /* Menggunakan Flexbox */
    flex-direction: column; /* Susun vertikal */
    max-height: 85vh;      /* Batas tinggi maksimal 85% dari tinggi layar */
    margin: 5% auto;       /* Posisi tetap di tengah */
}

/* 2. Header tetap diam di atas */
#modalEdit .modal-header {
    flex-shrink: 0;        /* Mencegah header mengecil/terpotong */
    z-index: 10;           /* Pastikan header di atas konten scroll */
}

/* 3. Body yang bisa di-scroll */
#modalEdit .modal-body {
    overflow-y: auto;      /* Aktifkan scroll vertikal */
    flex-grow: 1;          /* Mengisi sisa ruang tinggi yang tersedia */
    padding-right: 10px;   /* Tambah sedikit ruang agar scrollbar tidak menabrak tepi */
}

/* Custom Scrollbar untuk Modal Edit (Opsional, biar makin cantik) */
#modalEdit .modal-body::-webkit-scrollbar {
    width: 6px;
}
#modalEdit .modal-body::-webkit-scrollbar-track {
    background: #1a1a1a;
}
#modalEdit .modal-body::-webkit-scrollbar-thumb {
    background: var(--gold-dim);
    border-radius: 3px;
}
#modalEdit .modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--gold);
}
/* =========================================
   PERBAIKAN TAMPILAN DROPDOWN EDIT MODAL
   ========================================= */

#editTipe {
    width: 100%;
    padding: 16px 20px; /* Samakan padding dengan input text lainnya */
    border-radius: var(--radius);
    border: 1px solid var(--border-dim);
    background-color: var(--dark-input); /* Background Gelap */
    color: var(--text-main); /* Teks Putih */
    font-family: var(--font-body);
    font-size: 1.1rem;
    
    /* Hilangkan tanda panah default OS (yang jelek) */
    appearance: none; 
    -webkit-appearance: none;
    -moz-appearance: none;
    
    /* Tambahkan Panah Emas Custom */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23D4AF37' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 18px;
    
    cursor: pointer;
    transition: var(--transition);
}

/* Efek saat diklik/fokus */
#editTipe:focus {
    outline: none;
    border-color: var(--gold);
    background-color: #252525;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.15);
}

/* Warna pilihan dropdown saat dibuka (agar tetap gelap) */
#editTipe option {
    background-color: #1a1a1a;
    color: #e0e0e0;
    padding: 10px;
}