:root {
    /* UI Variables */
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-dark: #0f172a;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --input-bg: rgba(15, 23, 42, 0.6);
    
    /* Receipt Variables */
    --receipt-bg: #ffffff;
    --receipt-color: #000000;
    --receipt-width: 384px; /* Lebar mutlak untuk printer 58mm (384 dots) */
    --receipt-padding: 10px; /* Margin kiri-kanan sekecil mungkin agar hasil besar */
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Base Layout for Desktop */
.app-container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    padding-bottom: 100px; /* Space for action panel */
    z-index: 10;
}

.preview-container {
    position: fixed;
    right: 20px;
    top: 20px;
    bottom: 20px;
    width: 400px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 30px;
    overflow-y: auto;
    z-index: 10;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

@media (max-width: 1100px) {
    body {
        flex-direction: column;
    }
    .preview-container {
        position: relative;
        right: auto;
        top: auto;
        bottom: auto;
        width: 100%;
        max-width: 600px;
        margin: 0 auto;
        border-radius: 12px;
        margin-bottom: 100px;
    }
    .app-container {
        padding-bottom: 20px;
    }
}

/* Typography & Form Elements */
h1 { font-size: 24px; font-weight: 700; margin-bottom: 5px; background: linear-gradient(to right, #818cf8, #c084fc); -webkit-background-clip: text; -webkit-text-fill-color: transparent;}
h2 { font-size: 16px; font-weight: 600; color: #cbd5e1; margin-bottom: 15px; display: flex; align-items: center; gap: 8px;}
p { color: var(--text-muted); font-size: 14px; line-height: 1.5; margin-bottom: 20px; }

.panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.3);
}

.form-section {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--glass-border);
}
.form-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.form-group {
    margin-bottom: 15px;
}
.form-row {
    display: flex;
    gap: 15px;
}
.half { flex: 1; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1.5fr; gap: 10px; }
.mb-2 { margin-bottom: 10px; }
.mt-2 { margin-top: 10px; }
.mt-3 { margin-top: 15px; }

label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 5px;
    font-weight: 500;
}

input, textarea {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 12px 15px;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s ease;
}
input:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}

/* Buttons */
.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 15px 25px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    width: 100%;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}
.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -10px var(--primary);
}
.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: white;
    border: 1px dashed rgba(255, 255, 255, 0.2);
    padding: 12px;
    border-radius: 10px;
    width: 100%;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-style: solid;
}

.btn-remove {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
}
.btn-remove:hover {
    background: rgba(239, 68, 68, 0.8);
    color: white;
}

.card-glass {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    position: relative;
}

.card-glass-small {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
    position: relative;
}

.upload-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 5px;
}
input[type="file"] {
    padding: 8px;
    font-size: 13px;
    border: 1px dashed rgba(255,255,255,0.3);
    background: transparent;
}
.btn-danger-small {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.5);
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
}
.btn-danger-small:hover {
    background: rgba(239, 68, 68, 0.5);
}

.style-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    background: rgba(0,0,0,0.2);
    padding: 6px 10px;
    border-radius: 6px;
    margin-top: 5px;
}
.style-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    background: rgba(255,255,255,0.1);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 13px;
    margin-bottom: 0;
}
.style-btn:hover { background: rgba(255,255,255,0.2); }
.style-btn input { width: auto; margin: 0; padding: 0; }
.style-select {
    background: rgba(255,255,255,0.1);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    flex: 1;
}
.style-select option { background: var(--bg-dark); }

/* Login Overlay */
.login-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(15px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}
.login-box {
    width: 100%;
    max-width: 350px;
    padding: 30px 20px;
}
body.locked .app-container, body.locked .preview-container, body.locked .action-panel {
    display: none !important;
}

.subtotal-display {
    font-size: 13px;
    color: #a7f3d0;
    text-align: right;
    font-weight: 600;
}

.action-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--glass-border);
    z-index: 50;
    display: flex;
    justify-content: center;
}
@media (min-width: 1101px) {
    .action-panel {
        right: 440px; /* Offset by preview container */
    }
}

/* ========================================= */
/* RECEIPT STYLING (Strictly matches image)  */
/* ========================================= */

.receipt-wrapper {
    background: #e2e8f0;
    padding: 20px;
    border-radius: 4px;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.1);
}

.receipt {
    background-color: var(--receipt-bg);
    color: var(--receipt-color);
    width: var(--receipt-width);
    font-family: 'Roboto Mono', monospace; /* Monospaced font like thermal printers */
    font-size: 19px; /* Ideal untuk 32 karakter per baris pada lebar 384px */
    line-height: 1.4;
    padding: var(--receipt-padding);
    padding-bottom: 25px; /* Tambahan ruang kosong agar tidak terpotong pisau/canvas */
    margin: 0 auto;
}

.text-center { text-align: center; }
.bold { font-weight: 700; }
.text-sm { font-size: 15px; }

/* Logo styling to mimic the oval logo or standard logo in the image */
.receipt-logo {
    text-align: center;
    margin-bottom: 10px;
}
.receipt-logo img {
    max-width: 100%;
    max-height: 120px;
    object-fit: contain;
    filter: grayscale(100%) contrast(1.5); /* Optimize for thermal print (black and white) */
}

.receipt-title {
    font-size: 24px;
    margin-bottom: 5px;
    letter-spacing: 1px;
}
.receipt-address {
    padding: 0 10px;
    margin-bottom: 2px;
}
.receipt-phone {
    margin-bottom: 10px;
}

/* Dividers */
.divider {
    width: 100%;
    margin: 8px 0;
}
.divider.solid {
    border-top: 1px solid black;
}
.divider.dashed {
    border-top: 1px dashed black;
}

/* Meta Data */
.receipt-meta {
    margin-bottom: 5px;
}
.meta-row {
    display: flex;
}
.meta-label {
    width: 95px; /* Diperlebar untuk menyesuaikan ukuran font yang lebih besar (mencegah teks bertumpuk) */
}
.meta-colon {
    margin-right: 5px;
}

/* Items */
.receipt-items {
    margin-bottom: 5px;
}
.item {
    margin-bottom: 4px;
}
.item-calc {
    display: flex;
    justify-content: space-between;
    padding-left: 10px; /* Indent under item name */
}

/* Totals */
.total-row {
    display: flex;
    justify-content: space-between;
}
.grand-total {
    font-size: 21px;
}

/* ========================================= */
/* PRINT MEDIA QUERY                         */
/* ========================================= */
@media print {
    /* Hide everything except the receipt */
    body * {
        visibility: hidden;
    }
    
    body {
        background: white;
        margin: 0;
        padding: 0;
    }

    .preview-container, .receipt-wrapper, .receipt, .receipt * {
        visibility: visible;
    }

    .receipt {
        position: absolute;
        left: 0;
        top: 0;
        width: 384px;
        margin: 0;
        padding: 0;
    }

    .preview-container {
        position: absolute;
        left: 0;
        top: 0;
        width: 384px;
        padding: 0;
        background: transparent;
        border: none;
        box-shadow: none;
    }
    .receipt-wrapper {
        padding: 0;
        background: transparent;
        box-shadow: none;
    }
    
    @page {
        margin: 0;
        size: 58mm auto; /* Thermal paper size */
    }
}
