/* Modern Minimalist Linear / Stripe Inspired Studio CSS */
:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --dark: #0f172a;
    --surface: #ffffff;
    --surface-subtle: #f8fafc;
    --border: #e2e8f0;
    --border-focus: #6366f1;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --success: #10b981;
    --success-light: #ecfdf5;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --accent-theme: #4f46e5;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: #0b0f19;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

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

/* App Header / Topbar */
.app-header {
    height: 60px;
    background: #111827;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    z-index: 50;
    flex-shrink: 0;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-badge {
    background: linear-gradient(135deg, #4f46e5, #06b6d4);
    color: white;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.brand-title {
    font-size: 1rem;
    font-weight: 700;
    color: #f8fafc;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.brand-title span {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 7px;
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    border-radius: 999px;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

/* Main Layout */
.app-main {
    display: flex;
    flex: 1;
    overflow: hidden;
    height: calc(100vh - 60px);
}

/* Sidebar Editor */
.editor-sidebar {
    width: 460px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 30;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.05);
}

/* Sidebar Nav Tabs */
.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: var(--surface-subtle);
    padding: 0.4rem 0.5rem 0;
    gap: 0.25rem;
    overflow-x: auto;
}

.tab-btn {
    flex: 1;
    padding: 0.65rem 0.5rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 6px 6px 0 0;
    white-space: nowrap;
}

.tab-btn svg {
    width: 17px;
    height: 17px;
    stroke-width: 2;
    transition: transform 0.2s;
}

.tab-btn:hover {
    color: var(--primary);
    background: rgba(255, 255, 255, 0.6);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 -2px 6px rgba(0,0,0,0.02);
}

.tab-btn.active svg {
    transform: translateY(-1px);
}

/* Tab Content Areas */
.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    background: var(--surface);
}

.tab-pane {
    display: none;
    animation: fadeIn 0.2s ease;
}

.tab-pane.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Form Styles */
.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.form-card-title {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.form-group {
    margin-bottom: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.5rem;
}

label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

label .hint {
    font-weight: 400;
    font-size: 0.7rem;
    color: var(--text-muted);
}

input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.84rem;
    color: var(--text-primary);
    background: #ffffff;
    transition: all 0.15s ease;
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

textarea {
    resize: vertical;
    min-height: 65px;
    line-height: 1.45;
}

/* Palet & Preset Colors */
.color-presets {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.4rem;
}

.color-dot {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 0 0 1px var(--border);
    transition: transform 0.15s, box-shadow 0.15s;
}

.color-dot:hover {
    transform: scale(1.15);
}

.color-dot.active {
    box-shadow: 0 0 0 2px var(--primary);
    transform: scale(1.1);
}

/* Template Switcher Cards */
.template-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
}

.template-card {
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 0.75rem;
    cursor: pointer;
    text-align: center;
    background: var(--surface-subtle);
    transition: all 0.2s ease;
}

.template-card:hover {
    border-color: #cbd5e1;
    background: white;
}

.template-card.active {
    border-color: var(--primary);
    background: var(--primary-light);
}

.template-card .tpl-name {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}

.template-card .tpl-desc {
    font-size: 0.68rem;
    color: var(--text-muted);
}

/* Item Builder Modern Card */
.item-card {
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.75rem;
    margin-bottom: 0.6rem;
    position: relative;
    transition: all 0.2s ease;
}

.item-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 2px 6px rgba(0,0,0,0.03);
}

.item-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.item-index-badge {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
}

.btn-icon-danger {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 3px;
    border-radius: 4px;
    display: flex;
    align-items: center;
}

.btn-icon-danger:hover {
    color: var(--danger);
    background: var(--danger-light);
}

/* Canvas Workspace & Controls */
.workspace-wrapper {
    flex: 1;
    background: #1e293b;
    position: relative;
    overflow: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2.5rem 1.5rem;
}

.canvas-toolbar {
    position: sticky;
    top: 1rem;
    z-index: 40;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    padding: 0.35rem 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    margin-bottom: 2rem;
}

.canvas-tool-btn {
    background: transparent;
    border: none;
    color: #cbd5e1;
    padding: 0.35rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    transition: all 0.15s;
}

.canvas-tool-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.canvas-divider {
    width: 1px;
    height: 16px;
    background: rgba(255, 255, 255, 0.15);
}

/* Paper Container */
.paper-viewport {
    transform-origin: top center;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    margin-bottom: 4rem;
}

/* A4 Sheet Format */
.paper {
    width: 210mm;
    min-height: 297mm;
    background: #ffffff;
    padding: 22mm 22mm;
    position: relative;
    color: #1e293b;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* ===================================================
   MODERN MINIMALIST STRIPE / LINEAR INVOICE TEMPLATE
   =================================================== */

.invoice-modern {
    font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
    color: #1e293b;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Header */
.inv-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
}

.inv-brand-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-width: 50%;
}

.inv-logo-img {
    max-height: 54px;
    max-width: 180px;
    object-fit: contain;
    margin-bottom: 0.3rem;
}

.inv-store-name {
    font-size: 1.25rem;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.inv-store-details {
    font-size: 0.78rem;
    color: #64748b;
    line-height: 1.5;
}

.inv-meta-right {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.inv-tag-title {
    font-size: 1.75rem;
    font-weight: 900;
    letter-spacing: -0.04em;
    color: var(--accent-theme);
    line-height: 1;
    margin-bottom: 0.35rem;
}

.inv-number-badge {
    font-size: 0.85rem;
    font-weight: 700;
    color: #0f172a;
    background: #f1f5f9;
    padding: 0.25rem 0.7rem;
    border-radius: 6px;
    margin-bottom: 0.75rem;
    display: inline-block;
}

.inv-meta-grid {
    display: grid;
    grid-template-columns: auto auto;
    gap: 0.25rem 1rem;
    font-size: 0.76rem;
    text-align: right;
}

.inv-meta-label {
    color: #94a3b8;
    font-weight: 500;
}

.inv-meta-val {
    color: #1e293b;
    font-weight: 700;
}

/* Bill To & Info Strip */
.inv-client-strip {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-top: 1.5rem;
    padding: 1.2rem;
    background: #f8fafc;
    border: 1px solid #f1f5f9;
    border-radius: 10px;
    gap: 2rem;
}

.inv-client-col {
    flex: 1;
}

.inv-client-col:last-child {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    padding-top: 0.15rem;
}

#stampWrapper {
    margin-top: 0.85rem !important;
    display: inline-flex;
    align-items: center;
}

.inv-strip-label {
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #94a3b8;
    margin-bottom: 0.4rem;
}

.inv-client-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 0.2rem;
}

.inv-client-address {
    font-size: 0.78rem;
    color: #64748b;
    line-height: 1.45;
}

/* Modern Minimalist Table */
.inv-table-wrapper {
    margin-top: 1.5rem;
}

.inv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.inv-table th {
    padding: 0.75rem 0.5rem;
    text-align: left;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    border-bottom: 2px solid #e2e8f0;
}

.inv-table th.center, .inv-table td.center {
    text-align: center;
}

.inv-table th.right, .inv-table td.right {
    text-align: right;
}

.inv-table tbody tr {
    border-bottom: 1px solid #f1f5f9;
}

.inv-table tbody tr:last-child {
    border-bottom: 2px solid #e2e8f0;
}

.inv-table td {
    padding: 0.9rem 0.5rem;
    vertical-align: middle;
    color: #334155;
}

.inv-table td.item-name {
    font-weight: 600;
    color: #0f172a;
}

/* Calculation & Summary Section */
.inv-bottom-section {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-top: 1.5rem;
    gap: 2rem;
}

.inv-notes-block {
    flex: 1;
    font-size: 0.75rem;
    color: #64748b;
    line-height: 1.5;
    padding-top: 0.5rem;
}

.inv-summary-card {
    width: 280px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 1rem;
}

.summary-line {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    color: #64748b;
    margin-bottom: 0.5rem;
}

.summary-line.total {
    border-top: 2px dashed #cbd5e1;
    padding-top: 0.6rem;
    margin-top: 0.6rem;
    margin-bottom: 0;
    font-size: 0.98rem;
    font-weight: 800;
    color: #0f172a;
}

.summary-line.total .total-amount {
    color: var(--accent-theme);
}

/* Signature & Stamp Section */
.inv-sign-row {
    margin-top: auto;
    padding-top: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.inv-stamp-box {
    position: relative;
}

.paid-stamp {
    display: inline-block;
    padding: 0.4rem 1.2rem;
    text-transform: uppercase;
    font-weight: 900;
    font-size: 1.15rem;
    letter-spacing: 0.15em;
    border-radius: 8px;
    border: 3px solid;
    transform: rotate(-8deg) translateY(3px);
    opacity: 0.88;
    pointer-events: none;
    line-height: 1;
}

.stamp-lunas {
    color: #059669;
    border-color: #059669;
    background: rgba(16, 185, 129, 0.06);
}

.stamp-pending {
    color: #d97706;
    border-color: #d97706;
    background: rgba(245, 158, 11, 0.06);
}

.inv-sign-box {
    text-align: center;
    width: 200px;
}

.inv-sign-title {
    font-size: 0.75rem;
    color: #64748b;
    margin-bottom: 0.4rem;
}

.inv-sign-img-container {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0.4rem 0;
}

#qrSignaturePreview canvas,
#qrSignaturePreview img,
#printQrSignature canvas,
#printQrSignature img {
    display: block;
    image-rendering: pixelated;
}

#qrSignaturePreview {
    line-height: 0;
}

#printQrSignature {
    line-height: 0;
}

.inv-sign-name {
    font-size: 0.82rem;
    font-weight: 700;
    color: #0f172a;
    border-top: 1px solid #cbd5e1;
    padding-top: 0.35rem;
}

/* Watermark Overlay */
.watermark-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-30deg);
    font-size: 5rem;
    font-weight: 900;
    color: rgba(15, 23, 42, 0.035);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    pointer-events: none;
    white-space: nowrap;
    z-index: 1;
}

/* Buttons */
.btn {
    padding: 0.55rem 1rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    border: none;
    transition: all 0.15s ease;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

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

.btn-dark {
    background: #1e293b;
    color: #f8fafc;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn-dark:hover {
    background: #334155;
    color: white;
}

.btn-light {
    background: #ffffff;
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-light:hover {
    background: var(--surface-subtle);
    border-color: #cbd5e1;
}

/* Print Styles */
@media print {
    body {
        background: white;
        height: auto;
        overflow: visible;
        display: block;
    }
    .app-header, .editor-sidebar, .canvas-toolbar {
        display: none !important;
    }
    .app-main {
        height: auto;
        display: block;
    }
    .workspace-wrapper {
        background: white;
        padding: 0;
        overflow: visible;
        display: block;
    }
    .paper-viewport {
        transform: none !important;
        box-shadow: none;
        margin: 0;
    }
    .paper {
        box-shadow: none;
        padding: 12mm 15mm;
        width: 100%;
        min-height: 0;
    }
    @page {
        size: A4;
        margin: 0;
    }
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}
