/* =====================================================
   InvoPDF - Invoice Generator Styles
   ===================================================== */

/* CSS Variables for Theming */
:root {
    /* Light Mode Colors */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --preview-bg: #ffffff;
    --preview-border: #e2e8f0;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
}

[data-theme="dark"] {
    /* Dark Mode Colors */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    --accent-primary: #818cf8;
    --accent-secondary: #a78bfa;
    --accent-gradient: linear-gradient(135deg, #818cf8 0%, #a78bfa 100%);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
    --preview-bg: #1e293b;
    --preview-border: #475569;
}

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Header */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.header-content {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 32px;
    height: 32px;
    color: var(--accent-primary);
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.logo-highlight {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-content {
    display: flex;
    flex-direction: column;
}

.logo-tagline {
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-top: -2px;
}

/* Theme Toggle */
.theme-toggle {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.theme-toggle:hover {
    transform: scale(1.05);
    border-color: var(--accent-primary);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    position: absolute;
    transition: all 0.3s ease;
}

.sun-icon {
    color: #f59e0b;
    opacity: 0;
    transform: rotate(-90deg) scale(0);
}

.moon-icon {
    color: var(--accent-primary);
    opacity: 1;
    transform: rotate(0) scale(1);
}

[data-theme="dark"] .sun-icon {
    opacity: 1;
    transform: rotate(0) scale(1);
}

[data-theme="dark"] .moon-icon {
    opacity: 0;
    transform: rotate(90deg) scale(0);
}

/* Main Container */
.main-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 2rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 1200px) {
    .main-container {
        grid-template-columns: 1fr;
    }
}

/* Form Section */
.form-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-card {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
}

.form-card:hover {
    box-shadow: var(--shadow-lg);
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.title-icon {
    font-size: 1.25rem;
}

/* Form Groups */
.form-group {
    margin-bottom: 1rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-group-row:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    font-family: inherit;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group textarea {
    resize: vertical;
    min-height: 60px;
}

/* Items Container */
.items-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.item-row {
    display: grid;
    grid-template-columns: 2fr 80px 120px 100px 40px;
    gap: 0.75rem;
    align-items: end;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.item-row:hover {
    border-color: var(--accent-primary);
}

@media (max-width: 768px) {
    .item-row {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

.item-field label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.375rem;
}

.item-field input {
    width: 100%;
    padding: 0.625rem 0.75rem;
    font-size: 0.875rem;
    font-family: inherit;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.item-field input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

.item-amount {
    display: block;
    padding: 0.625rem 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--accent-primary);
}

.remove-item-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    align-self: end;
    margin-bottom: 2px;
}

.remove-item-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.remove-item-btn svg {
    width: 18px;
    height: 18px;
}

/* Add Item Button */
.add-item-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.875rem;
    font-size: 0.95rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--accent-primary);
    background: transparent;
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 0.5rem;
}

.add-item-btn:hover {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.05);
}

.add-item-btn svg {
    width: 20px;
    height: 20px;
}

/* Download Button */
.download-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 1.125rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    font-family: inherit;
    color: white;
    background: var(--accent-gradient);
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.5);
}

.download-btn:active {
    transform: translateY(0);
}

.download-btn svg {
    width: 24px;
    height: 24px;
}

/* Preview Section */
.preview-section {
    position: sticky;
    top: 100px;
    height: fit-content;
}

.preview-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.preview-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.preview-badge {
    padding: 0.25rem 0.75rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: white;
    background: var(--success-color);
    border-radius: 20px;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

.preview-container {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

/* Invoice Preview Styles */
.invoice-preview {
    background: white;
    color: #1e293b;
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    min-height: 600px;
}

.invoice-header-preview {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 3px solid #6366f1;
}

.invoice-brand .invoice-title {
    font-size: 2.5rem;
    font-weight: 800;
    color: #6366f1;
    letter-spacing: -0.02em;
    margin-bottom: 0.25rem;
}

.invoice-number-preview {
    font-size: 1rem;
    color: #64748b;
    font-weight: 500;
}

.invoice-dates {
    text-align: right;
}

.invoice-dates p {
    font-size: 0.9rem;
    color: #64748b;
    margin-bottom: 0.375rem;
}

.invoice-dates strong {
    color: #1e293b;
}

.invoice-parties {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.invoice-from h3,
.invoice-to h3 {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #6366f1;
    margin-bottom: 0.75rem;
}

.party-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.375rem;
}

.party-address,
.party-contact {
    font-size: 0.9rem;
    color: #64748b;
    margin-bottom: 0.25rem;
    white-space: pre-line;
}

/* Invoice Table */
.invoice-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
}

.invoice-table th {
    background: #f1f5f9;
    padding: 0.875rem 1rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    text-align: left;
    border-bottom: 2px solid #e2e8f0;
}

.invoice-table th:last-child {
    text-align: right;
}

.invoice-table td {
    padding: 1rem;
    font-size: 0.95rem;
    color: #1e293b;
    border-bottom: 1px solid #e2e8f0;
}

.invoice-table td:last-child {
    text-align: right;
    font-weight: 600;
}

.invoice-table tbody tr:hover {
    background: #f8fafc;
}

/* Invoice Summary */
.invoice-summary {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    margin-bottom: 2rem;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    width: 250px;
    padding: 0.625rem 0;
    font-size: 0.95rem;
    color: #64748b;
}

.summary-row.subtotal {
    border-bottom: 1px solid #e2e8f0;
}

.summary-row.total {
    border-top: 2px solid #1e293b;
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    font-size: 1.2rem;
    font-weight: 700;
    color: #1e293b;
}

.summary-row.total span:last-child {
    color: #6366f1;
}

/* Invoice Notes */
.invoice-notes {
    background: #f8fafc;
    padding: 1rem 1.25rem;
    border-radius: 8px;
    border-left: 3px solid #6366f1;
    margin-bottom: 2rem;
    font-size: 0.9rem;
    color: #64748b;
    white-space: pre-line;
}

.invoice-notes:empty {
    display: none;
}

/* Invoice Footer */
.invoice-footer-preview {
    text-align: center;
    padding-top: 1.5rem;
    border-top: 1px solid #e2e8f0;
    font-size: 0.95rem;
    color: #64748b;
}

/* Responsive */
@media (max-width: 768px) {
    .main-container {
        padding: 1rem;
    }

    .header-content {
        padding: 0.75rem 1rem;
    }

    .logo {
        gap: 0.5rem;
    }

    .logo-icon {
        width: 24px;
        height: 24px;
    }

    .logo-text {
        font-size: 1.2rem;
    }

    .theme-toggle {
        width: 38px;
        height: 38px;
        border-radius: 10px;
    }

    .theme-toggle svg {
        width: 18px;
        height: 18px;
    }

    .form-card {
        padding: 1.25rem;
    }

    .invoice-preview {
        padding: 1.5rem;
    }

    .invoice-header-preview {
        flex-direction: column;
        gap: 1rem;
    }

    .invoice-dates {
        text-align: left;
    }

    .invoice-parties {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .invoice-table th,
    .invoice-table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.85rem;
    }
}

/* Animations */
.form-card,
.preview-container {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.item-row {
    animation: slideIn 0.2s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Print Styles for PDF */
@media print {
    body {
        background: white;
    }

    .header,
    .form-section,
    .preview-header {
        display: none !important;
    }

    .main-container {
        display: block;
        padding: 0;
    }

    .preview-section {
        position: static;
    }

    .preview-container {
        box-shadow: none;
        border: none;
        padding: 0;
    }

    .invoice-preview {
        box-shadow: none;
    }
}