:root {
    --primary-color: #4361ee;
    --secondary-color: #3f37c9;
    --accent-color: #4895ef;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    --success-color: #4cc9f0;
    --danger-color: #f72585;
    --warning-color: #f8961e;
    --info-color: #43aa8b;
    
    --text-primary: #333;
    --text-secondary: #666;
    --text-light: #f8f9fa;
    
    --bg-color: #ffffff;
    --card-bg: #f8f9fa;
    --border-color: #dee2e6;
    
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1), 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1), 0 5px 10px rgba(0,0,0,0.05);
    
    --border-radius-sm: 4px;
    --border-radius-md: 8px;
    --border-radius-lg: 12px;
}

[data-theme="dark"] {
    --primary-color: #4895ef;
    --secondary-color: #4361ee;
    --accent-color: #3f37c9;
    --light-color: #343a40;
    --dark-color: #f8f9fa;
    
    --text-primary: #f8f9fa;
    --text-secondary: #e9ecef;
    
    --bg-color: #212529;
    --card-bg: #343a40;
    --border-color: #495057;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-color);
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

h1, h2, h3, h4 {
    color: var(--primary-color);
    margin-bottom: 15px;
}

h1 {
    font-size: 2.2rem;
}

h2 {
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.theme-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 30px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--light-color);
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background-color: var(--primary-color);
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--dark-color);
}

input:checked + .slider:before {
    transform: translateX(30px);
}

.invoice-container {
    width: 100%;
}

.invoice-form {
    display: flex;
    flex-wrap: wrap;
    gap:20px;
}


@media (max-width: 1200px) {
    .invoice-container {
        grid-template-columns: 1fr;
    }
    
    .invoice-preview-container {
        order: -1;
        margin-bottom: 30px;
    }
}

.controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 15px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    height: 50px;
}

.btn:hover {
    background-color: var(--secondary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

.btn-danger {
    background-color: var(--danger-color);
}

.btn-danger:hover {
    background-color: #d1145a;
}

.form-section {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: var(--border-radius-md);
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    width: 49%;
}

.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.form-row:last-child {
    margin-bottom: 0;
}

.form-group {
    flex: 1;
    margin-bottom: 10px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input,
.form-group textarea,
textarea,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background-color: var(--bg-color);
    color: var(--text-primary);
}

.form-group textarea {
    min-height: 80px;
    resize: vertical;
}

.items-table {
    width: 100%;
}

.items-header {
    display: flex;
    background-color: var(--primary-color);
    color: white;
    padding: 10px;
    border-radius: var(--border-radius-sm) var(--border-radius-sm) 0 0;
    font-weight: 500;
}

.item-col {
    padding: 0 5px;
}

.description {
    flex: 3;
}

.quantity, .price, .tax, .amount {
    flex: 1;
    text-align: center;
}

.action {
    width: 40px;
    text-align: center;
}

#itemsContainer {
    margin-bottom: 10px;
}

.item-row {
    display: flex;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    gap: 5px;
}

.item-row input {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background-color: var(--bg-color);
    color: var(--text-primary);
}

.remove-item {
    background: none;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    font-size: 1.2rem;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.remove-item:hover {
    background-color: rgba(247, 37, 133, 0.1);
}

#addItem {
    margin-top: 10px;
}

.totals-row {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.summary {
    background-color: var(--card-bg);
    padding: 15px;
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-sm);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px dashed var(--border-color);
}

.summary-row.total {
    font-weight: bold;
    font-size: 1.1rem;
    border-bottom: none;
    padding-top: 10px;
    margin-top: 10px;
    border-top: 1px solid var(--border-color);
}

.invoice-preview-container {
    position: sticky;
    top: 20px;
    height: fit-content;
}

.invoice-paper {
    background-color: white;
    padding: 30px;
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-lg);
    color: #333;
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 20px;
}

.company-info {
    flex: 2;
}

.invoice-title {
    flex: 1;
    text-align: right;
}

.invoice-title h1 {
    color: #333;
    margin-bottom: 10px;
}

.invoice-meta {
    text-align: right;
}

.meta-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.meta-row span:first-child {
    font-weight: bold;
    margin-right: 10px;
}

.client-info {
    margin-bottom: 30px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: var(--border-radius-md);
}

.client-info h3 {
    margin-bottom: 10px;
    color: #333;
}

.invoice-items {
    margin-bottom: 30px;
}

.items-header {
    display: flex;
    background-color: #f8f9fa;
    color: #333;
    padding: 10px;
    font-weight: bold;
    border-radius: var(--border-radius-sm) var(--border-radius-sm) 0 0;
}

.col-desc {
    flex: 3;
}

.col-qty, .col-price, .col-tax, .col-total {
    flex: 1;
    text-align: center;
}

.preview-item-row {
    display: flex;
    padding: 10px;
    border-bottom: 1px solid #eee;
}

.empty-message {
    text-align: center;
    padding: 20px;
    color: #999;
    font-style: italic;
}

.invoice-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.summary-notes {
    flex: 2;
    min-width: 300px;
}

.summary-totals {
    flex: 1;
    min-width: 250px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.grand-total {
    font-weight: bold;
    font-size: 1.2rem;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

.invoice-footer {
    margin-top: 30px;
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid #eee;
    color: #666;
}

@media print {
    body * {
        visibility: hidden;
    }
    .invoice-paper, .invoice-paper * {
        visibility: visible;
    }
    .invoice-paper {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        box-shadow: none;
    }
    .no-print {
        display: none !important;
    }
}