:root {
    --bg-color: #0f172a;
    --sidebar-bg: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --danger: #ef4444;
    --border: #334155;
    
    --invoice-bg: #ffffff;
    --invoice-text: #1e293b;
    --invoice-muted: #64748b;
    --invoice-border: #e2e8f0;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    width: 100%;
}

/* Sidebar Controls */
.controls-panel {
    width: 320px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

.form-group input {
    background: var(--bg-color);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.75rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus {
    border-color: var(--primary);
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-secondary {
    background-color: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
}

.btn-secondary:hover {
    background-color: var(--bg-color);
}

.footer-note {
    margin-top: auto;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

/* Preview Area */
.preview-panel {
    flex: 1;
    display: flex;
    justify-content: center;
    padding: 2rem;
    overflow-y: auto;
}

/* The actual invoice document (looks like paper) */
.invoice-wrapper {
    background-color: var(--invoice-bg);
    color: var(--invoice-text);
    width: 100%;
    max-width: 800px;
    min-height: 1056px; /* standard letter height ratio */
    padding: 3rem;
    border-radius: 0.5rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Hidden inputs to make it look like static text but editable */
.hidden-input, .hidden-input-inline {
    background: transparent;
    border: 1px solid transparent;
    color: var(--invoice-text);
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.hidden-input:hover, .hidden-input:focus, .hidden-input-inline:hover, .hidden-input-inline:focus {
    border-color: var(--invoice-border);
    background: #f8fafc;
}

textarea.hidden-input {
    resize: none;
    width: 100%;
    min-height: 100px;
    line-height: 1.5;
}

/* Invoice Header */
.invoice-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 3rem;
}

.invoice-title {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--invoice-text);
    margin-bottom: 1rem;
    width: 100%;
}

.company-details {
    font-size: 0.875rem;
    color: var(--invoice-muted);
}

.invoice-meta {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    text-align: right;
}

.meta-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    font-size: 0.875rem;
}

.meta-row span {
    color: var(--invoice-muted);
    font-weight: 500;
}

.meta-row input {
    text-align: right;
    font-size: 0.875rem;
    width: 120px;
}

/* Billing Section */
.invoice-billing {
    margin-bottom: 3rem;
}

.bill-to h3 {
    font-size: 0.875rem;
    color: var(--invoice-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.client-details {
    font-size: 1rem;
    font-weight: 500;
    min-height: 80px;
}

/* Table */
.invoice-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 2rem;
}

.invoice-table th {
    text-align: left;
    padding: 0.75rem 0;
    border-bottom: 2px solid var(--invoice-border);
    color: var(--invoice-muted);
    font-size: 0.875rem;
    font-weight: 600;
}

.invoice-table td {
    padding: 1rem 0;
    border-bottom: 1px solid var(--invoice-border);
    vertical-align: top;
}

.col-desc { width: 50%; }
.col-qty { width: 15%; text-align: center; }
.col-price { width: 15%; text-align: right; }
.col-total { width: 15%; text-align: right; }
.col-action { width: 5%; text-align: right; }

.invoice-table th.col-qty, .invoice-table td.col-qty { text-align: center; }
.invoice-table th.col-price, .invoice-table td.col-price { text-align: right; }
.invoice-table th.col-total, .invoice-table td.col-total { text-align: right; font-weight: 600; }

.item-desc { width: 100%; font-size: 0.875rem; }
.item-qty { width: 60px; text-align: center; font-size: 0.875rem; }
.item-price { width: 80px; text-align: right; font-size: 0.875rem; }

.btn-delete {
    background: transparent;
    border: none;
    color: var(--invoice-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
}

.btn-delete:hover {
    color: var(--danger);
    background: #fee2e2;
}

/* Summary */
.invoice-summary {
    display: flex;
    justify-content: space-between;
    gap: 2rem;
}

.notes {
    flex: 1;
}

.notes h3 {
    font-size: 0.875rem;
    color: var(--invoice-muted);
    margin-bottom: 0.5rem;
}

.notes textarea {
    font-size: 0.875rem;
    color: var(--invoice-muted);
}

.totals {
    width: 250px;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.total-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--invoice-muted);
}

.grand-total {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--invoice-text);
    border-top: 2px solid var(--invoice-border);
    padding-top: 0.75rem;
    margin-top: 0.25rem;
}

/* PDF Export styles */
@media print {
    body { background: white; }
    .controls-panel { display: none; }
    .preview-panel { padding: 0; display: block; }
    .invoice-wrapper { box-shadow: none; padding: 0; max-width: 100%; }
    .hide-in-pdf { display: none !important; }
    .hidden-input, .hidden-input-inline { border: none !important; background: transparent !important; }
}
