/**
 * Meck-Pomm Elektronik - Shared Styles
 * =====================================
 * Gemeinsame Styles für alle Geschäftsdokumente
 * Version: 2.0 | Stand: 02/2026
 */

/* === CSS Variablen === */
:root {
    --primary: #005f73;
    --primary-dark: #003d4d;
    --primary-light: #e8f4f8;
    --secondary: #2c3e50;
    --accent: #3498db;
    --success: #28a745;
    --warning: #ffc107;
    --warning-bg: #fff3cd;
    --danger: #dc3545;
    --danger-light: #fdf2f2;
    --text: #333;
    --text-light: #666;
    --text-muted: #888;
    --border: #ddd;
    --border-light: #eee;
    --bg: #fff;
    --bg-light: #f8f9fa;
    --bg-hover: #f0f8ff;
    
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --max-width: 210mm;
    --page-margin: 20mm 10mm 20mm 25mm; /* DIN-5008: Top, Right, Bottom, Left */
}

/* === Print Marks (DIN-5008) === */
.print-mark {
    display: none;
    position: fixed;
    left: 0;
    width: 5mm;
    border-top: 0.1pt solid #000;
    z-index: 9999;
}

@media print {
    .print-mark { display: block; }
    .fold-mark-1 { top: 87mm; }
    .fold-mark-2 { top: 192mm; }
    .hole-mark { top: 148.5mm; width: 10mm; }
}

/* === Dark Mode === */
[data-theme="dark"] {
    --primary: #0d8a9f;
    --primary-dark: #005f73;
    --primary-light: #1a3a42;
    --secondary: #34495e;
    --text: #e0e0e0;
    --text-light: #b0b0b0;
    --text-muted: #888;
    --border: #444;
    --border-light: #333;
    --bg: #1a1a1a;
    --bg-light: #252525;
    --bg-hover: #2a2a2a;
}

/* === Reset & Basis === */
*, *::before, *::after { box-sizing: border-box; }

html {
    font-size: 14px;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

body {
    font-family: var(--font-family);
    color: var(--text);
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 40px;
    background-color: var(--bg);
    line-height: 1.6;
}

/* === Print Styles === */
@media print {
    @page {
        size: A4;
        margin: var(--page-margin);
    }
    
    body {
        margin: 0 !important;
        padding: 0 !important;
        width: 100%;
        background: white !important;
        color: black !important;
        font-size: 11pt; /* DIN-5008 Standard */
    }

    /* Repeat Header & Footer */
    thead { display: table-header-group; }
    tfoot { display: table-footer-group; }

    .header {
        display: table-header-group;
        width: 100%;
        margin-bottom: 40px;
    }

    .footer {
        display: table-footer-group;
        width: 100%;
        position: fixed;
        bottom: 0;
    }
    
    .no-print,
    .toolbar,
    .btn-add,
    .btn-remove,
    .theme-toggle {
        display: none !important;
    }
    
    .page-break-before { page-break-before: always; }
    .page-break-after { page-break-after: always; }
    .no-break { page-break-inside: avoid; }
    
    .header, .footer, .section, .totals, .notes, .qr-section {
        page-break-inside: avoid;
    }
    
    table tr { page-break-inside: avoid; }
    
    [contenteditable] {
        border: none !important;
        background: transparent !important;
        outline: none !important;
    }
    
    input[type="number"], input[type="text"], select {
        border: none !important;
        background: transparent !important;
        -webkit-appearance: none;
    }
    
    input::-webkit-outer-spin-button,
    input::-webkit-inner-spin-button {
        -webkit-appearance: none;
        margin: 0;
    }
    
    .field, .form-field {
        border-bottom: 1px solid #999 !important;
        background: transparent !important;
    }
    
    .field:empty::after { content: '' !important; }
}

/* === Header === */
.header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--primary);
}

.company-info img {
    max-width: 220px;
    margin-bottom: 8px;
    display: block;
}

.company-info h1 {
    color: var(--primary);
    margin: 0;
    font-size: 1.4em;
}

.company-info p {
    margin: 4px 0;
    color: var(--text-light);
    font-size: 0.85em;
}

.doc-title {
    text-align: right;
}

.doc-title h2 {
    font-size: 2.2em;
    color: var(--primary);
    margin: 0 0 10px 0;
    text-transform: uppercase;
}

.doc-details table {
    width: auto;
    margin-left: auto;
    font-size: 0.9em;
}

.doc-details td {
    padding: 3px 0 3px 15px;
    text-align: right;
}

.doc-details td:first-child {
    color: var(--text-light);
}

/* === Address Section === */
.address-section {
    margin-bottom: 30px;
}

.sender-line {
    font-size: 10px;
    text-decoration: underline;
    color: var(--text-light);
    margin-bottom: 8px;
}

.recipient-address {
    line-height: 1.6;
}

/* === Sections === */
.section {
    margin-bottom: 20px;
    border: 1px solid var(--border);
    padding: 15px;
    border-radius: 4px;
}

.section-title {
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 10px;
    text-transform: uppercase;
    font-size: 14px;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 5px;
}

/* === Grid Layouts === */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 15px;
}

/* === Form Elements === */
.form-row {
    margin-bottom: 12px;
    display: flex;
    align-items: baseline;
}

.form-row label {
    width: 160px;
    font-weight: 600;
    flex-shrink: 0;
    color: var(--text-light);
}

.form-row .field {
    flex: 1;
    border-bottom: 1px dotted #999;
    min-height: 22px;
    padding: 2px 5px;
}

.field:empty::after {
    content: attr(data-placeholder);
    color: #bbb;
    font-style: italic;
}

[contenteditable]:hover {
    background-color: var(--bg-hover);
    cursor: text;
    border-radius: 3px;
}

[contenteditable]:focus {
    outline: 2px solid var(--primary);
    border-radius: 3px;
}

/* === Tables === */
.items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 10px;
}

.items-table th {
    text-align: left;
    padding: 10px 12px;
    background-color: var(--primary);
    color: white;
    font-weight: 500;
}

.items-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.items-table .col-pos { width: 45px; text-align: center; }
.items-table .col-desc { width: auto; }
.items-table .col-qty { width: 70px; text-align: center; }
.items-table .col-price { width: 110px; text-align: right; }
.items-table .col-total { width: 110px; text-align: right; font-weight: bold; }
.items-table .col-action { width: 40px; text-align: center; }

.items-table input[type="number"] {
    width: 80px;
    padding: 4px 6px;
    border: 1px solid var(--border);
    border-radius: 3px;
    text-align: right;
    font-size: 14px;
    font-family: inherit;
}

.items-table input[type="number"]:focus {
    outline: 2px solid var(--primary);
    border-color: var(--primary);
}

/* === Totals === */
.totals {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 30px;
}

.totals-table {
    width: 300px;
    border-collapse: collapse;
}

.totals-table td {
    padding: 6px 8px;
    text-align: right;
    font-size: 0.95em;
}

.totals-table td:first-child {
    color: var(--text-light);
}

.totals-table .total-row {
    font-size: 1.15em;
    font-weight: bold;
    color: var(--primary);
    border-top: 2px solid var(--primary);
}

/* === Buttons === */
.toolbar {
    position: fixed;
    top: 15px;
    right: 15px;
    display: flex;
    gap: 8px;
    z-index: 1000;
}

.toolbar button {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: background-color 0.2s;
}

.toolbar button:hover {
    background-color: var(--primary-dark);
}

.toolbar button.btn-secondary {
    background-color: #6c757d;
}

.toolbar button.btn-secondary:hover {
    background-color: #545b62;
}

.toolbar button.btn-success {
    background-color: var(--success);
}

.toolbar button.btn-warning {
    background-color: #fd7e14;
}

.toolbar button.btn-danger {
    background-color: var(--danger);
}

.btn-add {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    margin-bottom: 20px;
}

.btn-add:hover {
    background: var(--primary-dark);
}

.btn-remove {
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}

.btn-remove:hover {
    background: #a71d2a;
}

/* === Theme Toggle === */
.theme-toggle {
    background: var(--secondary) !important;
    font-size: 18px !important;
    padding: 10px 14px !important;
}

/* === Notes & Info Boxes === */
.notes {
    margin-top: 25px;
    padding: 12px 15px;
    background-color: var(--bg-light);
    border-left: 4px solid var(--primary);
    font-size: 0.9em;
}

.notes p { margin: 5px 0; }

.info-box {
    background: var(--primary-light);
    border: 1px solid var(--primary);
    padding: 12px 15px;
    border-radius: 6px;
    margin: 20px 0;
    font-size: 0.9em;
}

.info-box strong { color: var(--primary); }

.warning-box {
    background: var(--warning-bg);
    border: 1px solid var(--warning);
    padding: 12px 15px;
    border-radius: 6px;
    margin: 20px 0;
    font-size: 0.9em;
}

.warning-box strong { color: #856404; }

.success-box {
    background: #d4edda;
    border: 1px solid var(--success);
    padding: 12px 15px;
    border-radius: 6px;
    margin: 20px 0;
}

.success-box strong { color: #155724; }

/* === QR Code Section === */
.qr-section {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 15px 0;
    padding: 8px 10px;
    background: var(--primary-light);
    border: 1px solid var(--primary);
    border-radius: 6px;
}

.qr-section canvas { flex-shrink: 0; }

.qr-section .qr-text {
    font-size: 0.8em;
    color: var(--text-light);
    line-height: 1.5;
}

.qr-section .qr-text strong { color: var(--primary); }

/* === Signature === */
.signature-area {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 60px;
    margin-top: 40px;
}

.signature-block { text-align: center; }

.signature-line {
    border-top: 1px solid var(--text);
    margin-top: 60px;
    padding-top: 5px;
    font-size: 12px;
    color: var(--text-light);
}

/* === Footer === */
.footer {
    margin-top: 50px;
    text-align: center;
    font-size: 10.5px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    padding-top: 15px;
}

.footer p {
    margin: 0;
    line-height: 1.6;
}

/* === Checkbox & Radio === */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 5px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.checkbox-box {
    width: 14px;
    height: 14px;
    border: 1.5px solid var(--primary);
    border-radius: 2px;
    display: inline-block;
}

.rating-box {
    width: 14px;
    height: 14px;
    border: 1.5px solid var(--primary);
    border-radius: 2px;
    display: inline-block;
}

/* === Special Elements === */
.device-box {
    margin-bottom: 25px;
    padding: 12px 15px;
    background-color: #fff8e6;
    border-left: 4px solid #d4a848;
    border-radius: 5px;
}

.diagnose-section {
    margin-bottom: 25px;
    padding: 12px 15px;
    background-color: #f0f8f0;
    border-left: 4px solid var(--success);
    border-radius: 5px;
}

.diff-hinweis {
    margin-top: 20px;
    padding: 10px 15px;
    background: var(--warning-bg);
    border: 1px solid var(--warning);
    border-radius: 4px;
    font-size: 0.85em;
}

.price-section {
    margin: 25px 0;
    padding: 15px;
    background: var(--primary-light);
    border-radius: 4px;
    text-align: center;
}

.price-section .price {
    font-size: 1.8em;
    font-weight: bold;
    color: var(--primary);
}

/* === Legal Text === */
.legal-text {
    font-size: 10px;
    color: var(--text-light);
    margin-bottom: 20px;
    line-height: 1.4;
    text-align: justify;
}

.legal-section {
    margin: 25px 0;
    padding: 15px;
    background-color: var(--bg-light);
    border-left: 4px solid var(--primary);
    font-size: 0.9em;
    line-height: 1.7;
}

.legal-section h3 {
    color: var(--primary);
    margin: 0 0 8px 0;
    font-size: 1em;
}

/* === Condition Table === */
.condition-table {
    width: 100%;
    border-collapse: collapse;
}

.condition-table th, .condition-table td {
    border: 1px solid var(--border);
    padding: 8px 12px;
    text-align: left;
}

.condition-table th {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
}

/* === Price Table (Preisliste) === */
.price-category {
    margin-bottom: 40px;
}

.price-category h2 {
    color: var(--accent);
    border-bottom: 2px solid var(--accent);
    padding-bottom: 10px;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.price-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.price-table th {
    background: var(--bg-light);
    padding: 12px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #bdc3c7;
}

.price-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-light);
}

.price-table tr:hover {
    background: var(--bg-light);
}

.price-value {
    font-weight: 600;
    color: var(--success);
    text-align: right;
    white-space: nowrap;
}

.price-surcharge {
    background: var(--warning-bg);
    font-weight: 600;
    color: #e67e22;
}

.price-free {
    color: var(--success);
    font-weight: 600;
}

.badge {
    display: inline-block;
    background: var(--danger);
    color: white;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.75rem;
    margin-left: 8px;
}

/* === Checklist === */
.checklist {
    list-style: none;
    padding: 0;
}

.checklist li {
    padding: 6px 0;
    border-bottom: 1px solid #f0f0f0;
}

.checklist li::before {
    content: "\2610";
    margin-right: 10px;
    font-size: 16px;
}

/* === Photo Area === */
.photo-area {
    min-height: 100px;
    border: 2px dashed var(--border);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-style: italic;
}

/* === Drawing Box === */
.drawing-box {
    height: 120px;
    border: 1px dashed var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 11px;
    background-color: var(--bg-light);
}

/* === Pattern Grid (für Muster) === */
.pattern-grid {
    width: 80px;
    height: 80px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    justify-content: center;
    margin-top: 10px;
}

.dot {
    width: 6px;
    height: 6px;
    background-color: var(--text);
    border-radius: 50%;
    display: block;
    margin: auto;
}

/* === Status Indicator === */
.status-indicator {
    padding: 10px 14px;
    border-radius: 5px;
    color: white;
    font-size: 12px;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    background: #6c757d;
}

.status-online { background: var(--success); }
.status-offline { background: var(--danger); }

/* === Toast === */
.toast {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 6px;
    color: white;
    font-size: 14px;
    z-index: 1002;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    transition: opacity 0.3s;
}

/* === Validation === */
.validation-error {
    border: 2px solid var(--danger) !important;
    background-color: var(--danger-light) !important;
}

.validation-message {
    color: var(--danger);
    font-size: 12px;
    margin-top: 4px;
}

/* === Responsive === */
@media screen and (max-width: 768px) {
    body {
        padding: 20px;
    }
    
    .header {
        flex-direction: column;
        gap: 20px;
    }
    
    .doc-title {
        text-align: left;
    }
    
    .grid-2, .grid-3 {
        grid-template-columns: 1fr;
    }
    
    .toolbar {
        position: relative;
        top: auto;
        right: auto;
        flex-wrap: wrap;
        justify-content: center;
        margin-bottom: 20px;
    }
    
    .signature-area {
        grid-template-columns: 1fr;
        gap: 40px;
    }
}