:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --border-color: #ccc;
    --bg-color: #f8f9fa;
    --font-family: 'Cairo', Tajawal, sans-serif; /* Prioritizing Cairo */
}

body {
    direction: rtl;
    font-family: var(--font-family);
    margin: 0;
    padding: 20px;
    background-color: var(--bg-color);
    color: #333;
}

#app-container {
    max-width: 600px;
    margin: 0 auto;
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

h1 {
    text-align: center;
    color: var(--primary-color);
    font-weight: 700;
}

.input-area {
    padding: 15px;
}

.form-group {
    margin-bottom: 15px;
    padding: 5px 0;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: 700;
}

input[type="text"],
input[type="number"],
input[type="tel"],
textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 16px;
}

textarea {
    resize: vertical;
}

.checkbox-group, .amount-options label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 400;
}

.amount-options p {
    margin: 0 0 10px 0;
    font-weight: 700;
}

.actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: space-around;
}

button {
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 700;
    transition: background-color 0.3s;
    flex-grow: 1;
}

#printBtn, #previewBtn {
    background-color: var(--primary-color);
    color: white;
}

#clearBtn {
    background-color: var(--secondary-color);
    color: white;
}

/* --- Print Styles --- */

#print-area {
    display: none; /* Hide by default */
}

@media screen and (max-width: 650px) {
    #app-container {
        padding: 10px;
    }
}

@media print {
    /* Hide input interface */
    #app-container {
        display: none !important;
    }
    
    /* Set printing context */
    @page {
        size: 10cm 15cm portrait; /* A6 size definition */
        margin: 0;
        padding: 0;
    }
    
    body {
        background: none;
        padding: 0;
        margin: 0;
        direction: rtl;
        font-family: var(--font-family);
        font-size: 11pt; 
    }

    #print-area {
        display: block !important;
        width: 10cm; 
        margin: 0;
        padding: 0;
        box-shadow: none;
    }

    .page {
        /* This container MUST match the page size set in @page */
        width: 10cm;
        height: 15cm; 
        
        box-sizing: border-box;
        padding: 0.5cm 0.7cm; /* Internal padding */
        
        page-break-after: always; /* Separation logic */
        page-break-inside: avoid;
        position: relative; /* For absolute positioning of footer */
        
        /* Optional: Border for visualization, remove if printing to actual size thermal printer */
        /* border: 1px dashed #000; */
    }
    
    .page:last-child {
        page-break-after: auto; 
    }
    
    /* Receipt Content Styling */
    .receipt-header {
        text-align: center;
        margin-bottom: 0.4cm;
    }
    
    .receipt-title {
        font-size: 16pt;
        font-weight: 700;
        border-bottom: 2px solid #000;
        padding-bottom: 3px;
        display: inline-block;
    }
    
    .data-row {
        margin-bottom: 0.25cm;
    }
    
    .data-label {
        display: block; /* Ensure label takes up full width for proper stacking */
        font-weight: 700;
        font-size: 10pt;
        color: #555;
        line-height: 1.2;
    }
    
    .data-value {
        display: block; /* Ensure value takes up full width */
        font-size: 11pt;
        font-weight: 400;
        line-height: 1.4;
        border-bottom: 1px dashed #bbb;
        padding-bottom: 1px;
        
        /* Fulfilling user request: Align data values to the left */
        text-align: left;
        direction: ltr; /* Use LTR context for numerical/address data flow */
    }

    .data-value.large-font {
        font-size: 13pt;
        font-weight: 700;
        color: #000;
    }

    /* Specific styles for key elements */
    
    .bon-number-section {
        margin-top: 0.5cm;
        text-align: center;
    }
    
    .bon-number {
        font-size: 20pt; /* Large and thick */
        font-weight: 700;
        border: 2px solid #000;
        padding: 5px 10px;
        display: inline-block;
        margin-bottom: 0.5cm;
    }
    
    .amount-section {
        text-align: center;
        margin: 0.8cm 0;
        padding: 0.4cm;
        border: 3px double #000;
        background: #fcfcfc;
    }
    
    .amount-label {
        font-size: 13pt;
        font-weight: 700;
    }
    
    .amount-value {
        font-size: 20pt;
        font-weight: 700;
        color: #000; 
        display: block;
        margin-top: 5px;
    }
    
    .footer-info {
        position: absolute;
        bottom: 0.5cm;
        left: 0.7cm;
        right: 0.7cm;
        display: flex;
        justify-content: space-between;
        align-items: flex-end;
        font-size: 9pt;
        color: #777;
    }
    
    .copy-number {
        font-size: 11pt;
        font-weight: 700;
        color: #000;
        border: 1px solid #000;
        padding: 2px 5px;
    }
}