/* ===============================================
   PROFESSIONAL INVOICE GENERATOR STYLES
   A comprehensive invoice generator with premium features
   =============================================== */

/* --- Tool-Specific Variables --- */
:root {
    --invoice-accent: #3B82F6;
    --invoice-bg: #FFFFFF;
    --invoice-border: #E5E7EB;
    --invoice-text: #111827;
    --invoice-text-secondary: #6B7280;
    --invoice-success: #10B981;
    --invoice-warning: #F59E0B;
    --invoice-error: #EF4444;
}

[data-theme="dark"] {
    --invoice-bg: #1F2937;
    --invoice-border: #374151;
    --invoice-text: #F9FAFB;
    --invoice-text-secondary: #D1D5DB;
}

/* --- Main Layout --- */
.invoice-generator-main {
    padding: var(--space-8) 0;
    min-height: 100vh;
    background: var(--bg-secondary);
}

/* --- Mobile Tab Navigation --- */
.mobile-tabs {
    display: none;
    margin-bottom: var(--space-6);
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: var(--space-2);
    box-shadow: var(--shadow-sm);
}

@media (max-width: 640px) {
    .mobile-tabs {
        display: flex;
        gap: var(--space-2);
    }
}

.tab-button {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-base);
    font-weight: var(--font-weight-medium);
    transition: all var(--transition-base);
    cursor: pointer;
}

.tab-button.active {
    background: var(--brand-primary);
    color: var(--text-inverse);
    box-shadow: var(--shadow-sm);
}

.tab-button:hover:not(.active) {
    background: var(--gray-100);
    color: var(--text-primary);
}

[data-theme="dark"] .tab-button:hover:not(.active) {
    background: var(--gray-800);
}

/* --- Two-Column Layout --- */
.invoice-generator-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-8);
    align-items: start;
}

@media (max-width: 1024px) {
    .invoice-generator-layout {
        gap: var(--space-6);
    }
}

@media (max-width: 640px) {
    .invoice-generator-layout {
        grid-template-columns: 1fr;
        gap: 0;
    }
    
    .form-column,
    .preview-column {
        display: none;
    }
    
    .form-column.active,
    .preview-column.active {
        display: block;
    }
}

/* --- Form Column Styles --- */
.form-column {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    box-shadow: var(--shadow-lg);
    height: fit-content;
    max-height: 90vh;
    overflow-y: auto;
}

.form-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-8);
    padding-bottom: var(--space-4);
    border-bottom: 2px solid var(--gray-200);
}

[data-theme="dark"] .form-header {
    border-bottom-color: var(--gray-700);
}

.form-header h2 {
    font-size: 1.75rem;
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
}

.form-controls {
    display: flex;
    gap: var(--space-4);
    align-items: center;
}

@media (max-width: 768px) {
    .form-controls {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-3);
    }
}

.template-selector,
.color-picker {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.template-selector label,
.color-picker label {
    font-weight: var(--font-weight-medium);
    color: var(--text-secondary);
    white-space: nowrap;
}

.template-selector select {
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--invoice-border);
    border-radius: var(--radius-base);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.color-picker input[type="color"] {
    width: 40px;
    height: 32px;
    border: 1px solid var(--invoice-border);
    border-radius: var(--radius-base);
    cursor: pointer;
    background: none;
}

/* --- Form Sections --- */
.form-section {
    margin-bottom: var(--space-8);
}

.form-section:last-child {
    margin-bottom: 0;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-6);
}

.section-header h3 {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: 1.25rem;
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
}

.section-header h3 i {
    color: var(--brand-primary);
}

.save-info-toggle,
.client-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

@media (max-width: 768px) {
    .section-header {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-3);
    }
    
    .client-actions {
        flex-direction: column;
        gap: var(--space-2);
    }
}

/* --- Form Grid --- */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
}

@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
        gap: var(--space-3);
    }
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.form-group.logo-upload {
    grid-column: 1 / -1;
}

.form-group label {
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    padding: var(--space-3);
    border: 1px solid var(--invoice-border);
    border-radius: var(--radius-base);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: border-color var(--transition-base);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* --- Logo Upload --- */
.logo-upload-area {
    border: 2px dashed var(--invoice-border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-base);
}

.logo-upload-area:hover {
    border-color: var(--brand-primary);
    background: rgba(59, 130, 246, 0.05);
}

.logo-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    color: var(--text-secondary);
}

.logo-preview i {
    font-size: 2rem;
    color: var(--brand-primary);
}

.logo-preview img {
    max-width: 200px;
    max-height: 100px;
    object-fit: contain;
    border-radius: var(--radius-base);
}

/* --- Items Table --- */
.items-table {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--invoice-border);
}

.table-header {
    display: grid;
    grid-template-columns: 2fr 80px 120px 120px 60px;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--gray-100);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    font-size: 0.875rem;
}

[data-theme="dark"] .table-header {
    background: var(--gray-800);
}

@media (max-width: 768px) {
    .table-header {
        grid-template-columns: 1fr 60px 80px 80px 40px;
        gap: var(--space-2);
        padding: var(--space-3);
        font-size: 0.75rem;
    }
}

.table-body {
    max-height: 300px;
    overflow-y: auto;
}

.item-row {
    display: grid;
    grid-template-columns: 2fr 80px 120px 120px 60px;
    gap: var(--space-3);
    padding: var(--space-4);
    border-top: 1px solid var(--invoice-border);
    align-items: center;
}

@media (max-width: 768px) {
    .item-row {
        grid-template-columns: 1fr 60px 80px 80px 40px;
        gap: var(--space-2);
        padding: var(--space-3);
    }
}

.item-row input {
    padding: var(--space-2);
    border: 1px solid var(--invoice-border);
    border-radius: var(--radius-base);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.875rem;
    width: 100%;
}

@media (max-width: 768px) {
    .item-row input {
        font-size: 0.75rem;
        padding: 6px;
    }
}

.remove-item {
    background: var(--error);
    color: white;
    border: none;
    border-radius: var(--radius-base);
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
}

.remove-item:hover {
    background: #DC2626;
    transform: scale(1.05);
}

/* --- Totals Section --- */
.totals-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

@media (max-width: 768px) {
    .totals-grid {
        grid-template-columns: 1fr;
        gap: var(--space-3);
    }
}

.totals-summary {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    border: 1px solid var(--invoice-border);
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-2) 0;
    font-size: 0.875rem;
}

.total-row:not(:last-child) {
    border-bottom: 1px solid var(--invoice-border);
}

.total-final {
    font-size: 1.125rem;
    font-weight: var(--font-weight-bold);
    padding-top: var(--space-4);
    color: var(--brand-primary);
}

/* --- Buttons --- */
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--invoice-border);
    border-radius: var(--radius-base);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-weight: var(--font-weight-medium);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition-base);
}

.btn-secondary:hover {
    background: var(--gray-100);
    transform: translateY(-1px);
}

[data-theme="dark"] .btn-secondary:hover {
    background: var(--gray-800);
}

.form-actions {
    display: flex;
    gap: var(--space-4);
    justify-content: center;
    margin-top: var(--space-8);
    padding-top: var(--space-6);
    border-top: 2px solid var(--gray-200);
}

[data-theme="dark"] .form-actions {
    border-top-color: var(--gray-700);
}

@media (max-width: 768px) {
    .form-actions {
        flex-direction: column;
        gap: var(--space-3);
    }
}

/* --- Preview Column --- */
.preview-column {
    position: sticky;
    top: var(--space-4);
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
    overflow-y: auto;
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-4);
    border-bottom: 2px solid var(--gray-200);
}

[data-theme="dark"] .preview-header {
    border-bottom-color: var(--gray-700);
}

.preview-header h2 {
    font-size: 1.5rem;
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
}

.preview-badges {
    display: flex;
    gap: var(--space-2);
}

.no-watermark-badge {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--success);
    color: white;
    border-radius: var(--radius-base);
    font-size: 0.75rem;
    font-weight: var(--font-weight-medium);
}

/* --- Invoice Preview --- */
.invoice-preview {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    min-height: 600px;
}

/* --- Invoice Templates --- */
.invoice-template {
    padding: var(--space-8);
    color: #000;
    line-height: 1.6;
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: var(--space-8);
    padding-bottom: var(--space-6);
    border-bottom: 2px solid var(--invoice-accent);
}

.company-info {
    flex: 1;
}

.company-logo {
    max-width: 200px;
    max-height: 80px;
    object-fit: contain;
    margin-bottom: var(--space-4);
}

.company-details h2 {
    font-size: 1.5rem;
    font-weight: var(--font-weight-bold);
    color: var(--invoice-accent);
    margin-bottom: var(--space-2);
}

.company-details p {
    margin: 2px 0;
    font-size: 0.875rem;
    color: #666;
}

.invoice-title {
    text-align: right;
}

.invoice-title h1 {
    font-size: 2.5rem;
    font-weight: var(--font-weight-bold);
    color: var(--invoice-accent);
    margin-bottom: var(--space-2);
}

.invoice-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-8);
    margin-bottom: var(--space-8);
}

.bill-to,
.invoice-details {
    background: #f8f9fa;
    padding: var(--space-6);
    border-radius: var(--radius-lg);
}

.bill-to h3,
.invoice-details h3 {
    font-size: 1.125rem;
    font-weight: var(--font-weight-semibold);
    color: var(--invoice-accent);
    margin-bottom: var(--space-3);
}

.bill-to p,
.invoice-details p {
    margin: 2px 0;
    font-size: 0.875rem;
}

.invoice-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: var(--space-8);
}

.invoice-table th {
    background: var(--invoice-accent);
    color: white;
    padding: var(--space-4);
    text-align: left;
    font-weight: var(--font-weight-semibold);
}

.invoice-table td {
    padding: var(--space-4);
    border-bottom: 1px solid #e5e7eb;
}

.invoice-table tbody tr:nth-child(even) {
    background: #f8f9fa;
}

.text-right {
    text-align: right;
}

.invoice-totals {
    margin-left: auto;
    width: 300px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    padding: var(--space-2) 0;
}

.total-row:not(:last-child) {
    border-bottom: 1px solid #e5e7eb;
}

.final-total {
    font-size: 1.25rem;
    font-weight: var(--font-weight-bold);
    background: var(--invoice-accent);
    color: white;
    padding: var(--space-4);
    border-radius: var(--radius-base);
    margin-top: var(--space-4);
}

/* --- Template Variations --- */
.template-classic .invoice-header {
    border-bottom: 3px double var(--invoice-accent);
}

.template-classic .invoice-title h1 {
    font-family: serif;
}

.template-minimalist .invoice-template {
    padding: var(--space-6);
}

.template-minimalist .invoice-header {
    border-bottom: 1px solid var(--invoice-accent);
}

.template-minimalist .bill-to,
.template-minimalist .invoice-details {
    background: transparent;
    border: 1px solid #e5e7eb;
}

.template-professional .company-info {
    background: linear-gradient(135deg, var(--invoice-accent), rgba(59, 130, 246, 0.8));
    color: white;
    padding: var(--space-6);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-6);
}

.template-professional .company-details h2,
.template-professional .company-details p {
    color: white;
}

.template-creative .invoice-header {
    background: linear-gradient(135deg, var(--invoice-accent), #8B5CF6);
    color: white;
    padding: var(--space-6);
    border-radius: var(--radius-lg);
    margin: calc(var(--space-8) * -1) calc(var(--space-8) * -1) var(--space-8);
}

.template-creative .company-details h2,
.template-creative .company-details p,
.template-creative .invoice-title h1 {
    color: white;
}

/* --- Responsive Invoice --- */
@media (max-width: 768px) {
    .invoice-template {
        padding: var(--space-4);
        font-size: 0.875rem;
    }
    
    .invoice-header {
        flex-direction: column;
        gap: var(--space-4);
        text-align: center;
    }
    
    .invoice-title {
        text-align: center;
    }
    
    .invoice-title h1 {
        font-size: 2rem;
    }
    
    .invoice-meta {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }
    
    .invoice-table {
        font-size: 0.75rem;
    }
    
    .invoice-table th,
    .invoice-table td {
        padding: var(--space-2);
    }
    
    .invoice-totals {
        width: 100%;
    }
}

/* --- Print Styles --- */
@media print {
    body * {
        visibility: hidden;
    }
    
    .invoice-preview,
    .invoice-preview * {
        visibility: visible;
    }
    
    .invoice-preview {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        background: white !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .invoice-template {
        padding: 20px !important;
        margin: 0 !important;
    }
    
    .navbar,
    .tool-hero,
    .footer,
    .form-column,
    .preview-header,
    .mobile-tabs {
        display: none !important;
    }
    
    .preview-column {
        position: static !important;
        max-height: none !important;
        overflow: visible !important;
        box-shadow: none !important;
        background: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }
}

/* --- Checkbox Styling --- */
input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--brand-primary);
}

/* --- Save Info Toggle --- */
.save-info-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.save-info-toggle label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
}

/* --- Loading States --- */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--brand-primary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* --- Custom Scrollbar --- */
.form-column::-webkit-scrollbar,
.preview-column::-webkit-scrollbar,
.table-body::-webkit-scrollbar {
    width: 6px;
}

.form-column::-webkit-scrollbar-track,
.preview-column::-webkit-scrollbar-track,
.table-body::-webkit-scrollbar-track {
    background: var(--gray-100);
    border-radius: 3px;
}

.form-column::-webkit-scrollbar-thumb,
.preview-column::-webkit-scrollbar-thumb,
.table-body::-webkit-scrollbar-thumb {
    background: var(--gray-400);
    border-radius: 3px;
}

.form-column::-webkit-scrollbar-thumb:hover,
.preview-column::-webkit-scrollbar-thumb:hover,
.table-body::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
}

/* HERO SECTION - Unified with other tools */
.tool-hero {
    margin-top: 0;
    padding: 120px 0 80px;
    position: relative;
    z-index: 2;
    background: linear-gradient(135deg, var(--bg-primary) 0%, rgba(59, 130, 246, 0.1) 30%, rgba(16, 185, 129, 0.1) 70%, var(--bg-primary) 100%);
    overflow: hidden;
}

.tool-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 80%, rgba(59, 130, 246, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(16, 185, 129, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(139, 92, 246, 0.05) 0%, transparent 50%);
    pointer-events: none;
}

/* FOOTER - Unified with other tools */
.footer {
    background: var(--bg-primary);
}
