/* ============================================
   COLOR PALETTE
   Light mode: bg #f5f5f5, main #6dc58d, text #333333
   Dark mode:  bg #0d1117, main #6dc58d, text #e6edf3
   ============================================ */

:root {
    --bg-page: #f5f5f5;
    --bg-card: #ffffff;
    --bg-input: #fafafa;
    --bg-hover: rgba(109, 197, 141, 0.15);
    --bg-stat: #f8f9fa;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-muted: #999999;
    --text-inverse: #ffffff;
    --brand-primary: #6dc58d;
    --brand-primary-hover: #5ab47a;
    --brand-primary-light: rgba(109, 197, 141, 0.15);
    --border-light: #e9ecef;
    --border-medium: #cccccc;
    --success: #6dc58d;
    --success-bg: rgba(109, 197, 141, 0.2);
    --success-text: #333333;
    --error: #c75c5c;
    --error-bg: #f5e1e1;
    --error-text: #994444;
    --warning: #d4a24c;
    --warning-bg: #fef6e6;
    --warning-text: #8a6914;
    --shadow-sm: rgba(0, 0, 0, 0.1);
    --theme-transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* ============================================
   DARK MODE OVERRIDES
   ============================================ */
[data-theme="dark"] {
    --bg-page: #0d1117;
    --bg-card: #161b22;
    --bg-input: #21262d;
    --bg-hover: rgba(109, 197, 141, 0.15);
    --bg-stat: #21262d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --text-inverse: #0d1117;
    --brand-primary: #6dc58d;
    --brand-primary-hover: #5ab47a;
    --brand-primary-light: rgba(109, 197, 141, 0.15);
    --border-light: #30363d;
    --border-medium: #3d444d;
    --success: #6dc58d;
    --success-bg: rgba(109, 197, 141, 0.2);
    --success-text: #e6edf3;
    --error: #d47272;
    --error-bg: #3d2222;
    --error-text: #e8a0a0;
    --warning: #d4a24c;
    --warning-bg: #3d3000;
    --warning-text: #e8c56c;
    --shadow-sm: rgba(0, 0, 0, 0.3);
}

/* ============================================
   RESET & BASE
   ============================================ */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: var(--theme-transition);
}

/* ============================================
   THEME TOGGLE BUTTON
   ============================================ */
.theme-toggle {
    position: fixed;
    top: 1rem;
    right: 1rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid var(--border-light);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    transition: var(--theme-transition), transform 0.2s ease;
    z-index: 1000;
    box-shadow: 0 2px 8px var(--shadow-sm);
}

.theme-toggle:hover {
    border-color: var(--brand-primary);
    color: var(--brand-primary);
    transform: scale(1.05);
}

.theme-toggle .icon-sun { display: block; }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* ============================================
   LAYOUT
   ============================================ */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1rem 2rem;
    flex: 1;
}

header {
    text-align: center;
    margin-bottom: 1.5rem;
    transition: var(--theme-transition);
}

h1 {
    color: var(--brand-primary);
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

h2 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

/* ============================================
   CARDS
   ============================================ */
.card {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 10px var(--shadow-sm);
    transition: var(--theme-transition);
}

/* ============================================
   ICON BUTTONS (upload area)
   ============================================ */
.icon-row {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
}

.icon-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border: 2px solid var(--border-light);
    border-radius: 12px;
    background: var(--bg-input);
    cursor: pointer;
    transition: var(--theme-transition), border-color 0.2s, transform 0.2s;
    text-decoration: none;
    color: var(--text-secondary);
}

.icon-btn:hover {
    border-color: var(--brand-primary);
    background: var(--bg-hover);
    transform: translateY(-2px);
}

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

.icon-btn img {
    width: 120px;
    height: 120px;
}

.icon-btn .icon-placeholder {
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: var(--brand-primary);
    opacity: 0.6;
}

.icon-btn span {
    font-size: 1.1rem;
    font-weight: 700;
}

.icon-btn input[type="file"] {
    display: none;
}

/* ============================================
   DEBTOR SETTINGS
   ============================================ */
.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.settings-header h2 {
    margin-bottom: 0;
}

.consent-toggle {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
    transition: color 0.2s;
}

.consent-toggle:hover {
    color: var(--brand-primary);
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}

label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-secondary);
}

input[type="text"], input[type="date"] {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    font-size: 0.95rem;
    background: var(--bg-input);
    color: var(--text-primary);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

input:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 2px rgba(109, 197, 141, 0.3);
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--brand-primary);
    color: var(--text-inverse);
}

.btn-primary:hover {
    background: var(--brand-primary-hover);
}

.btn-success {
    background: var(--brand-primary);
    color: var(--text-inverse);
}

.btn-success:hover {
    background: var(--brand-primary-hover);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-medium);
}

.btn-outline:hover {
    background: var(--bg-input);
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.btn:disabled {
    background: var(--border-medium);
    cursor: not-allowed;
}

/* ============================================
   UPLOAD STATUS
   ============================================ */
#upload-status {
    margin-top: 0.75rem;
    font-size: 0.9rem;
}

/* ============================================
   INVOICE TABLE
   ============================================ */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th {
    text-align: left;
    padding: 10px 8px;
    border-bottom: 2px solid var(--border-light);
    color: var(--text-secondary);
    font-weight: 600;
    white-space: nowrap;
}

td {
    padding: 8px;
    border-bottom: 1px solid var(--border-light);
}

tr:hover {
    background: var(--bg-hover);
}

td.amount {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.bic-lookup {
    color: var(--warning);
    font-size: 0.75rem;
}

.bic-missing {
    color: var(--error);
    font-size: 0.75rem;
    font-weight: 600;
}

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--brand-primary);
}

/* ============================================
   BOTTOM BAR
   ============================================ */
.bottom-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.bottom-bar .summary {
    flex: 1;
    font-weight: 600;
    color: var(--text-primary);
}

#status {
    margin-top: 8px;
    font-size: 0.9rem;
}

.error {
    color: var(--error);
}

.success {
    color: var(--success);
}

.errors-list {
    margin-top: 10px;
    padding: 10px;
    background: var(--error-bg);
    border: 1px solid var(--error);
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--error-text);
}

/* ============================================
   COOKIE CONSENT BANNER (GDPR)
   ============================================ */
.cookie-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 1.5rem 2rem;
    z-index: 1000;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
    border-top: 2px solid var(--brand-primary);
    transition: var(--theme-transition);
}

.cookie-inner {
    max-width: 800px;
    margin: 0 auto;
}

.cookie-banner h3 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    color: var(--brand-primary);
}

.cookie-banner p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 0.5rem;
}

.cookie-details {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border-radius: 6px;
    border: 1px solid var(--border-light);
}

.cookie-details summary {
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary);
    user-select: none;
}

.cookie-details summary:hover {
    color: var(--brand-primary);
}

.cookie-details[open] summary {
    margin-bottom: 0.5rem;
}

.cookie-details ul {
    margin: 0.5rem 0 0 1.25rem;
    line-height: 1.8;
}

.cookie-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.cookie-actions .btn {
    padding: 0.6rem 1.5rem;
    font-size: 0.9rem;
}

/* ============================================
   FOOTER
   ============================================ */
footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border-light);
    padding: 2rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    transition: var(--theme-transition);
}

.footer-content {
    max-width: 1100px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 2rem;
}

.footer-section h4 {
    color: var(--text-primary);
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--brand-primary);
}

.footer-section p {
    margin: 0 0 0.5rem 0;
    color: var(--text-muted);
    line-height: 1.6;
}

.footer-section p:last-child {
    margin-bottom: 0;
}

.footer-section ul {
    list-style: none;
    padding: 0;
    margin-top: 0.5rem;
}

.footer-section li {
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.footer-section li strong {
    color: var(--brand-primary);
}

footer a {
    color: var(--brand-primary);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

.footer-bottom {
    grid-column: 1 / -1;
    text-align: center;
    padding-top: 1.5rem;
    margin-top: 0.5rem;
    border-top: 1px solid var(--border-light);
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .settings-grid {
        grid-template-columns: 1fr;
    }

    .icon-row {
        flex-direction: column;
        align-items: center;
    }

    .cookie-actions {
        flex-direction: column;
    }

    .cookie-actions .btn {
        width: 100%;
        text-align: center;
    }

    .footer-content {
        grid-template-columns: 1fr;
    }
}
