/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #16c79a;
    --secondary-color: #11698e;
    --dark-bg: #0f0f1e;
    --darker-bg: #1a1a2e;
    --accent: #19d3ae;
    --text-light: #e0e0e0;
    --text-dark: #a0a0a0;
    --border-color: #2a2a3e;
    --glow: 0 0 20px rgba(22, 199, 154, 0.3);
    --glow-strong: 0 0 30px rgba(22, 199, 154, 0.6);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, var(--dark-bg) 0%, var(--darker-bg) 100%);
    color: var(--text-light);
    line-height: 1.6;
    min-height: 100vh;
}

/* Container Layout */
.container {
    display: grid;
    grid-template-columns: 420px 1fr;
    min-height: 100vh;
    max-width: 1600px;
    margin: 0 auto;
    background: var(--darker-bg);
    box-shadow: 0 0 60px rgba(22, 199, 154, 0.2);
}

/* Input Panel */
.input-panel {
    background: linear-gradient(180deg, var(--darker-bg) 0%, var(--dark-bg) 100%);
    padding: 30px;
    overflow-y: auto;
    border-right: 2px solid var(--border-color);
    position: relative;
}

.input-panel::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 2px;
    height: 100%;
    background: linear-gradient(180deg, transparent, var(--primary-color), transparent);
    opacity: 0.5;
}

/* App Header */
.app-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
    position: relative;
}

.app-header::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100px;
    height: 2px;
    background: var(--primary-color);
    box-shadow: var(--glow);
}

.app-logo {
    width: 60px;
    height: 60px;
    filter: drop-shadow(var(--glow));
    animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.app-title h1 {
    font-family: 'Orbitron', sans-serif;
    font-size: 28px;
    font-weight: 900;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: var(--glow);
    margin: 0;
}

.app-title .subtitle {
    font-size: 12px;
    color: var(--text-dark);
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-top: 5px;
}

.app-footer {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.app-footer p {
    font-size: 11px;
    color: var(--text-dark);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.form-section {
    margin-bottom: 30px;
    animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.form-section h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 15px;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 2px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-section h2::before {
    content: '';
    width: 4px;
    height: 16px;
    background: var(--primary-color);
    box-shadow: var(--glow);
}

/* Form Inputs */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="number"],
textarea {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.3s;
}

input:focus,
textarea:focus {
    outline: none;
    border-color: #3498db;
}

textarea {
    resize: vertical;
}

input[type="file"] {
    margin-bottom: 5px;
}

.help-text {
    font-size: 12px;
    color: #7f8c8d;
    margin-top: -5px;
}

/* Tax Input */
.tax-input {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tax-input input {
    flex: 1;
    margin-bottom: 0;
}

.tax-input span {
    font-weight: 600;
    color: #34495e;
}

/* Line Items */
.line-item {
    background: white;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 10px;
    border: 1px solid #e0e0e0;
}

.line-item-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

.line-item input {
    margin-bottom: 0;
}

.line-item-actions {
    text-align: right;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
    margin-bottom: 10px;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: white;
    color: #3498db;
    border: 2px solid #3498db;
}

.btn-secondary:hover {
    background: #3498db;
    color: white;
}

.btn-danger {
    background: #e74c3c;
    color: white;
    padding: 6px 12px;
    font-size: 12px;
}

.btn-danger:hover {
    background: #c0392b;
}

/* Preview Panel */
.preview-panel {
    padding: 40px;
    overflow-y: auto;
    background: #fff;
}

/* Invoice Styles */
.invoice {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    padding: 40px;
    border: 1px solid #e0e0e0;
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 2px solid #34495e;
}

.logo-container img {
    max-width: 150px;
    max-height: 80px;
    object-fit: contain;
}

.business-info {
    text-align: right;
}

.business-info h3 {
    font-size: 20px;
    margin-bottom: 10px;
    color: #2c3e50;
}

.business-info p {
    font-size: 14px;
    color: #555;
    margin-bottom: 5px;
}

.invoice-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.invoice-title h1 {
    font-size: 36px;
    color: #2c3e50;
}

.invoice-meta {
    text-align: right;
}

.invoice-meta p {
    font-size: 14px;
    margin-bottom: 5px;
}

.client-section {
    margin-bottom: 30px;
}

.client-section h3 {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    color: #7f8c8d;
    margin-bottom: 10px;
}

.client-info p {
    font-size: 14px;
    color: #333;
    margin-bottom: 5px;
}

.preserve-linebreaks {
    white-space: pre-line;
}

/* Line Items Table */
.line-items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 30px;
}

.line-items-table thead {
    background: #34495e;
    color: white;
}

.line-items-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
}

.line-items-table th:last-child,
.line-items-table td:last-child {
    text-align: right;
}

.line-items-table td {
    padding: 12px;
    border-bottom: 1px solid #e0e0e0;
    font-size: 14px;
}

.line-items-table tbody tr:last-child td {
    border-bottom: 2px solid #34495e;
}

.empty-state {
    text-align: center !important;
    color: #95a5a6;
    font-style: italic;
}

/* Totals Section */
.totals-section {
    margin-left: auto;
    width: 300px;
}

.totals-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    font-size: 14px;
}

.totals-row.total {
    border-top: 2px solid #34495e;
    margin-top: 10px;
    padding-top: 15px;
    font-size: 18px;
    font-weight: 700;
    color: #2c3e50;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .container {
        grid-template-columns: 350px 1fr;
    }
}

@media (max-width: 768px) {
    .container {
        grid-template-columns: 1fr;
    }

    .input-panel {
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }

    .preview-panel {
        padding: 20px;
    }

    .invoice {
        padding: 20px;
    }

    .invoice-header {
        flex-direction: column;
        gap: 20px;
    }

    .business-info {
        text-align: left;
    }

    .invoice-title {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .invoice-meta {
        text-align: left;
    }

    .totals-section {
        width: 100%;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
    }

    .container {
        display: block;
        box-shadow: none;
    }

    .input-panel {
        display: none !important;
    }

    .preview-panel {
        padding: 0;
    }

    .invoice {
        border: none;
        padding: 20px;
        max-width: 100%;
    }

    .line-items-table {
        page-break-inside: avoid;
    }

    .totals-section {
        page-break-inside: avoid;
    }
}
