:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --secondary: #f59e0b;
    --dark: #1e293b;
    --light: #f8fafc;
    --gray: #94a3b8;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --border: #e2e8f0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body {
    background: linear-gradient(135deg, #f0f4ff 0%, #fef7ff 100%);
    min-height: 100vh;
    padding: 20px;
    color: var(--dark);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    background: var(--primary);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 6px rgba(99, 102, 241, 0.2);
}

.logo-text h1 {
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(to right, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.logo-text p {
    font-size: 13px;
    color: var(--gray);
}

.header-actions {
    display: flex;
    gap: 15px;
}

.btn {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 6px rgba(99, 102, 241, 0.2);
}

.btn-primary:hover {
    background: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(99, 102, 241, 0.3);
}

.btn-outline {
    background: white;
    color: var(--primary);
    border: 1px solid var(--primary);
}

.btn-outline:hover {
    background: #f0f4ff;
}

/* Toast Notification */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 25px;
    background: var(--success);
    color: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateX(150%);
    transition: transform 0.3s ease;
    z-index: 1000;
    max-width: 300px;
}

.toast.show {
    transform: translateX(0);
}

.toast.error {
    background: var(--danger);
}

.toast.warning {
    background: var(--warning);
}

/* Main layout */
.main-content {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 30px;
}

/* Invoice Form */
.invoice-form {
    background: white;
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
}

.form-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 30px;
}

.invoice-title h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 5px;
    cursor: text;
    padding: 5px 10px;
    border-radius: 6px;
    transition: all 0.2s;
}

.invoice-title h2:hover {
    background: #f8fafc;
}

.invoice-title h2:focus {
    outline: none;
    background: white;
    border: 1px solid var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.invoice-title p {
    color: var(--gray);
    font-size: 14px;
    cursor: text;
    padding: 5px 10px;
    border-radius: 6px;
    transition: all 0.2s;
}

.invoice-title p:hover {
    background: #f8fafc;
}

.invoice-title p:focus {
    outline: none;
    background: white;
    border: 1px solid var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Editable Invoice Number */
.invoice-number-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.invoice-number-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.invoice-number-input {
    background: #f0f4ff;
    padding: 10px 16px;
    border-radius: 10px;
    font-weight: 700;
    color: var(--primary);
    border: 2px solid transparent;
    font-size: 16px;
    text-align: center;
    min-width: 180px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.invoice-number-input:hover {
    background: #e0e7ff;
    border-color: rgba(99, 102, 241, 0.3);
}

.invoice-number-input:focus {
    outline: none;
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    cursor: text;
}

.invoice-number-hint {
    font-size: 11px;
    color: var(--gray);
    font-style: italic;
}

.form-section {
    margin-bottom: 30px;
}

/* Editable Section Titles */
.section-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--dark);
    cursor: text;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.2s;
}

.section-title:hover {
    background: #f8fafc;
}

.section-title:focus {
    outline: none;
    background: white;
    border: 1px solid var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.section-title i {
    color: var(--primary);
    flex-shrink: 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

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

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--dark);
}

.input-with-icon {
    position: relative;
}

.input-with-icon i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray);
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    padding-left: 40px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Address Textarea */
.address-textarea {
    width: 100%;
    min-height: 120px;
    padding: 12px 15px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    resize: vertical;
    line-height: 1.5;
    font-family: inherit;
}

.address-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.address-group {
    background: #f8fafc;
    border-radius: 10px;
    padding: 20px;
    border: 1px solid var(--border);
}

.address-group h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

.address-group h4 i {
    color: var(--primary);
}

.address-hint {
    font-size: 12px;
    color: var(--gray);
    margin-top: 5px;
    font-style: italic;
}

.logo-upload {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 20px;
}

.logo-upload:hover {
    border-color: var(--primary);
    background: #f8fafc;
}

.logo-upload i {
    font-size: 40px;
    color: var(--primary-light);
    margin-bottom: 10px;
}

.logo-upload p {
    color: var(--gray);
    font-size: 14px;
}

.logo-preview {
    margin-top: 15px;
    text-align: center;
    display: none;
}

.logo-preview img {
    max-width: 200px;
    max-height: 100px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Items Table with Delete Buttons */
.items-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.items-table thead {
    background: #f8fafc;
}

.items-table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: var(--dark);
    border-bottom: 1px solid var(--border);
}

.items-table td {
    padding: 15px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.item-input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
}

.delete-item-btn {
    background: none;
    border: none;
    color: var(--danger);
    font-size: 16px;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.delete-item-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    transform: scale(1.1);
}

.add-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px;
    margin-top: 15px;
    background: #f8fafc;
    border: 1px dashed var(--border);
    border-radius: 8px;
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.add-item:hover {
    background: #f0f4ff;
    border-color: var(--primary);
}

/* Invoice Summary with Advanced Controls */
.invoice-summary {
    background: white;
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 20px;
}

.summary-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 25px;
    color: var(--dark);
    cursor: text;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.2s;
}

.summary-title:hover {
    background: #f8fafc;
}

.summary-title:focus {
    outline: none;
    background: white;
    border: 1px solid var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.summary-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

.summary-label {
    color: var(--gray);
    font-weight: 500;
}

.summary-value {
    font-weight: 600;
    text-align: right;
}

/* Currency/Toggle Controls */
.currency-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 30px;
}

.currency-selector select {
    padding: 8px 15px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-weight: 600;
    color: var(--dark);
    background: white;
}

/* Percentage/Amount Toggle */
.amount-control {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8fafc;
    border-radius: 10px;
}

.amount-control-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.amount-control-label {
    font-weight: 600;
    font-size: 14px;
    color: var(--dark);
}

.toggle-switch {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 4px;
    border-radius: 20px;
    border: 1px solid var(--border);
}

.toggle-option {
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    color: var(--gray);
}

.toggle-option.active {
    background: var(--primary);
    color: white;
}

.amount-control-inputs {
    display: flex;
    gap: 10px;
}

.amount-input-group {
    flex: 1;
}

.amount-input-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    text-align: right;
}

.amount-input-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.input-suffix {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray);
    font-size: 14px;
    pointer-events: none;
}

.relative {
    position: relative;
}

.total-section {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 2px solid var(--border);
}

.total-row {
    display: flex;
    justify-content: space-between;
    font-size: 20px;
    font-weight: 700;
    color: var(--dark);
    margin-top: 10px;
    cursor: text;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.2s;
}

.total-row:hover {
    background: #f8fafc;
}

.total-row:focus {
    outline: none;
    background: white;
    border: 1px solid var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.amount-due {
    color: var(--primary);
}

.amount-paid-input {
    width: 120px;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-align: right;
    font-weight: 600;
    font-size: 16px;
}

.amount-paid-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Custom Payment Terms */
.payment-terms-container {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.payment-term-option {
    padding: 8px 16px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
}

.payment-term-option:hover {
    border-color: var(--primary);
    background: #f0f4ff;
}

.payment-term-option.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.custom-days-input {
    width: 80px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 14px;
}

.custom-days-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Notes & Terms */
.notes-terms {
    margin-top: 30px;
}

.textarea-group {
    margin-bottom: 20px;
}

.textarea-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--dark);
}

textarea {
    width: 100%;
    padding: 15px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    min-height: 100px;
    resize: vertical;
}

textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Footer */
.footer {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    color: var(--gray);
    font-size: 14px;
    cursor: text;
    padding: 10px;
    border-radius: 6px;
    transition: all 0.2s;
}

.footer:hover {
    background: #f8fafc;
}

.footer:focus {
    outline: none;
    background: white;
    border: 1px solid var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.color-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 15px;
}

.color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.dot-1 { background: var(--primary); }
.dot-2 { background: var(--secondary); }
.dot-3 { background: var(--success); }
.dot-4 { background: #8b5cf6; }

/* Same Billing Address Checkbox */
.same-address {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 15px;
    padding: 12px 15px;
    background: #f0f4ff;
    border-radius: 8px;
    cursor: pointer;
}

.same-address input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.same-address label {
    cursor: pointer;
    font-weight: 500;
    color: var(--dark);
    margin: 0;
}

/* Responsive */
@media (max-width: 992px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .invoice-summary {
        position: static;
    }
}

@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .header {
        flex-direction: column;
        gap: 20px;
        align-items: flex-start;
    }
    
    .header-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    .form-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
    }
    
    .invoice-number-container {
        align-items: flex-start;
    }
    
    .amount-control-inputs {
        flex-direction: column;
    }
    
    .payment-terms-container {
        flex-direction: column;
        align-items: flex-start;
    }
}
