/* Reset và base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f8f9fa;
    color: #333;
    line-height: 1.5;
}

/* Container chính */
.container {
    max-width: 480px;
    margin: 0 auto;
    background-color: white;
    min-height: 100vh;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* Form section */
.form-section {
    background-color: #f8f9fa;
    padding: 16px;
    border-bottom: 1px solid #e9ecef;
}

.form-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 16px;
    text-align: center;
}

.invoice-form {
    background-color: white;
    padding: 16px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #666;
    margin-bottom: 4px;
}

.form-group input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.25);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.products-form {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e9ecef;
}

.products-form h3 {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    margin-bottom: 12px;
}

.product-form-item {
    background-color: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 12px;
    position: relative;
}

.product-form-row {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.product-form-row .product-name-group {
    background-color: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.product-form-row .product-controls {
    display: flex;
    gap: 8px;
    align-items: end;
    justify-content: space-between;
    background-color: #fff;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #dee2e6;
}

.product-form-row .product-controls .form-group {
    flex: 1;
    min-width: 0;
}

.product-form-row .product-controls .form-group:nth-child(3) {
    flex: 0 0 80px;
}

.product-form-row .product-controls .form-group:nth-child(4) {
    flex: 0 0 60px;
}

.product-form-row .product-controls .remove-product {
    flex: 0 0 40px;
    margin-bottom: 0;
}

.product-form-row .form-group {
    margin-bottom: 0;
}

.product-form-row .form-group input {
    font-size: 12px;
    padding: 6px 8px;
}

.remove-product {
    background-color: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-product:hover {
    background-color: #c82333;
}

.btn-add-product {
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
    margin-bottom: 16px;
}

.btn-add-product:hover {
    background-color: #218838;
}

.form-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 16px;
}

.btn-generate, .btn-preview {
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-generate {
    background-color: #007bff;
    color: white;
}

.btn-generate:hover {
    background-color: #0056b3;
}

.btn-preview {
    background-color: #6c757d;
    color: white;
}

.btn-preview:hover {
    background-color: #5a6268;
}

/* Header */
.header {
    background-color: white;
    border-bottom: 1px solid #e9ecef;
    position: sticky;
    top: 0;
    z-index: 100;
}

.invoice-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background-color: white;
}

.back-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    padding: 4px;
}

.invoice-info h1 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.status {
    font-size: 14px;
    color: #28a745;
    font-weight: 500;
}

.status.completed {
    color: #28a745;
}

.menu-btn {
    font-size: 18px;
    color: #666;
    cursor: pointer;
}

/* Thông tin khách hàng */
.customer-info {
    background-color: white;
    margin: 8px 0;
}

.info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #f1f3f4;
}

.info-row:last-child {
    border-bottom: none;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.label {
    font-size: 14px;
    color: #333;
}

.arrow {
    color: #999;
    font-size: 16px;
}

.doctor, .datetime {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

/* Sản phẩm */
.products {
    background-color: white;
    margin: 8px 0;
}

.product-item {
    padding: 16px;
    border-bottom: 1px solid #f1f3f4;
}

.product-item:last-child {
    border-bottom: none;
}

.product-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
}

.product-name-col {
    flex: 1;
    margin-right: 16px;
}

.product-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
    line-height: 1.4;
}

.product-code {
    font-size: 12px;
    color: #999;
    margin-bottom: 8px;
}

.price-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    flex-wrap: wrap;
}

.original-price {
    font-size: 12px;
    color: #999;
    text-decoration: line-through;
}

.discount-badge {
    background-color: #28a745;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
}

.quantity {
    font-size: 12px;
    color: #666;
    /*margin-left: auto;*/
}

.unit-price {
    font-size: 12px;
    color: #666;
}

.final-price {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    text-align: right;
    margin-top: 4px;
}

/* Tổng kết */
.summary {
    background-color: white;
    margin: 8px 0;
}

.summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #f1f3f4;
}

.summary-row:last-child {
    border-bottom: none;
}

.summary-row.highlight {
    background-color: #f8f9fa;
    font-weight: 600;
}

.summary-label {
    font-size: 14px;
    color: #333;
}

.summary-value {
    font-size: 12px;
    color: #666;
    background-color: #e9ecef;
    padding: 2px 6px;
    border-radius: 3px;
}

.summary-amount {
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.summary-amount.paid {
    color: #007bff;
}

/* Footer info */
.footer-info {
    background-color: white;
    margin: 8px 0;
    padding-bottom: 16px;
}

.creator {
    padding: 12px 16px;
    font-size: 12px;
    color: #666;
    text-align: center;
    border-top: 1px solid #f1f3f4;
}

.creator-label {
    margin-right: 4px;
}

.creator-name {
    font-weight: 500;
    color: #333;
}

.branch {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

/* Action buttons */
.action-buttons {
    padding: 16px;
    display: flex;
    gap: 12px;
    background-color: white;
    border-top: 1px solid #e9ecef;
}

.btn {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.btn-download {
    background-color: #007bff;
    color: white;
}

.btn-download:hover {
    background-color: #0056b3;
}

.btn-print {
    background-color: #28a745;
    color: white;
}

.btn-print:hover {
    background-color: #1e7e34;
}

/* Responsive design cho màn hình lớn hơn */
@media (min-width: 768px) {
    .container {
        max-width: 600px;
        margin: 20px auto;
        border-radius: 12px;
        overflow: hidden;
    }
    
    .action-buttons {
        position: sticky;
        bottom: 0;
    }
}

/* Print styles */
@media print {
    body {
        background-color: white;
    }
    
    .container {
        box-shadow: none;
        max-width: none;
        margin: 0;
    }
    
    .header {
        position: static;
    }
    
    .back-btn,
    .menu-btn,
    .action-buttons {
        display: none;
    }
    
    .product-item,
    .summary-row,
    .info-row {
        border-bottom: 1px solid #ddd;
    }
    
    .status {
        color: #000 !important;
    }
}

/* Mobile optimizations */
@media (max-width: 480px) {
    .container {
        margin: 0;
        border-radius: 0;
    }

    .invoice-title {
        padding: 12px;
    }

    .info-row,
    .product-item,
    .summary-row {
        padding: 10px 12px;
    }

    .btn {
        padding: 10px 12px;
        font-size: 13px;
    }

    .product-name {
        font-size: 13px;
    }

    .product-row {
        flex-direction: column;
        gap: 8px;
    }

    .product-name-col {
        margin-right: 0;
    }

    .final-price {
        text-align: left;
        margin-top: 0;
    }

    .product-controls {
        flex-direction: column;
        gap: 6px;
    }

    .product-form-row .product-controls {
        flex-direction: column;
        gap: 6px;
    }

    .product-form-row .product-controls .form-group:nth-child(3),
    .product-form-row .product-controls .form-group:nth-child(4) {
        flex: none;
    }

    .remove-product {
        width: 28px;
        height: 28px;
        font-size: 10px;
    }
}