/* Font Import */
@font-face {
    font-family: 'BitArray-A2';
    src: url('../fonts/bitArray-A2/bitArray-A2.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

/* CSS Variables with updated millimeter measurements */
:root {
    /* Color scheme */
    --color-white: #ffffff;
    --color-off-white: #f5f5f7;
    --color-light-gray: #e5e5ea;
    --color-gray: #d1d1d6;
    --color-dark-gray: #6e6e73;
    --color-darker-gray: #4c4c4f;
    --color-text-dark: #1d1d1f;
    --color-text-muted: #8e8e93;

    /* Brand colors */
    --color-primary: #0066cc;
    --color-primary-hover: #004c99;
    --color-success: #34c759;
    --color-success-hover: #30b753;
    --color-error: #ff3b30;
    --color-error-hover: #e42e27;
    --color-warning: #ff9500;
    --color-info: #5ac8fa;

    /* Font families */
    --font-family-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-family-BitArray: 'BitArray-A2', monospace;

    /* Receipt dimensions in millimeters as specified */
    --receipt-width: 80mm;
    --receipt-height: 297mm; /* Standard A4 height */
    --receipt-padding: 5mm;

    /* Font sizes in millimeters */
    --font-size-standard: 2.8mm;
    --font-size-large: 3.2mm;
    --font-size-small: 2.5mm;
    --font-size-total: 4mm;

    /* Line spacing */
    --line-height-standard: 1.2;
    --line-height-compact: 1.1;
    --line-height-loose: 1.3;

    /* Spacing measurements */
    --spacing-xxs: 0.5mm;
    --spacing-xs: 1mm;
    --spacing-sm: 2mm;
    --spacing-md: 3mm;
    --spacing-lg: 5mm;
    --spacing-xl: 7mm;
    --spacing-xxl: 10mm;

    /* Section margins */
    --section-margin: 7mm;
    --header-margin: 10mm;
    --footer-margin: 15mm;

    /* Other variables */
    --main-bg-color: #f5f5f7;
    --panel-bg-color: #ffffff;
    --border-color: #dddddd;
    --text-color: #000000; /* Changed to black to match receipt */
    --receipt-bg-color: #ffffff;
    --accent-color: #0066cc;
    --hover-color: #004c99;
    --success-color: #34c759;
    --error-color: #ff3b30;
    --warning-color: #ff9500;
    --info-color: #5ac8fa;
}

/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family-sans);
    background-color: var(--main-bg-color);
    color: var(--text-color);
    line-height: 1.5;
    padding-bottom: 80px;
}

/* App Container */
.app-container {
    display: flex;
    flex-wrap: wrap;
    max-width: 1200px;
    margin: 20px auto;
    gap: 20px;
}

/* Preview Container */
.preview-container {
    flex: 1;
    min-width: 340px;
    background-color: var(--panel-bg-color);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 15px;
    display: flex;
    flex-direction: column;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.preview-title {
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.zoom-controls {
    display: flex;
    gap: 5px;
}

.zoom-btn {
    border: 1px solid var(--border-color);
    background-color: var(--panel-bg-color);
    color: var(--text-color);
    width: 30px;
    height: 30px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.zoom-btn:hover {
    background-color: #f0f0f0;
}

/* Receipt Container */
.receipt-container {
    overflow: auto;
    flex: 1;
    display: flex;
    justify-content: center;
    padding: 20px;
    background-color: #f0f0f0;
    border-radius: 4px;
    position: relative;
    transition: transform 0.3s ease;
}

/* Receipt Styles - Updated with exact millimeter measurements */
.receipt {
    width: var(--receipt-width);
    min-height: var(--receipt-height);
    background-color: var(--receipt-bg-color);
    padding: var(--receipt-padding);
    font-family: var(--font-family-BitArray);
    font-size: var(--font-size-standard);
    line-height: var(--line-height-standard);
    color: var(--text-color);
    position: relative;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    letter-spacing: 0.05mm;
}

/* Store Header - Updated with exact positioning */
.store-header {
    text-align: center;
    margin-bottom: var(--header-margin);
    line-height: var(--line-height-loose);
    font-size: var(--font-size-standard);
}

.store-header-line {
    margin-bottom: var(--spacing-xxs);
}

/* Receipt Header - Updated with exact spacing */
.receipt-header-combined {
    width: 100%;
    margin: 0 0 var(--section-margin) 0;
    padding: 0;
    font-size: var(--font-size-standard);
    letter-spacing: 0.1mm;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Customer Section - Updated with exact spacing */
.customer-section {
    margin-bottom: var(--section-margin);
}

.customer-info {
    line-height: var(--line-height-standard);
}

.customer-id-line {
    margin-bottom: var(--spacing-xs);
}

.customer-name-line {
    display: flex;
    gap: var(--spacing-xs);
}

/* Product Section - Updated with exact measurements */
.product-section {
    margin-bottom: var(--spacing-lg);
}

.product-item {
    display: flex;
    margin-bottom: var(--spacing-sm);
    align-items: flex-start;
}

.product-quantity {
    flex: 0 0 8mm; /* Exact width for quantity column */
}

.product-info {
    flex: 1;
    margin-right: var(--spacing-md);
}

.product-name {
    font-weight: normal;
}

.product-sku {
    font-size: var(--font-size-small);
    margin-top: var(--spacing-xxs);
}

.product-price {
    text-align: right;
    flex: 0 0 18mm; /* Exact width for price column */
    font-variant-numeric: tabular-nums;
}

/* Subtotal Section - Updated with exact measurements */
.subtotal-section {
    margin-top: var(--spacing-md);
    margin-bottom: var(--section-margin);
}

.subtotal-row {
    display: flex;
    justify-content: space-between;
    padding-top: var(--spacing-xs);
}

.subtotal-row span {
    font-variant-numeric: tabular-nums;
}

/* Total Section - Updated with precise spacing */
.total-section {
    margin-bottom: var(--spacing-xxl);
    position: relative;
}

.total-row {
    display: flex;
    justify-content: flex-end;
    margin-bottom: var(--spacing-sm);
}

.total-amount {
    font-variant-numeric: tabular-nums;
}

.total-amount-with-currency {
    font-size: var(--font-size-total);
    text-align: right;
    margin-bottom: var(--spacing-xs);
}

.product-count {
    font-size: var(--font-size-small);
    text-align: right;
}

/* Payment Section - Updated with exact measurements */
.payment-section {
    margin-bottom: var(--spacing-xl);
}

.payment-row {
    display: flex;
    justify-content: space-between;
}

.payment-method {
    text-align: left;
}

.payment-amount {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Tax Section - Updated with exact spacing */
.tax-section {
    margin-bottom: var(--footer-margin);
}

.tax-data {
    display: flex;
    justify-content: space-between;
    font-size: var(--font-size-standard);
}

#tax-amount, #tax-rate-display, #tax-base {
    font-variant-numeric: tabular-nums;
    flex: 1;
    text-align: center;
}

#tax-amount {
    text-align: left;
}

#tax-base {
    text-align: right;
}

/* Store Footer - Updated with exact measurements */
.store-footer {
    text-align: center;
    font-size: var(--font-size-small);
    line-height: var(--line-height-loose);
    margin-top: auto;
    padding-top: var(--spacing-xl);
}

.store-footer-line {
    margin-bottom: var(--spacing-xxs);
}

/* Receipt Style Variations */
.receipt.us-style {
    font-family: var(--font-family-BitArray);
}

.receipt.europe-style {
    font-family: var(--font-family-BitArray);
}

.receipt.europe-style .tax-section {
    margin-top: var(--spacing-lg);
}

/* Refund Policy */
.refund-policy {
    font-family: var(--font-family-BitArray);
    font-size: var(--font-size-small);
    text-align: center;
    margin-top: var(--spacing-xxl);
    padding-top: var(--spacing-xl);
    border-top: 1px dotted #ddd;
}

/* Receipt Watermark */
.receipt-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    font-size: 32px;
    color: rgba(0, 0, 0, 0.1);
    white-space: nowrap;
    pointer-events: none;
    z-index: 20;
    background-image: url('../images/watermark.png');
    background-repeat: no-repeat;
    background-position: center;
    background-size: 80% auto;
    width: 100%;
    height: 100%;
    opacity: 0.1;
    display: none;
}

/* Control Panel */
.control-panel {
    flex: 1;
    min-width: 340px;
    background-color: var(--panel-bg-color);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 15px;
    display: flex;
    flex-direction: column;
}

.panel-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Tabs */
.tabs-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 15px;
}

.tab-btn {
    padding: 10px 15px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.7;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 5px;
    position: relative;
}

.tab-btn:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.05);
}

.tab-btn.active {
    opacity: 1;
    font-weight: 500;
    color: var(--accent-color);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--accent-color);
}

.tab-btn i {
    font-size: 16px;
}

.tab-content {
    display: none;
    flex: 1;
}

.tab-content.active {
    display: block;
}

/* Form Sections */
.form-sections {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-section {
    background-color: #f9f9f9;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.section-title {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 15px;
    color: #555;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title i {
    color: var(--accent-color);
    font-size: 18px;
}

.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.form-row:last-child {
    margin-bottom: 0;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

label {
    font-size: 0.9rem;
    color: #555;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
}

input[type="text"],
input[type="number"],
select,
textarea {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: border-color 0.2s ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.1);
}

.info-display {
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    background-color: #f5f5f5;
    font-size: 0.9rem;
    min-height: 36px;
    display: flex;
    align-items: center;
}

.file-input-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background-color: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.file-input-label:hover {
    background-color: #e5e5e5;
}

.file-input-label input[type="file"] {
    display: none;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    gap: 8px;
}

.checkbox-label input[type="checkbox"] {
    margin-right: 5px;
}

.range-slider {
    display: flex;
    align-items: center;
    gap: 10px;
}

.range-slider input[type="range"] {
    flex: 1;
}

.range-value {
    font-size: 0.9rem;
    color: #666;
    min-width: 40px;
    text-align: right;
}

/* StockX Link Processor */
.input-with-button {
    display: flex;
    margin-bottom: 10px;
}

.stockx-link-input {
    flex: 1;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.process-link-button {
    padding: 8px 16px;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background-color 0.2s ease;
}

.process-link-button:hover {
    background-color: var(--hover-color);
}

.loader {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top: 2px solid white;
    animation: spin 1s linear infinite;
    display: none;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.link-status {
    font-size: 0.9rem;
    padding: 8px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.link-status.success {
    background-color: rgba(52, 199, 89, 0.1);
    color: var(--success-color);
}

.link-status.error {
    background-color: rgba(255, 59, 48, 0.1);
    color: var(--error-color);
}

.link-status.processing {
    background-color: rgba(90, 200, 250, 0.1);
    color: var(--info-color);
}

/* Product List */
.product-list {
    max-height: 300px;
    overflow-y: auto;
}

.product-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding: 10px 0;
}

.product-list-item:last-child {
    border-bottom: none;
}

.product-list-details {
    flex: 1;
}

.product-list-name {
    font-weight: 500;
    margin-bottom: 3px;
}

.product-list-info {
    font-size: 0.8rem;
    color: #777;
}

.product-list-actions {
    display: flex;
    gap: 5px;
}

.edit-product-btn,
.remove-product-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #777;
    font-size: 1rem;
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 4px;
}

.edit-product-btn:hover {
    color: var(--accent-color);
    background-color: rgba(0, 102, 204, 0.1);
}

.remove-product-btn:hover {
    color: var(--error-color);
    background-color: rgba(255, 59, 48, 0.1);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 10px;
}

.action-btn {
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.add-btn {
    background-color: var(--accent-color);
    color: white;
    border: none;
}

.add-btn:hover {
    background-color: var(--hover-color);
}

.clear-btn {
    background-color: transparent;
    color: var(--error-color);
    border: 1px solid var(--error-color);
}

.clear-btn:hover {
    background-color: rgba(255, 59, 48, 0.1);
}

/* Style Selector */
.style-selector {
    display: flex;
    gap: 15px;
}

.style-option {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.style-option input[type="radio"] {
    margin: 0;
}

/* Export Options */
.export-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.export-btn {
    padding: 10px 16px;
    background-color: #f5f5f7;
    color: var(--text-color);
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    transition: all 0.2s ease;
}

.export-btn:hover {
    background-color: #ebebf0;
}

.export-explanation {
    font-size: 0.8rem;
    color: #777;
    margin-top: 3px;
}

/* Template Buttons */
.template-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

.template-btn {
    padding: 10px;
    background-color: #f5f5f7;
    color: var(--text-color);
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    transition: all 0.2s ease;
    text-align: center;
}

.template-btn:hover {
    background-color: #ebebf0;
}

.template-btn i {
    font-size: 20px;
    color: var(--accent-color);
}

.random-btn {
    background-color: rgba(255, 149, 0, 0.1);
    color: var(--warning-color);
}

.random-btn:hover {
    background-color: rgba(255, 149, 0, 0.2);
}

.random-btn i {
    color: var(--warning-color);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

.toast {
    padding: 12px 16px;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 300px;
    max-width: 400px;
    background-color: white;
    animation: toast-in 0.3s ease forwards;
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--error-color);
}

.toast.warning {
    border-left: 4px solid var(--warning-color);
}

.toast.info {
    border-left: 4px solid var(--info-color);
}

.toast.success i {
    color: var(--success-color);
}

.toast.error i {
    color: var(--error-color);
}

.toast.warning i {
    color: var(--warning-color);
}

.toast.info i {
    color: var(--info-color);
}

.toast i {
    font-size: 18px;
}

.toast.fade-out {
    animation: toast-out 0.3s ease forwards;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(50px); }
}

/* Footer */
.app-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: #f5f5f7;
    border-top: 1px solid var(--border-color);
    text-align: center;
    padding: 15px;
    font-size: 0.9rem;
    color: #777;
    z-index: 100;
}

/* Special hazard effects */
.receipt-container.blinking {
    animation: blink 1s infinite;
}

.receipt-container.shake {
    animation: shake 0.5s infinite;
}

.receipt-container.rotate {
    animation: rotate 3s infinite linear;
}

.receipt-container.skew {
    animation: skew 2s infinite alternate;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes skew {
    0% { transform: skewX(0deg); }
    100% { transform: skewX(15deg); }
}

/* Print settings for receipt */
@media print {
    body {
        margin: 0;
        padding: 0;
        background: none;
    }

    .site-header, .control-panel, .preview-header, .app-footer {
        display: none;
    }

    .app-container {
        display: block;
        margin: 0;
        padding: 0;
    }

    .preview-container {
        width: var(--receipt-width);
        box-shadow: none;
        padding: 0;
        background: none;
    }

    #receipt-container {
        width: var(--receipt-width);
        box-shadow: none;
        padding: 0;
    }

    .receipt {
        box-shadow: none;
    }
}

/* Responsive Styles */
@media (max-width: 900px) {
    .app-container {
        flex-direction: column;
    }
}

@media (max-width: 600px) {
    .form-row {
        flex-direction: column;
        gap: 10px;
    }

    .template-buttons {
        grid-template-columns: repeat(2, 1fr);
    }

    .panel-title, .preview-title {
        font-size: 1.1rem;
    }

    .export-btn, .template-btn {
        padding: 8px;
    }

    .tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .tab-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
}

/* Specific adjustments for the example receipt */
/* These ensure exact matching with the reference image */
.total-amount-with-currency {
    margin-top: 4mm;
    font-weight: normal;
}

.payment-section {
    margin-top: 5mm;
}

.tax-section {
    margin-top: 5mm;
}

/* Ensure minimum heights are maintained for proper spacing */
.product-section {
    min-height: 20mm;
}

.subtotal-section {
    min-height: 5mm;
}

/* Ensure the footer is properly aligned at the bottom */
.store-footer {
    margin-top: auto;
}

/* Enhance print quality by specifying exact font rendering */
@media print {
    .receipt * {
        -webkit-font-smoothing: none;
        font-smooth: never;
    }
}
