/* ============================
   Receipt Printer Styles
   PT Sakura Format
   ============================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: system-ui, -apple-system, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    color: #fff;
}

/* Control Panel */
.control-panel {
    max-width: 500px;
    margin: 0 auto;
    padding: 40px 20px;
    text-align: center;
}

.control-panel h1 {
    font-size: 2rem;
    margin-bottom: 8px;
    background: linear-gradient(90deg, #00d9ff, #00ff88);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: #8892b0;
    margin-bottom: 30px;
}

/* Upload Area */
.upload-area {
    border: 2px dashed #4a5568;
    border-radius: 16px;
    padding: 40px 20px;
    background: rgba(255, 255, 255, 0.03);
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: #00d9ff;
    background: rgba(0, 217, 255, 0.05);
}

.upload-area.uploaded {
    border-color: #00ff88;
    background: rgba(0, 255, 136, 0.05);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.upload-area p {
    color: #a0aec0;
    margin-bottom: 8px;
}

.or {
    font-size: 0.875rem;
    color: #718096;
}

.upload-btn {
    display: inline-block;
    margin-top: 15px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #00d9ff, #00ff88);
    color: #1a1a2e;
    font-weight: 600;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0, 217, 255, 0.3);
}

/* Download Sample Button */
.btn-sample {
    margin-top: 20px;
    padding: 10px 20px;
    background: transparent;
    border: 1px solid #4a5568;
    color: #a0aec0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.btn-sample:hover {
    border-color: #00d9ff;
    color: #00d9ff;
    background: rgba(0, 217, 255, 0.1);
}

/* Upload Status Indicator */
.upload-status {
    display: none;
    margin-top: 20px;
    padding: 15px 20px;
    background: rgba(0, 255, 136, 0.1);
    border: 1px solid rgba(0, 255, 136, 0.3);
    border-radius: 12px;
    align-items: center;
    gap: 15px;
}

.upload-status.show {
    display: flex;
}

.upload-status .status-icon {
    font-size: 2rem;
}

.upload-status .status-info {
    flex: 1;
    text-align: left;
}

.upload-status .file-name {
    display: block;
    font-weight: 600;
    color: #00ff88;
    font-size: 0.95rem;
    margin-bottom: 2px;
}

.upload-status .record-count {
    display: block;
    font-size: 0.85rem;
    color: #8892b0;
}

.btn-reset {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.layout-select {
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #4a5568;
    background: #1a1a2e;
    color: #fff;
    font-size: 1rem;
    margin-left: 10px;
    cursor: pointer;
}

.layout-controls {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

.control-group {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px 25px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-reset:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(180deg);
}

/* Action Buttons */
.actions {
    margin-top: 25px;
    display: flex;
    gap: 15px;
    justify-content: center;
}

.btn {
    padding: 14px 28px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-pdf {
    background: linear-gradient(135deg, #ff6b6b, #ff8e53);
    color: #fff;
}

.btn-pdf:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(255, 107, 107, 0.3);
}

.btn-pdf:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Receipt Container */
.receipt-container {
    max-width: 210mm;
    margin: 30px auto;
    padding: 0 20px;
}

/* ============================
   Receipt Styles (PT Sakura Format)
   ============================ */

/* ============================
   Receipt Styles (User Spec)
   ============================ */

.receipt {
    background: #fff;
    color: #000;
    font-family: Arial, Liberation-Sans, Helvetica, sans-serif;
    font-size: 11pt; /* Increased font size */
    padding: 15px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    margin: 0 auto 30px auto;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 180mm;
    
/* Page break for PDF - 2 Receipts per Page */
    /* Remove default always break */
    page-break-after: auto;
    break-after: auto;
    page-break-inside: avoid;
    break-inside: avoid;
}

.receipt:nth-child(even) {
    page-break-after: always;
    break-after: page;
}

.receipt:last-child {
    page-break-after: auto;
    break-after: auto;
}

.receipt h1 {
    font-size: 10pt;
    font-weight: bold;
    margin-block-start: 0;
    margin-block-end: 0;
}

.receipt .header {
    text-align: center;
    border-style: solid;
    border-width: 1px 0px 1px 0px;
    border-color: #000;
    padding: 5px 0;
    margin-bottom: 10px;
}

.receipt .detail {
    padding: 0;
}

.receipt .footer {
    margin-block-start: 1em;
    text-align: center;
    border-style: solid;
    border-width: 1px 0px 1px 0px;
    border-color: #000;
    padding: 5px 0;
    margin-top: 10px;
    font-weight: normal;
}

/* Inline Definition List (User Spec) */
/* Inline Definition List (User Spec) */
dl.inline { margin: 0; }

dl.inline dd {
    display: inline;
    margin: 0;
}

dl.inline dd:after {
    display: block;
    content: '';
    margin-bottom: 5px; /* Increase line spacing */
}

dl.inline dt {
    display: inline-block;
    min-width: 180px; /* Wider label to fix wrapping */
    font-weight: bold;
    white-space: nowrap;
}

/* ============================
   Print & PDF Styles
   ============================ */

@media print {
    body {
        background: #fff;
        margin: 0;
        padding: 0;
    }

    .no-print {
        display: none !important;
    }

    /* --- Shared Basic Styles --- */
    .receipt-container {
        max-width: 100%;
        padding: 0;
        margin: 0;
        /* Default grid (reset by specific layouts) */
        display: block; 
    }

    .receipt {
        box-shadow: none;
        margin: 0;
        border-radius: 0;
        max-width: 100%;
        width: 100%;
        border: 1px solid #000;
        /* Reset all breaks by default */
        page-break-after: auto;
        break-after: auto;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* --- Specific Layout Logic --- */

    /* 1. Layout 1x2 (1 col, 2 rows) */
    /* Target: ~135mm per receipt */
    .receipt-container.layout-1x2 {
        display: grid;
        grid-template-columns: 1fr;
        row-gap: 10mm;
    }
    .receipt-container.layout-1x2 .receipt {
        height: auto;
        max-height: 130mm;
        margin-bottom: 0;
        padding: 20px;
        font-size: 10pt;
    }
    .receipt-container.layout-1x2 .receipt:nth-child(2n) {
        page-break-after: always;
        break-after: page;
    }

    /* 2. Layout 1x3 (1 col, 3 rows) */
    /* Target: ~90mm per receipt */
    .receipt-container.layout-1x3 {
        display: block;
        /* No grid gap, use margin */
    }
    .receipt-container.layout-1x3 .receipt {
        height: auto;
        max-height: 92mm; /* 3 x 92 = 276mm < 277mm (A4 usable) */
        margin: 0 0 2mm 0; /* Minimal margin */
        padding: 10px 15px;
        font-size: 8.5pt;
        overflow: hidden;
    }
    .receipt-container.layout-1x3 .receipt:nth-child(3n) {
        page-break-after: always;
        break-after: page;
        margin-bottom: 0;
    }

    /* 3. Layout 2x3 (2 cols, 3 rows) */
    /* Target: ~90mm per receipt */
    .receipt-container.layout-2x3 {
        display: grid;
        grid-template-columns: 1fr 1fr;
        column-gap: 10mm;
        row-gap: 5mm;
    }
    .receipt-container.layout-2x3 .receipt {
        height: auto;
        max-height: 90mm; /* 3 x 90 = 270 + 2x5 gaps = 280mm (Safe) */
        margin: 0;
        padding: 10px;
        font-size: 8.5pt;
        overflow: hidden;
    }
    .receipt-container.layout-2x3 .receipt h1 {
        font-size: 10pt; 
        margin-bottom: 5px;
    }
    .receipt-container.layout-2x3 .receipt .header,
    .receipt-container.layout-2x3 .receipt .footer {
        padding: 5px 0;
        margin: 5px 0;
    }
    .receipt-container.layout-2x3 .receipt:nth-child(6n) {
        page-break-after: always;
        break-after: page;
    }

    @page {
        size: A4;
        margin: 10mm; /* 297mm - 20mm = 277mm usable height */
    }
}
