/* ========================================
   Dubani Creatives — Invoice Generator
   Styles
======================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
    --bg-primary: #0d0d0d;
    --bg-secondary: #141414;
    --bg-card: #1a1a1a;
    --bg-input: #222222;
    --accent: #ff5e00;
    --accent-hover: #ff7a2e;
    --text-primary: #ffffff;
    --text-secondary: #a09a9a;
    --text-muted: #666;
    --border: rgba(255,255,255,0.08);
    --border-hover: rgba(255,255,255,0.18);
    --success: #25D366;
    --danger: #ff4444;
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    line-height: 1.6;
    min-height: 100vh;
}

/* ---- Top Bar ---- */
.app-topbar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-left img {
    height: 30px;
    width: auto;
}

.topbar-title {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.topbar-title span { color: var(--accent); }

.topbar-actions {
    display: flex;
    gap: 10px;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--border-hover); background: #2a2a2a; }

.btn-success {
    background: var(--success);
    color: #fff;
}
.btn-success:hover { background: #1ebe57; }

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-sm { padding: 6px 14px; font-size: 12px; }

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 16px;
}
.btn-icon:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Main Layout ---- */
.app-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    min-height: calc(100vh - 65px);
}

.form-panel {
    padding: 32px;
    overflow-y: auto;
    max-height: calc(100vh - 65px);
    border-right: 1px solid var(--border);
}

.preview-panel {
    padding: 32px;
    overflow-y: auto;
    max-height: calc(100vh - 65px);
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ---- Form Styles ---- */
.form-section {
    margin-bottom: 28px;
}

.form-section-title {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--accent);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 14px;
}

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 14px;
    margin-bottom: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group.full { grid-column: 1 / -1; }

.form-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.form-input, .form-select, .form-textarea {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    transition: border-color 0.2s;
    width: 100%;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a09a9a' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.form-textarea {
    min-height: 80px;
    resize: vertical;
}

/* ---- Line Items Table ---- */
.items-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}

.items-table thead th {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.items-table thead th:last-child { text-align: center; }

.items-table tbody td {
    padding: 8px 6px;
    vertical-align: top;
}

.items-table .item-input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 13px;
    width: 100%;
    transition: border-color 0.2s;
}

.items-table .item-input:focus {
    outline: none;
    border-color: var(--accent);
}

.items-table .col-service { width: 35%; }
.items-table .col-desc { width: 25%; }
.items-table .col-qty { width: 10%; }
.items-table .col-rate { width: 15%; }
.items-table .col-total { width: 12%; text-align: right; }
.items-table .col-action { width: 3%; }

.line-total {
    font-weight: 600;
    color: var(--accent);
    padding-top: 10px;
    display: inline-block;
    text-align: right;
    width: 100%;
}

.remove-item-btn {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 18px;
    padding: 8px;
    opacity: 0.5;
    transition: opacity 0.2s;
}
.remove-item-btn:hover { opacity: 1; }

/* ---- Totals Summary ---- */
.totals-summary {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.total-row {
    display: flex;
    justify-content: space-between;
    width: 280px;
    font-size: 14px;
}

.total-row .total-label { color: var(--text-secondary); }
.total-row .total-value { font-weight: 600; }

.total-row.grand {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    padding-top: 10px;
    border-top: 2px solid var(--accent);
    margin-top: 4px;
}

/* ---- Export Actions ---- */
.export-actions {
    display: flex;
    gap: 12px;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

/* ---- Invoice Preview ---- */
.invoice-preview {
    background: #ffffff;
    color: #1a1a1a;
    width: 100%;
    max-width: 680px;
    padding: 48px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    font-size: 13px;
    line-height: 1.5;
}

.inv-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 3px solid #1a1a1a;
}

.inv-logo img { height: 50px; }

.inv-title-block { text-align: right; }

.inv-title {
    font-family: var(--font-heading);
    font-size: 36px;
    font-weight: 800;
    letter-spacing: 2px;
    color: #1a1a1a;
}

.inv-number {
    font-size: 16px;
    color: #666;
    font-weight: 600;
}

.inv-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 28px;
}

.inv-from h4, .inv-to h4 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #999;
    margin-bottom: 6px;
}

.inv-from p, .inv-to p {
    font-size: 13px;
    color: #333;
    line-height: 1.6;
}

.inv-from strong, .inv-to strong {
    font-size: 14px;
    color: #1a1a1a;
}

.inv-dates {
    text-align: right;
}

.inv-dates-table {
    width: 100%;
    border-collapse: collapse;
}

.inv-dates-table td {
    padding: 4px 0;
    font-size: 13px;
}

.inv-dates-table td:first-child {
    color: #999;
    text-align: right;
    padding-right: 16px;
}

.inv-dates-table td:last-child {
    text-align: right;
    font-weight: 500;
}

.inv-balance-due {
    background: #1a1a1a;
    color: #fff;
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    font-weight: 700;
    font-size: 14px;
    margin-top: 8px;
}

/* ---- Invoice Items Table ---- */
.inv-items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 24px;
}

.inv-items-table thead th {
    background: var(--accent);
    color: #fff;
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: left;
}

.inv-items-table thead th:nth-child(2) { text-align: center; }
.inv-items-table thead th:nth-child(3),
.inv-items-table thead th:nth-child(4) { text-align: right; }

.inv-items-table tbody td {
    padding: 12px;
    border-bottom: 1px solid #eee;
    font-size: 13px;
}

.inv-items-table tbody td:nth-child(2) { text-align: center; }
.inv-items-table tbody td:nth-child(3),
.inv-items-table tbody td:nth-child(4) { text-align: right; }

.inv-item-name { font-weight: 600; color: #1a1a1a; }
.inv-item-desc { font-size: 12px; color: #888; margin-top: 2px; }

/* ---- Invoice Totals ---- */
.inv-totals {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 32px;
}

.inv-totals-table {
    width: 260px;
    border-collapse: collapse;
}

.inv-totals-table td {
    padding: 6px 0;
    font-size: 13px;
}

.inv-totals-table td:first-child {
    text-align: right;
    padding-right: 20px;
    color: #888;
}

.inv-totals-table td:last-child {
    text-align: right;
    font-weight: 600;
}

.inv-totals-table .inv-grand-total td {
    padding-top: 12px;
    border-top: 2px solid #1a1a1a;
    font-size: 16px;
    font-weight: 700;
    color: #1a1a1a;
}

/* ---- Invoice Notes & Terms ---- */
.inv-notes, .inv-terms {
    margin-top: 24px;
}

.inv-notes h4, .inv-terms h4 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent);
    margin-bottom: 6px;
}

.inv-notes p, .inv-terms p {
    font-size: 12px;
    color: #666;
    line-height: 1.7;
}

/* ---- Modals ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    width: 90%;
    max-width: 560px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-title {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    transition: color 0.2s;
}
.modal-close:hover { color: var(--text-primary); }

.saved-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.saved-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.saved-item:hover {
    border-color: var(--accent);
    background: #252525;
}

.saved-item-info h4 {
    font-size: 14px;
    font-weight: 600;
}

.saved-item-info p {
    font-size: 12px;
    color: var(--text-secondary);
}

.saved-item-actions {
    display: flex;
    gap: 6px;
}

/* ---- Responsive ---- */
@media (max-width: 1100px) {
    .app-layout {
        grid-template-columns: 1fr;
    }
    .form-panel, .preview-panel {
        max-height: none;
        border-right: none;
    }
    .preview-panel {
        border-top: 1px solid var(--border);
    }
}

@media (max-width: 600px) {
    .app-topbar { padding: 12px 16px; }
    .form-panel, .preview-panel { padding: 20px; }
    .form-row { grid-template-columns: 1fr; }
    .form-row-3 { grid-template-columns: 1fr; }
    .invoice-preview { padding: 24px; }
    .inv-header { flex-direction: column; gap: 16px; }
    .inv-title-block { text-align: left; }
    .inv-details-grid { grid-template-columns: 1fr; }
    .export-actions { flex-direction: column; }
    .export-actions .btn { width: 100%; justify-content: center; }
}
