/* Beta Dépannage PDF - Styles */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: #f5f5f7;
    color: #1d1d1f;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* PIN Dialog */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.dialog {
    background: white;
    padding: 32px;
    border-radius: 16px;
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.dialog h2 {
    margin-bottom: 16px;
}

.dialog p {
    margin-bottom: 20px;
    color: #666;
}

.dialog input {
    width: 100%;
    padding: 14px;
    font-size: 1.2rem;
    text-align: center;
    border: 2px solid #e5e5e5;
    border-radius: 10px;
    margin-bottom: 16px;
}

.error-text {
    color: #c00;
    margin-top: 12px;
}

/* Header */
header {
    background: linear-gradient(135deg, #007aff 0%, #5856d6 100%);
    color: white;
    padding: 24px;
    text-align: center;
}

header h1 {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 4px;
}

header .subtitle {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Main content */
main {
    padding: 24px;
}

/* Form sections */
.form-section {
    margin-bottom: 32px;
    background: #f9f9f9;
    padding: 20px;
    border-radius: 12px;
}

.form-section h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1d1d1f;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e5e5e5;
}

/* Form inputs */
.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.form-group {
    flex: 1;
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: #666;
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    border: 2px solid #e5e5e5;
    border-radius: 8px;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: #007aff;
}

/* Checkbox grid for tariffs */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.checkbox-grid .checkbox-container {
    padding: 12px;
    margin-bottom: 0;
}

/* Checkbox styling */
.checkbox-container {
    display: flex;
    align-items: flex-start;
    padding: 16px;
    margin-bottom: 12px;
    background: white;
    border-radius: 10px;
    cursor: pointer;
    border: 2px solid #e5e5e5;
    transition: all 0.2s ease;
}

.checkbox-container:hover {
    border-color: #007aff;
}

.checkbox-container:last-child {
    margin-bottom: 0;
}

.checkbox-container input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 24px;
    height: 24px;
    min-width: 24px;
    border: 2px solid #c7c7cc;
    border-radius: 6px;
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.checkbox-container input:checked + .checkmark {
    background-color: #34c759;
    border-color: #34c759;
}

.checkbox-container input:checked + .checkmark::after {
    content: "✓";
    color: white;
    font-size: 16px;
    font-weight: bold;
}

.checkbox-text {
    font-size: 0.95rem;
    line-height: 1.4;
}

/* Required checkbox */
.checkbox-container.required {
    border-color: #ffcc00;
    background: #fffef5;
}

/* Majoration box */
.majoration-box {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 2px dashed #ffcc00;
}

.majoration-box .checkbox-container {
    background: #fff8e5;
    border-color: #ffcc00;
}

/* Agreement list */
.agreement-list .checkbox-container {
    padding: 14px;
}

/* Signature section */
.signature-wrapper {
    position: relative;
    margin-bottom: 16px;
    margin-top: 16px;
}

#signatureCanvas {
    width: 100%;
    height: 180px;
    border: 2px dashed #c7c7cc;
    border-radius: 12px;
    background: white;
    touch-action: none;
}

.signature-line {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    color: #8e8e93;
    font-size: 0.9rem;
    pointer-events: none;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: linear-gradient(135deg, #007aff 0%, #5856d6 100%);
    color: white;
    width: 100%;
    font-size: 1.2rem;
    padding: 18px;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.4);
}

.btn-primary:disabled {
    background: #c7c7cc;
    cursor: not-allowed;
}

.btn-secondary {
    background: #f2f2f7;
    color: #007aff;
    margin-bottom: 16px;
}

.btn-secondary:hover {
    background: #e5e5ea;
}

/* Actions section */
.actions-section {
    margin-bottom: 0;
    padding: 24px;
    background: white;
}

/* Status message */
.status-message {
    margin-top: 16px;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    font-size: 0.95rem;
    display: none;
}

.status-message.success {
    display: block;
    background: #d1f2d9;
    color: #1d7a3e;
}

.status-message.error {
    display: block;
    background: #fdd;
    color: #c00;
}

.status-message.loading {
    display: block;
    background: #e5f0ff;
    color: #007aff;
}

/* Footer */
footer {
    background: #f5f5f7;
    padding: 16px;
    text-align: center;
    color: #8e8e93;
    font-size: 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.calibrate-link {
    color: #007aff;
    text-decoration: none;
}

/* iPad optimizations */
@media (min-width: 768px) {
    body {
        padding: 40px;
    }
    
    #signatureCanvas {
        height: 220px;
    }
    
    .checkbox-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Mobile */
@media (max-width: 600px) {
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .checkbox-grid {
        grid-template-columns: 1fr;
    }
}

/* Landscape mode */
@media (orientation: landscape) and (max-height: 500px) {
    .container {
        max-width: 100%;
    }
    
    #signatureCanvas {
        height: 150px;
    }
}

/* ============================================================================
   TARIFF TABLE STYLING
   ============================================================================ */

.tariff-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.tariff-table thead {
    background: #f5f5f7;
}

.tariff-table th {
    padding: 12px 8px;
    text-align: left;
    font-size: 0.85rem;
    font-weight: 600;
    color: #666;
    border-bottom: 2px solid #e5e5e5;
}

.tariff-table th:first-child {
    text-align: center;
    width: 40px;
}

.tariff-table th:nth-child(3),
.tariff-table th:nth-child(4),
.tariff-table th:nth-child(5) {
    text-align: right;
    width: 80px;
}

.tariff-table td {
    padding: 12px 8px;
    font-size: 0.9rem;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

.tariff-table td:first-child {
    text-align: center;
}

.tariff-table td:nth-child(3),
.tariff-table td:nth-child(4),
.tariff-table td:nth-child(5) {
    text-align: right;
    font-family: 'SF Mono', Menlo, monospace;
    font-size: 0.85rem;
}

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

.tariff-table input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* Required note */
.required-note {
    font-size: 0.85rem;
    color: #ff3b30;
    margin-bottom: 12px;
}

.required-star {
    color: #ff3b30;
    font-weight: bold;
}

/* Mobile tariff table */
@media (max-width: 600px) {
    .tariff-table {
        font-size: 0.85rem;
    }
    
    .tariff-table th,
    .tariff-table td {
        padding: 8px 4px;
    }
    
    .tariff-table th:nth-child(3),
    .tariff-table th:nth-child(4),
    .tariff-table td:nth-child(3),
    .tariff-table td:nth-child(4) {
        display: none; /* Hide HT and TVA on mobile, show only TTC */
    }
}
