/* ========================================
   WIZE INVOICE - MODERN CREATE INVOICE STYLES
   Split Layout with Live Preview
   ======================================== */

.create-invoice-modern {
    min-height: calc(100vh - 64px);
    background: linear-gradient(135deg, #f5f7fa 0%, #e9ecef 100%);
}

.split-container {
    display: flex;
    height: calc(100vh - 64px); /* ✅ fixed height, no page scroll */
    overflow: hidden;
}

/* LEFT PANEL - Form */
.form-panel {
    flex: 1;
    background: var(--surface);
    overflow-y: auto;
    padding: 16px 20px; /* ✅ reduced padding */
    box-shadow: var(--shadow-lg);
    z-index: 1;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}

.form-header {
    margin-bottom: 12px; /* ✅ reduced */
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary);
}

.form-header h2 {
    font-size: 1.25rem; /* ✅ reduced from 1.75rem */
    margin-bottom: 2px;
    color: var(--text);
}

.form-header p {
    color: var(--text-light);
    font-size: 0.75rem;
}

/* Modern Form */
.modern-form {
    display: flex;
    flex-direction: column;
    gap: 10px; /* ✅ reduced from xl */
}

.form-section {
    background: var(--background);
    border-radius: var(--radius-md); /* ✅ smaller radius */
    padding: 12px 14px; /* ✅ reduced padding */
    border: 1px solid var(--border);
    transition: all 0.3s ease;
}

.form-section:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.section-title {
    font-size: 0.8rem; /* ✅ reduced */
    font-weight: 600;
    margin-bottom: 10px; /* ✅ reduced */
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.section-title::before {
    content: '';
    width: 3px;
    height: 14px;
    background: var(--primary);
    border-radius: 2px;
}

/* Theme Hint */
.theme-hint {
    font-size: 0.65rem;
    color: var(--text-light);
    margin-bottom: 8px;
}

/* Form Row */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px; /* ✅ reduced */
}

/* Form Group spacing */
.form-group {
    margin-bottom: 8px; /* ✅ tighter */
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-label {
    font-size: 0.72rem; /* ✅ smaller label */
    margin-bottom: 3px;
    display: block;
    font-weight: 500;
}

.form-input,
.form-select,
.form-textarea {
    padding: 6px 10px; /* ✅ reduced from default */
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    width: 100%;
    box-sizing: border-box;
}

.form-textarea {
    resize: vertical;
    min-height: 60px; /* ✅ shorter textarea */
}

.form-hint {
    font-size: 0.65rem;
    color: var(--text-light);
    margin-top: 2px;
    display: block;
}

/* Modern Items Container */
.items-container-modern {
    margin-bottom: 8px;
}

.item-row-modern {
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: 8px 10px; /* ✅ reduced */
    margin-bottom: 8px;
    border: 1px solid var(--border);
    transition: all 0.2s ease;
}

.item-row-modern:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px; /* ✅ reduced */
}

.item-title {
    font-weight: 500;
    font-size: 0.7rem;
    color: var(--text-light);
}

.remove-item-btn {
    background: none;
    border: none;
    color: var(--error);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.remove-item-btn:hover {
    background: #fee2e2;
}

.item-fields {
    display: grid;
    grid-template-columns: 3fr 1fr 1fr;
    gap: 8px;
}

.item-fields .form-input {
    width: 100%;
}

.btn-add-item {
    width: 100%;
    background: none;
    border: 2px dashed var(--border);
    padding: 7px; /* ✅ reduced */
    border-radius: var(--radius-sm);
    color: var(--primary);
    font-weight: 500;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-add-item:hover {
    border-color: var(--primary);
    background: rgba(15, 92, 75, 0.05);
}

/* Totals Section */
.totals-modern {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0; /* ✅ tighter */
    font-size: 0.78rem;
}

.total-row.grand {
    font-size: 1rem; /* ✅ reduced */
    font-weight: 700;
    color: var(--primary);
    border-top: 2px solid var(--border);
    margin-top: 4px;
    padding-top: 6px;
}

.tax-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tax-select {
    padding: 3px 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.72rem;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    padding-bottom: 16px;
}

.form-actions .btn {
    flex: 1;
    padding: 9px;
    font-size: 0.8rem;
}

/* RIGHT PANEL - Preview */
.preview-panel {
    flex: 1;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 16px 20px; /* ✅ reduced */
    display: flex;
    flex-direction: column;
    overflow: hidden; /* ✅ no scroll on panel itself */
    position: sticky;
    top: 0;
    height: calc(100vh - 64px);
}

.preview-header {
    text-align: center;
    margin-bottom: 10px; /* ✅ reduced */
    flex-shrink: 0;
}

.preview-header h2 {
    color: white;
    font-size: 1.1rem; /* ✅ reduced */
    margin-bottom: 2px;
}

.preview-header p {
    color: rgba(255,255,255,0.7);
    font-size: 0.75rem;
}

/* Live Preview Area - ✅ fits screen, no scroll */
.live-preview {
    background: white;
    border-radius: var(--radius-lg);
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: var(--shadow-xl);
    flex: 1;
    min-height: 0;
    transition: all 0.3s ease;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}

/* ✅ Scale invoice preview to fit container */
.live-preview > div {
    transform-origin: top left;
    width: 100%;
    height: 100%;
}

.invoice-preview {
    padding: var(--spacing-lg);
}

.preview-loading {
    text-align: center;
    padding: var(--spacing-2xl);
    color: var(--text-light);
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.preview-loading .spinner {
    width: 40px;
    height: 40px;
    margin-bottom: var(--spacing-md);
}

/* Invoice Preview Styles */
.preview-invoice {
    font-family: 'Inter', sans-serif;
}

.preview-header-section {
    text-align: center;
    margin-bottom: var(--spacing-lg);
}

.preview-logo {
    max-height: 60px;
    margin-bottom: var(--spacing-md);
}

.preview-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

.preview-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 2px solid;
}

.preview-client h4,
.preview-details h4 {
    font-size: 0.75rem;
    margin-bottom: var(--spacing-xs);
    opacity: 0.7;
}

.preview-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: var(--spacing-lg);
}

.preview-table th,
.preview-table td {
    padding: var(--spacing-sm);
    text-align: left;
    border-bottom: 1px solid #eee;
    font-size: 0.75rem;
}

.preview-table th {
    font-weight: 600;
}

.preview-totals {
    text-align: right;
    margin-top: var(--spacing-md);
}

.preview-totals p {
    margin: var(--spacing-xs) 0;
    font-size: 0.75rem;
}

.preview-grand {
    font-size: 1rem !important;
    font-weight: 700;
}

.preview-notes {
    margin-top: var(--spacing-lg);
    padding: var(--spacing-md);
    background: #f9f9f9;
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    font-style: italic;
}

/* Branding Row */
.branding-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px; /* ✅ reduced */
}

.branding-item {
    text-align: center;
}

.branding-preview {
    display: flex;
    justify-content: center;
    margin: 8px 0; /* ✅ reduced */
}

.preview-placeholder-small {
    width: 70px; /* ✅ reduced */
    height: 70px;
    background: var(--background);
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
}

.preview-placeholder-small span {
    font-size: 1.4rem; /* ✅ reduced */
    opacity: 0.5;
}

.preview-placeholder-small p {
    font-size: 0.6rem;
    color: var(--text-light);
    margin: 0;
}

.branding-preview img {
    max-width: 70px; /* ✅ reduced */
    max-height: 70px;
    border-radius: var(--radius-md);
    object-fit: contain;
}

.branding-upload {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 4px;
}

.btn-danger {
    background-color: var(--error);
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-sm {
    padding: 4px 10px; /* ✅ reduced */
    font-size: 0.7rem;
}

/* ========================================
   THEME COLOR PICKER
   ======================================== */

.theme-color-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px; /* ✅ reduced */
    margin-top: 4px;
}

.theme-color-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 6px 4px;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    background: var(--surface);
    border: 1px solid var(--border);
}

.theme-color-option:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.theme-color-option.selected {
    border: 2px solid var(--primary);
    background: rgba(15, 92, 75, 0.05);
}

.theme-color-preview {
    width: 32px; /* ✅ reduced from 48px */
    height: 32px;
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease;
}

.theme-color-option:hover .theme-color-preview {
    transform: scale(1.05);
}

.theme-color-name {
    font-size: 0.6rem;
    font-weight: 500;
    color: var(--text);
}

/* 8 Color Theme Preview Circles */
.theme-emerald  { background: linear-gradient(135deg, #0F5C4B, #FFB74D); }
.theme-ocean    { background: linear-gradient(135deg, #1E3A5F, #67E8F9); }
.theme-coral    { background: linear-gradient(135deg, #E76F51, #F4A261); }
.theme-midnight { background: linear-gradient(135deg, #2D1B4E, #F9A826); }
.theme-minimal  { background: linear-gradient(135deg, #2C3E50, #95A5A6); }
.theme-royal    { background: linear-gradient(135deg, #5B2C6F, #F1C40F); }
.theme-forest   { background: linear-gradient(135deg, #1B4F3B, #A3E4D7); }
.theme-sunset   { background: linear-gradient(135deg, #D35400, #F39C12); }

/* ========================================
   TRIAL COUNTDOWN BANNER
   ======================================== */

.trial-countdown-banner {
    background: linear-gradient(135deg, #ff6b35, #f7c59f);
    color: white;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.3);
    flex-shrink: 0;
}

.trial-countdown-banner.urgent {
    background: linear-gradient(135deg, #dc2626, #ef4444);
    animation: pulse-banner 1.5s infinite;
}

.trial-countdown-banner.expired {
    background: linear-gradient(135deg, #1a1a1a, #374151);
}

@keyframes pulse-banner {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}

.trial-banner-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.trial-banner-icon {
    font-size: 1.2rem;
}

.trial-banner-text strong {
    font-weight: 700;
}

.trial-timer {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-top: 2px;
}

.timer-block {
    background: rgba(255,255,255,0.25);
    border-radius: 5px;
    padding: 2px 7px;
    text-align: center;
    min-width: 36px;
}

.timer-block .timer-value {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
    display: block;
}

.timer-block .timer-label {
    font-size: 0.55rem;
    opacity: 0.85;
    text-transform: uppercase;
    display: block;
}

.timer-separator {
    font-size: 1rem;
    font-weight: 700;
    opacity: 0.7;
    margin-bottom: 10px;
}

.trial-banner-right {
    flex-shrink: 0;
}

.trial-upgrade-btn {
    background: white;
    color: #ff6b35;
    border: none;
    padding: 6px 16px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.78rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    display: inline-block;
}

.trial-upgrade-btn:hover {
    background: #fff3ee;
    transform: scale(1.03);
}

.trial-upgrade-btn.expired {
    background: #ef4444;
    color: white;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    max-width: 400px;
    width: 90%;
    padding: var(--spacing-xl);
    text-align: center;
    animation: fadeInUp 0.3s ease;
}

.modal-icon {
    font-size: 3rem;
    margin-bottom: var(--spacing-md);
}

.modal-buttons {
    display: flex;
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

/* Upgrade Modal */
.upgrade-modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    max-width: 420px;
    width: 90%;
    padding: var(--spacing-xl);
    text-align: center;
    animation: fadeInUp 0.3s ease;
    border-top: 4px solid #ff6b35;
}

.upgrade-modal-content h2 {
    font-size: 1.4rem;
    margin-bottom: 8px;
    color: var(--text);
}

.upgrade-modal-content p {
    color: var(--text-light);
    font-size: 0.875rem;
    margin-bottom: 20px;
}

.upgrade-features {
    text-align: left;
    margin-bottom: 20px;
    background: var(--background);
    border-radius: var(--radius-md);
    padding: 14px;
}

.upgrade-features li {
    font-size: 0.82rem;
    padding: 4px 0;
    color: var(--text);
    list-style: none;
}

.upgrade-features li::before {
    content: '✅ ';
}

/* Responsive */
@media (max-width: 1024px) {
    .split-container {
        flex-direction: column;
        height: auto;
        overflow: visible;
    }

    .preview-panel {
        position: relative;
        height: 600px;
        overflow: hidden;
        top: 0;
    }

    .form-panel {
        padding: 14px 16px;
        overflow-y: visible;
    }

    .branding-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}

@media (max-width: 768px) {
    .item-fields {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .theme-color-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
    }

    .theme-color-preview {
        width: 28px;
        height: 28px;
    }

    .trial-countdown-banner {
        flex-direction: column;
        gap: 8px;
        text-align: center;
        padding: 10px;
    }

    .trial-timer {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .theme-color-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

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