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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f5f5;
    padding: 10px;
    line-height: 1.6;
    position: relative;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid #2c3e50;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

header > div:first-child {
    text-align: left;
}

header h1 {
    color: #2c3e50;
    font-size: 24px;
    margin-bottom: 5px;
}

.subtitle {
    color: #666;
    font-size: 14px;
}

.section {
    margin-bottom: 20px;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
}

.section h2 {
    color: #2c3e50;
    font-size: 18px;
    margin-bottom: 10px;
    border-bottom: 2px solid #3498db;
    padding-bottom: 5px;
}

.field {
    margin-bottom: 10px;
}

.field label {
    display: block;
    font-weight: bold;
    color: #555;
    margin-bottom: 5px;
}

.field input[type="text"],
.field input[type="date"],
.field input[type="tel"],
.field input[type="email"],
.field input[type="number"] {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
}

.row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"],
.checkbox-group input[type="radio"] {
    cursor: pointer;
}

.note {
    font-size: 12px;
    color: #666;
    font-style: italic;
    margin-top: 10px;
}

.services-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.services-table th {
    background: #2c3e50;
    color: white;
    padding: 10px;
    text-align: left;
}

.services-table td {
    padding: 8px;
    border-bottom: 1px solid #ddd;
}

.services-table input[type="number"] {
    width: 60px;
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 3px;
}

.services-table input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
}

.line-total {
    font-weight: bold;
    color: #27ae60;
}

.guarantee-field .checkbox-group input[type="number"] {
    width: 80px;
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 3px;
}

.totals {
    background: #ecf0f1;
}

.total-row {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    font-size: 16px;
}

.total-row.final {
    background: #2c3e50;
    color: white;
    font-weight: bold;
    font-size: 20px;
    border-radius: 5px;
    margin-top: 10px;
}

.tva-row {
    display: flex;
    gap: 20px;
    padding: 10px;
    justify-content: center;
}

.terms {
    font-size: 13px;
    color: #555;
    text-align: center;
    font-style: italic;
    padding: 10px;
}

.signatures {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.signature-box {
    text-align: center;
}

.signature-box h3 {
    margin-bottom: 10px;
    color: #2c3e50;
}

.signature-box canvas {
    border: 2px solid #2c3e50;
    border-radius: 5px;
    background: white;
    cursor: crosshair;
    width: 100%;
    max-width: 300px;
    height: 150px;
}

.clear-btn {
    margin-top: 10px;
    padding: 5px 15px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}

.clear-btn:hover {
    background: #c0392b;
}

footer {
    text-align: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #2c3e50;
    color: #555;
    font-size: 14px;
}

footer p {
    margin: 3px 0;
}

.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.action-buttons button {
    padding: 12px 25px;
    font-size: 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    background: #3498db;
    color: white;
    transition: background 0.3s;
}

.action-buttons button:hover {
    background: #2980b9;
}

/* Print styles */
@media print {
    body {
        background: white;
        padding: 0;
    }

    .container {
        box-shadow: none;
        max-width: 100%;
        padding: 10px;
    }

    .no-print {
        display: none !important;
    }

    .section {
        page-break-inside: avoid;
    }

    .signature-box canvas {
        border: 1px solid #000;
    }
}

/* Bons List Modal */
.bons-list-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.bons-list-container {
    background: white;
    border-radius: 10px;
    max-width: 1000px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

.bons-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 2px solid #2c3e50;
}

.bons-list-header h2 {
    margin: 0;
    color: #2c3e50;
}

.close-btn {
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background: #c0392b;
}

.bons-search {
    padding: 15px 20px;
    background: #f5f5f5;
}

.bons-search input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 14px;
}

.bons-list-content {
    overflow-y: auto;
    padding: 20px;
    flex: 1;
}

.no-bons {
    text-align: center;
    color: #999;
    padding: 40px;
    font-size: 16px;
}

.bons-table {
    width: 100%;
    border-collapse: collapse;
}

.bons-table th {
    background: #2c3e50;
    color: white;
    padding: 12px;
    text-align: left;
    font-weight: 600;
    position: sticky;
    top: 0;
}

.bons-table td {
    padding: 12px;
    border-bottom: 1px solid #ddd;
}

.bons-table tr:hover {
    background: #f9f9f9;
}

.status-draft {
    background: #f39c12;
    color: white;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: bold;
}

.status-finalized {
    background: #27ae60;
    color: white;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: bold;
}

.actions {
    display: flex;
    gap: 8px;
}

.btn-edit {
    background: #3498db;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

.btn-edit:hover {
    background: #2980b9;
}

.btn-delete {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

.btn-delete:hover {
    background: #c0392b;
}

/* Statistics */
.stats-content {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(90vh - 100px);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

.stat-card.primary {
    background: #e3f2fd;
    border-color: #2196f3;
}

.stat-card.success {
    background: #e8f5e9;
    border-color: #4caf50;
}

.stat-card.warning {
    background: #fff3e0;
    border-color: #ff9800;
}

.stat-value {
    font-size: 28px;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 14px;
    color: #666;
    text-transform: uppercase;
}

/* Mobile responsive */
@media (max-width: 768px) {
    body {
        padding: 5px;
    }

    .container {
        padding: 15px;
    }

    header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    header h1 {
        font-size: 20px;
    }

    .subtitle {
        font-size: 12px;
    }

    header > div:first-child {
        width: 100%;
    }

    header > div:last-child {
        width: 100%;
    }

    header > div:last-child button {
        width: 100%;
    }

    .section {
        padding: 12px;
    }

    .section h2 {
        font-size: 16px;
    }

    .row, .signatures {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .services-table {
        font-size: 11px;
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .services-table thead {
        display: none;
    }

    .services-table tbody {
        display: block;
    }

    .services-table tr {
        display: flex;
        flex-direction: column;
        border: 1px solid #ddd;
        margin-bottom: 10px;
        padding: 10px;
        border-radius: 5px;
        background: #f9f9f9;
    }

    .services-table td {
        display: flex;
        justify-content: space-between;
        padding: 5px 0;
        border: none;
    }

    .services-table td:before {
        content: attr(data-label);
        font-weight: bold;
        margin-right: 10px;
    }

    .services-table input[type="checkbox"] {
        order: -1;
    }

    .services-table input[type="number"] {
        width: 80px;
    }

    .checkbox-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .signature-box canvas {
        width: 100%;
        max-width: 100%;
        height: 120px;
    }

    .bons-list-overlay {
        padding: 5px;
    }

    .bons-list-container {
        max-height: 95vh;
    }

    .bons-list-header {
        padding: 15px;
    }

    .bons-list-header h2 {
        font-size: 18px;
    }

    .bons-search {
        padding: 10px;
    }

    .bons-list-content {
        padding: 10px;
    }

    .bons-table {
        font-size: 11px;
        display: block;
        overflow-x: auto;
    }

    .bons-table thead {
        display: none;
    }

    .bons-table tbody {
        display: block;
    }

    .bons-table tr {
        display: block;
        border: 1px solid #ddd;
        margin-bottom: 10px;
        padding: 12px;
        border-radius: 5px;
    }

    .bons-table td {
        display: flex;
        justify-content: space-between;
        padding: 5px 0;
        border: none;
    }

    .bons-table td:before {
        content: attr(data-label);
        font-weight: bold;
        flex-shrink: 0;
        margin-right: 10px;
    }

    .bons-table td.actions {
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid #ddd;
    }

    .bons-table td.actions:before {
        display: none;
    }

    .actions {
        flex-direction: row;
        gap: 8px;
        width: 100%;
    }

    .btn-edit,
    .btn-delete {
        font-size: 12px;
        padding: 8px 12px;
        flex: 1;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        padding: 15px;
    }

    .action-buttons {
        gap: 8px;
        width: 100%;
    }

    .action-buttons button {
        padding: 12px 15px;
        font-size: 14px;
        flex: 1 1 45%;
    }

    .total-row {
        font-size: 14px;
    }

    .total-row.final {
        font-size: 18px;
    }

    .tva-row {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .field input[type="text"],
    .field input[type="date"],
    .field input[type="tel"],
    .field input[type="email"],
    .field input[type="number"] {
        font-size: 16px;
        padding: 10px;
    }

    .sync-status {
        bottom: 10px;
        right: 10px;
        left: 10px;
        padding: 10px 15px;
        font-size: 12px;
    }
}

/* Sync status indicator */
.sync-status {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #ff9800;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 10000;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.sync-icon {
    font-size: 20px;
}

.sync-text {
    font-size: 14px;
    font-weight: 500;
}

.sync-btn {
    background: white;
    color: #ff9800;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
}

.sync-btn:hover {
    background: #f5f5f5;
    transform: scale(1.05);
}

.sync-btn:active {
    transform: scale(0.95);
}

@media print {
    .sync-status {
        display: none !important;
    }
}
