/* Facture Generator Custom Styles */

:root {
    --accent-color: #4f46e5;
    --accent-light: #e0e7ff;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.dark ::-webkit-scrollbar-track {
    background: #1e293b;
}
.dark ::-webkit-scrollbar-thumb {
    background: #475569;
}

/* Live Preview Animation */
.preview-updated {
    animation: preview-flash 0.3s ease-out;
}
@keyframes preview-flash {
    0%   { opacity: 0.6; }
    100% { opacity: 1; }
}

/* Invoice Preview Card */
.invoice-preview {
    background: #ffffff;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    font-size: 13px;
    color: #1f2937;
    line-height: 1.5;
}

.invoice-preview .accent-bg {
    background-color: var(--accent-color);
}

.invoice-preview .accent-text {
    color: var(--accent-color);
}

.invoice-preview .accent-border {
    border-color: var(--accent-color);
}

.invoice-preview table thead {
    background-color: var(--accent-color);
    color: #ffffff;
}

.invoice-preview .invoice-title {
    color: var(--accent-color);
}

/* Template Tabs */
.template-tab {
    cursor: pointer;
    transition: all 0.2s ease;
}
.template-tab.active {
    border-bottom: 2px solid var(--accent-color);
    color: var(--accent-color);
    font-weight: 600;
}

/* Form Cards */
.form-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid #e5e7eb;
}
.dark .form-card {
    background: #1e293b;
    border-color: #334155;
}

/* Line Items Table */
.line-items-table input {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 4px 8px;
    width: 100%;
    transition: border-color 0.15s;
}
.line-items-table input:focus {
    outline: none;
    border-color: var(--accent-color);
    background: #f8fafc;
}
.dark .line-items-table input:focus {
    background: #1e293b;
}

/* Color Picker */
.color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    border: 2px solid transparent;
}
.color-swatch:hover {
    transform: scale(1.15);
}
.color-swatch.selected {
    border-color: #1f2937;
    box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px var(--accent-color);
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9999;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
}
.toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}
.modal-overlay.show {
    opacity: 1;
    pointer-events: all;
}
.modal-box {
    background: #fff;
    border-radius: 16px;
    padding: 2rem;
    width: 100%;
    max-width: 480px;
    transform: scale(0.95);
    transition: transform 0.2s;
}
.dark .modal-box {
    background: #1e293b;
}
.modal-overlay.show .modal-box {
    transform: scale(1);
}

/* Logo upload area */
.logo-upload-area {
    border: 2px dashed #d1d5db;
    border-radius: 10px;
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.logo-upload-area:hover,
.logo-upload-area.drag-over {
    border-color: var(--accent-color);
    background: var(--accent-light);
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Sticky preview panel */
.preview-sticky {
    position: sticky;
    top: 5rem;
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
}

/* Print Styles */
@media print {
    * {
        overflow: visible !important;
        max-height: none !important;
    }
    body * {
        visibility: hidden !important;
    }
    .invoice-preview,
    .invoice-preview * {
        visibility: visible !important;
        overflow: visible !important;
    }
    .invoice-preview {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        z-index: 9999 !important;
        background: white !important;
        overflow: visible !important;
    }
    /* Hide everything except preview */
    header, nav, footer,
    .no-print, .form-panel, .template-tabs,
    .preview-sticky, .preview-header {
        display: none !important;
    }
    /* Unwrap the sticky container so preview renders at page top */
    .preview-sticky {
        position: static !important;
        overflow: visible !important;
        max-height: none !important;
    }
    @page {
        margin: 1cm;
        size: A4 portrait;
    }
    html, body {
        background: white !important;
        height: auto !important;
    }
}

/* Sidebar active state */
.sidebar-link.active {
    background-color: var(--accent-color);
    color: white;
}
.sidebar-link:not(.active):hover {
    background-color: #f1f5f9;
}
.dark .sidebar-link:not(.active):hover {
    background-color: #334155;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .preview-sticky {
        position: static;
        max-height: none;
    }
}

/* Input focus ring */
.input-field {
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    width: 100%;
    background: #fff;
    color: #111827;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}
.input-field:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}
.dark .input-field {
    background: #334155;
    border-color: #475569;
    color: #f1f5f9;
}
.dark .input-field:focus {
    border-color: #818cf8;
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.2);
}

/* Note character counter */
.char-counter {
    font-size: 0.75rem;
    color: #9ca3af;
    text-align: right;
    margin-top: 2px;
}
.char-counter.near-limit {
    color: #f59e0b;
}
.char-counter.at-limit {
    color: #ef4444;
}
