/* ============================================
   Invoice Generator - Main Styles
   ============================================ */

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

:root {
    --primary-bg: #0f0f0f;
    --secondary-bg: #1a1a1a;
    --card-bg: #222222;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --border-color: #333333;
    --success: #22c55e;
    --paper-bg: #ffffff;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--primary-bg);
    color: var(--text-primary);
    min-height: 100vh;
}

/* ============================================
   App Layout
   ============================================ */

.app-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 100vh;
    gap: 0;
}

/* ============================================
   Form Section
   ============================================ */

.form-section {
    background: var(--secondary-bg);
    padding: 30px;
    overflow-y: auto;
    max-height: 100vh;
}

.form-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.form-header h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #fff 0%, #a0a0a0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.form-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Form Cards */
.form-group-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    transition: border-color 0.3s ease;
}

.form-group-card:hover {
    border-color: var(--accent);
}

.form-group-card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* Form Elements */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

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

.form-group {
    margin-bottom: 16px;
}

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

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 14px;
    background: var(--primary-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

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

/* Items Container */
#itemsContainer {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.item-row {
    display: grid;
    grid-template-columns: 2fr 3fr 1fr 2fr auto;
    gap: 10px;
    align-items: end;
    padding: 16px;
    background: var(--primary-bg);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.item-row .form-group {
    margin-bottom: 0;
}

.btn-remove-item {
    width: 36px;
    height: 36px;
    border: none;
    background: #ef4444;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.btn-remove-item:hover {
    background: #dc2626;
    transform: scale(1.05);
}

.btn-add-item {
    width: 100%;
    padding: 14px;
    background: transparent;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-add-item:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(59, 130, 246, 0.05);
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.btn-preview,
.btn-export,
.btn-save,
.btn-clear {
    flex: 1;
    padding: 16px 24px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 140px;
}

.btn-preview {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

.btn-save {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(34, 197, 94, 0.3);
}

.btn-save:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(34, 197, 94, 0.4);
}

.btn-clear {
    background: var(--card-bg);
    color: #ef4444;
    border: 1px solid #ef4444;
}

.btn-clear:hover {
    background: rgba(239, 68, 68, 0.1);
}

.btn-export {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.btn-export:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

/* ============================================
   Preview Section
   ============================================ */

.preview-section {
    background: var(--primary-bg);
    padding: 30px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.preview-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.preview-size {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--card-bg);
    padding: 6px 12px;
    border-radius: 20px;
}

.preview-wrapper {
    flex: 1;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    background: var(--card-bg);
    border-radius: 12px;
}

/* ============================================
   Invoice Paper (912 x 1280 pixels)
   ============================================ */

.invoice-paper {
    width: 912px;
    min-height: 1280px;
    background: var(--paper-bg);
    color: #000;
    padding: 0;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    font-family: 'Courier Prime', 'Courier New', monospace;
    position: relative;
    transform-origin: top center;
    transform: scale(0.55);
    margin-bottom: -580px;
}

/* Top Black Bar */
.invoice-paper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 8px;
    background: #000;
}

/* Bottom Black Bar */
.invoice-paper::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 12px;
    background: #000;
}

.invoice-content {
    padding: 30px 40px;
    padding-top: 25px;
}

/* Invoice Header */
.invoice-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 40px;
    margin-top: 10px;
}

.invoice-title-section h1 {
    font-family: 'Inter', sans-serif;
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 12px;
    letter-spacing: 2px;
}

.invoice-meta {
    font-size: 14px;
    line-height: 1.8;
    font-weight: 600;
}

.invoice-meta p {
    margin: 0;
    white-space: nowrap;
}

.company-section {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.company-logo {
    max-width: 120px;
    max-height: 80px;
    margin-bottom: 12px;
    /* Invert colors: black bg becomes white, white text becomes black */
    filter: invert(1);
}

.company-contact {
    font-size: 14px;
    line-height: 1.8;
    text-align: right;
    font-weight: 600;
    white-space: nowrap;
}

/* Bill To Section */
.bill-to-section {
    margin-bottom: 30px;
}

.bill-to-section h2 {
    font-family: 'Inter', sans-serif;
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 5px;
}

.bill-to-section .client-name {
    font-size: 16px;
    letter-spacing: 1px;
    color: #000000;
    font-weight: 600;
}

/* Invoice Table */
.invoice-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 30px;
    table-layout: fixed;
}

.invoice-table thead {
    background: #000;
    color: #fff;
}

.invoice-table th {
    padding: 12px 15px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1px;
    font-family: 'Courier Prime', monospace;
}

.invoice-table th:nth-child(3),
.invoice-table th:nth-child(4) {
    text-align: center;
}

.invoice-table td {
    padding: 15px;
    font-size: 14px;
    font-weight: 600;
    border-bottom: 1px solid #e0e0e0;
    vertical-align: top;
    color: #000000;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.invoice-table td:nth-child(1) {
    /* ITEM column */
    word-break: break-word;
}

.invoice-table td:nth-child(2) {
    /* DESCRIPTION column */
    word-break: break-word;
}

.invoice-table td:nth-child(3) {
    /* QTY column */
    text-align: center;
    word-break: break-word;
}

.invoice-table td:nth-child(4) {
    /* TOTAL column */
    text-align: right;
    word-break: break-word;
}

.invoice-table tbody tr:last-child td {
    border-bottom: 2px solid #000;
}

/* Total Row */
.total-row {
    text-align: right;
    margin-top: 15px;
    margin-bottom: 60px;
}

.total-box {
    display: inline-block;
    background: #f5f5f5;
    padding: 12px 25px;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
    white-space: nowrap;
    color: #000000;
}

/* Summary Section */
.summary-section {
    text-align: right;
    margin-top: 15px;
}

.summary-table {
    display: inline-block;
    background: #f5f5f5;
    border-collapse: collapse;
}

.summary-table td {
    padding: 8px 15px;
    font-size: 14px;
    font-weight: 600;
    color: #000000;
    white-space: nowrap;
}

.summary-table .summary-label {
    text-align: left;
    padding-right: 30px;
}

.summary-table .summary-value {
    text-align: right;
}

/* Payment Info */
.payment-section {
    position: absolute;
    bottom: 50px;
    left: 40px;
}

.payment-section h3 {
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 10px;
}

.payment-section p {
    font-size: 14px;
    line-height: 1.8;
    margin: 0;
    white-space: nowrap;
    color: #000000;
}

.payment-section strong {
    font-weight: 700;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 1400px) {
    .invoice-paper {
        transform: scale(0.5);
        margin-bottom: -640px;
    }
}

@media (max-width: 1200px) {
    .app-container {
        grid-template-columns: 1fr;
    }

    .form-section {
        max-height: none;
    }

    .preview-section {
        min-height: 100vh;
    }

    .invoice-paper {
        transform: scale(0.45);
        margin-bottom: -700px;
    }
}

@media (max-width: 768px) {

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

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

    .invoice-paper {
        transform: scale(0.35);
        margin-bottom: -830px;
    }
}

/* ============================================
   Print Styles (for PDF)
   ============================================ */

@media print {
    body {
        background: white;
    }

    .form-section,
    .preview-header {
        display: none !important;
    }

    .app-container {
        display: block;
    }

    .preview-section {
        padding: 0;
        background: white;
    }

    .preview-wrapper {
        padding: 0;
        background: white;
    }

    .invoice-paper {
        transform: none;
        margin: 0;
        box-shadow: none;
    }
}