/* CSS Variables - Light Mode */
:root {
    --bg-primary: #f5f5f7;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f0f0f2;
    --accent-primary: #0066cc;
    --accent-secondary: #00a651;
    --text-primary: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-muted: #86868b;
    --border-color: #d2d2d7;
    --success: #34c759;
    --danger: #ff3b30;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --radius-sm: 4px;
    --radius-md: 6px;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* App Container */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.logo-mark {
    width: 44px;
    height: 44px;
    background: var(--accent-primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Space Mono', monospace;
    font-weight: 700;
    font-size: 1.1rem;
    color: white;
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.app-domain {
    margin-left: auto;
    font-family: 'Space Mono', monospace;
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 0.25rem 0.6rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

/* "Mede mogelijk gemaakt door" credit under the preview */
.powered-by {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.powered-by a {
    display: inline-flex;
    align-items: center;
    transition: opacity 0.2s;
}

.powered-by a:hover {
    opacity: 0.75;
}

.powered-by-logo {
    height: 32px;
    width: auto;
    display: block;
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 1100px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

/* Sections */
.editor-section,
.preview-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.section-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.preview-badge {
    font-size: 0.7rem;
    font-weight: 500;
    padding: 0.25rem 0.6rem;
    background: rgba(52, 199, 89, 0.15);
    color: var(--success);
    border-radius: 12px;
    border: 1px solid rgba(52, 199, 89, 0.3);
}

/* Form Elements */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group > label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group textarea {
    width: 100%;
    padding: 0.65rem 0.85rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group textarea {
    resize: vertical;
    min-height: 70px;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.15);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

/* Logo Checkboxes */
.logo-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

/* Color pickers */
.color-pickers {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.color-picker {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
    font-size: 0.85rem;
    color: var(--text-primary);
    padding: 0.35rem 0.55rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.color-picker input[type="color"] {
    width: 32px;
    height: 24px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    cursor: pointer;
    background: transparent;
}

.color-picker input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 2px;
}

.btn-small {
    font-size: 0.75rem;
    padding: 0.35rem 0.65rem;
}

/* Note alignment radios */
.align-options {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.align-label {
    font-weight: 500;
}

.radio-label {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
    user-select: none;
    color: var(--text-primary);
}

.radio-label input[type="radio"] {
    accent-color: var(--accent-primary);
    cursor: pointer;
}

/* Checkbox */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
    font-size: 0.85rem;
    color: var(--text-primary);
}

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

.checkbox-custom {
    width: 18px;
    height: 18px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.checkbox-label input:checked + .checkbox-custom {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.checkbox-custom::after {
    content: '✓';
    color: white;
    font-size: 0.75rem;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.2s;
}

.checkbox-label input:checked + .checkbox-custom::after {
    opacity: 1;
    transform: scale(1);
}

/* Tariffs Section */
.tariffs-section {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-color);
}

.tariffs-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.tariffs-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.tariffs-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

/* Tariff Item */
.tariff-item {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.85rem;
    transition: all 0.2s;
}

.tariff-item.inactive {
    opacity: 0.5;
    border-style: dashed;
}

.tariff-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.6rem;
}

.tariff-name {
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tariff-status {
    font-size: 0.65rem;
    padding: 0.15rem 0.4rem;
    border-radius: 8px;
    font-weight: 500;
}

.tariff-status.active {
    background: rgba(52, 199, 89, 0.15);
    color: var(--success);
}

.tariff-status.inactive {
    background: rgba(255, 59, 48, 0.15);
    color: var(--danger);
}

.tariff-controls {
    display: flex;
    gap: 0.4rem;
}

.tariff-fields {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
}

.tariff-field label {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
}

.tariff-field input {
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn .icon {
    font-size: 0.9rem;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: #0055aa;
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-add {
    background: transparent;
    color: var(--accent-primary);
    border: 1px dashed var(--accent-primary);
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
}

.btn-add:hover {
    background: rgba(0, 102, 204, 0.1);
}

.btn-icon {
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-radius: 3px;
}

.btn-icon:hover {
    color: var(--text-primary);
    background: var(--border-color);
}

.btn-icon.danger:hover {
    color: var(--danger);
    background: rgba(255, 59, 48, 0.15);
    border-color: var(--danger);
}

.actions {
    display: flex;
    gap: 0.6rem;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-color);
}

/* Preview Container */
.preview-container {
    background: #e8e8e8;
    border-radius: var(--radius-sm);
    padding: 1.5rem;
    min-height: 350px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

/* ==========================================
   TARIEFKAART STYLING
   Size: Half A4 (approx 148mm x 105mm)
   Square corners, no rounded edges
   Colors are driven by CSS variables that can be overridden by the user.
   ========================================== */
.tariefkaart {
    --card-bg: #29b6f6;
    --card-panel-bg: #ffffff;
    --card-text: #000000;
    --card-line: #000000;
    width: 148mm;
    background-color: var(--card-bg) !important;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--card-text);
    padding: 6px;
    display: inline-block;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
}

.tariefkaart * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
}

/* Payment logos row - height is synced to the company name box at runtime */
.tariefkaart-logos {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 4px 12px;
    background-color: var(--card-panel-bg) !important;
    border: 1px solid var(--card-line);
    margin-bottom: 5px;
}

/* Logo wrapper (contains an inline <svg>). Default height; individual
   logos override this to compensate for differing amounts of internal
   whitespace in their source SVGs so they all appear visually balanced. */
.tariefkaart-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 50px;
}

.tariefkaart-logo svg {
    height: 100%;
    width: auto;
    max-width: 180px;
    display: block;
}

/* PIN has a 1:1 viewBox with lots of empty space around the actual content,
   so we make it a bit taller to balance visually with the other logos. */
.tariefkaart-logo--pin     { height: 64px; }
.tariefkaart-logo--maestro { height: 50px; }
.tariefkaart-logo--mastercard { height: 50px; }
/* VISA is very wide (3:1) and dense; slightly smaller keeps it from
   dominating the row. */
.tariefkaart-logo--visa    { height: 42px; }
.tariefkaart-logo--tikkie  { height: 48px; }

.tariefkaart-logo-text {
    font-weight: bold;
    font-size: 13px;
    color: var(--card-text);
    padding: 4px 8px;
    border: 1px dashed #999;
}

/* Company header */
.tariefkaart-header {
    background-color: var(--card-panel-bg) !important;
    color: var(--card-text);
    padding: 8px 12px;
    text-align: center;
    border: 1px solid var(--card-line);
    margin-bottom: 5px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tariefkaart-company {
    font-weight: bold;
    white-space: nowrap;
    display: inline-block;
    line-height: 1.1;
}

/* Table styling.
   The table itself uses border-collapse: separate with explicit per-cell
   borders (right + bottom only) so internal lines render at exactly 1px.
   The outer perimeter is drawn by the wrapper div's border — this is more
   reliable than relying on outer cell borders, which html2canvas does not
   render consistently. The net effect: every line, inner and outer, is
   visually identical at 1px. */
.tariefkaart-table-wrapper {
    border: 1px solid var(--card-line);
    margin-bottom: 5px;
    background-color: var(--card-panel-bg) !important;
}

.tariefkaart-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    color: var(--card-text);
}

.tariefkaart-table th,
.tariefkaart-table td {
    border-right: 1px solid var(--card-line);
    border-bottom: 1px solid var(--card-line);
    padding: 8px 6px;
    text-align: center;
    vertical-align: middle;
    font-weight: bold;
    word-wrap: break-word;
    background-color: var(--card-panel-bg) !important;
    color: var(--card-text);
    line-height: 1.2;
}

/* The last column / last row don't need their right/bottom borders since
   the wrapper provides the outer perimeter. */
.tariefkaart-table tr > *:last-child { border-right: none; }
.tariefkaart-table tbody tr:last-child > * { border-bottom: none; }

.tariefkaart-table thead th {
    background-color: var(--card-panel-bg) !important;
    font-weight: bold;
    font-size: 12px;
    padding: 6px 4px;
}

.tariefkaart-table tbody td {
    background-color: var(--card-panel-bg) !important;
    height: 36px;
    overflow: hidden;
}

.tariefkaart-table tbody td.col-tarief {
    font-weight: bold;
    font-size: 20px;
    width: 60px;
}

/* Auto-scaled data cell text wrapper */
.tariefkaart-table .cell-text {
    display: inline-block;
    white-space: nowrap;
    line-height: 1.1;
    font-weight: bold;
}

/* Column widths */
.tariefkaart-table thead th:first-child {
    width: 60px;
}

/* Footer note */
.tariefkaart-note {
    font-size: 10px;
    font-style: italic;
    color: var(--card-text);
    padding: 6px 8px;
    background-color: var(--card-panel-bg) !important;
    border: 1px solid var(--card-line);
    text-align: left;
    line-height: 1.35;
    white-space: pre-wrap;
}

/* Print Styles */
@media print {
    body {
        background: white !important;
    }
    
    .app-header,
    .editor-section,
    .section-header,
    .actions {
        display: none !important;
    }
    
    .preview-section {
        background: none !important;
        border: none !important;
        padding: 0 !important;
        box-shadow: none !important;
    }
    
    .preview-container {
        background: white !important;
        padding: 0 !important;
    }
    
    .tariefkaart {
        margin: 0 !important;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tariff-item {
    animation: fadeIn 0.2s ease-out;
}
