/* --- Invoice specific styles --- */
body {
    background-color: #F0F2F5;
    /* Darker bg for invoice context */
}

.invoice-workspace {
    display: flex;
    justify-content: center;
    gap: 32px;
    padding: 40px;
    align-items: flex-start;
    flex-wrap: wrap;
    /* Added for responsiveness */
}

/* Paper */
.page-paper {
    background: white;
    width: 800px;
    max-width: 100%;
    /* Added for responsiveness */
    /* A4-ish */
    min-height: 1100px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    /* Sharper corners for paper feel */
    padding: 60px;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: all 0.3s ease;
}

/* Logo Area */
.logo-wrapper {
    position: relative;
    width: fit-content;
}

.logo-placeholder {
    width: 150px;
    height: 80px;
    background: #F9FAFB;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #9CA3AF;
    font-size: 12px;
    border: 1px dashed #E5E5EA;
    cursor: pointer;
    transition: all 0.2s ease;
    overflow: hidden;
}

.logo-placeholder i {
    font-size: 20px;
    margin-bottom: 4px;
}

.logo-placeholder:hover {
    border-color: var(--accent-blue);
    background: #EFF6FF;
    color: var(--accent-blue);
}

.logo-placeholder img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.remove-logo-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #EF4444;
    color: white;
    border: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.3);
}

.logo-wrapper:hover .remove-logo-btn {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

/* Header */
.invoice-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 50px;
    align-items: flex-start;
}

.invoice-title-block {
    text-align: right;
}

.invoice-title-block h1 {
    font-size: 36px;
    letter-spacing: 2px;
    margin-bottom: 20px;
    color: #111827;
    font-weight: 300;
    /* Cleaner look */
}

.meta-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-bottom: 8px;
    gap: 12px;
}

.meta-row label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: #6B7280;
    text-transform: uppercase;
}

.meta-row input {
    width: 120px;
    text-align: right;
    border: 1px solid transparent;
    font-weight: 500;
    color: #111827;
    font-size: 14px;
    outline: none;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.meta-row input:hover {
    background: #F9FAFB;
}

.meta-row input:focus {
    background: white;
    border-color: var(--accent-blue);
}

.business-name-input {
    font-size: 24px;
    font-weight: 600;
    color: #111827;
    border: 1px solid transparent;
    margin-bottom: 40px;
    width: 100%;
    outline: none;
    padding: 8px 0;
    border-radius: 4px;
    background: transparent;
    transition: all 0.2s;
}

.business-name-input:hover {
    background: #F9FAFB;
    padding-left: 8px;
}

.business-name-input:focus {
    background: #F0F9FF;
    border-color: transparent;
    color: var(--accent-blue);
    padding-left: 8px;
}

.business-name-input::placeholder {
    color: #E5E7EB;
}


/* Billing Grid */
.billing-grid {
    display: flex;
    gap: 40px;
    /* Reduced from 80px */
    margin-bottom: 50px;
    flex-wrap: wrap;
    /* Added for responsiveness */
}

.bill-col {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.bill-col label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: #9CA3AF;
    margin-bottom: 12px;
    text-transform: uppercase;
}

.bill-col .field {
    font-weight: 600;
    font-size: 15px;
    border: 1px solid transparent;
    margin-bottom: 4px;
    width: 100%;
    outline: none;
    padding: 4px 0;
    color: #111827;
    background: transparent;
    border-radius: 4px;
}

.bill-col .field-area {
    border: 1px solid transparent;
    resize: none;
    font-size: 14px;
    color: #4B5563;
    min-height: 80px;
    outline: none;
    font-family: inherit;
    line-height: 1.5;
    background: transparent;
    padding: 4px 0;
    border-radius: 4px;
}

.bill-col input:hover,
.bill-col textarea:hover {
    background: #F9FAFB;
    padding-left: 8px;
}

.bill-col input:focus,
.bill-col textarea:focus {
    background: white;
    border-color: #E5E7EB;
    padding-left: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Table */
.line-items {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px;
    /* Space between rows */
    margin-bottom: 16px;
}

.line-items th {
    text-align: left;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    color: #6B7280;
    padding: 0 8px 12px 8px;
    border-bottom: 2px solid #F3F4F6;
    text-transform: uppercase;
}

.col-qty,
.col-price,
.col-amt {
    text-align: right !important;
}

.line-items td {
    padding: 0;
    vertical-align: top;
}

/* Beautiful Inputs in Table */
.line-items input {
    border: 1px solid transparent;
    width: 100%;
    font-size: 14px;
    outline: none;
    background: transparent;
    padding: 10px 8px;
    color: #374151;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.line-items tr:hover input {
    background: #F9FAFB;
}

.line-items input:focus {
    background: white !important;
    border-color: #D1D5DB;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    color: #111827;
}

.line-items .desc-input {
    font-weight: 500;
}

.line-items .amt {
    font-weight: 600;
    color: #111827;
    padding: 10px 8px;
    display: block;
    /* Align with inputs */
}

/* Column Widths */
.col-desc {
    width: 50%;
}

.col-qty {
    width: 10%;
}

.col-price {
    width: 15%;
}

.col-amt {
    width: 15%;
}

.col-actions {
    width: 5%;
}

/* Add Button & Footer */
.table-actions {
    margin-bottom: 20px;
    padding-left: 8px;
    /* Align with inputs */
}

.add-line-btn {
    border: none;
    background: transparent;
    color: #6B7280;
    /* Muted gray */
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
    padding: 6px 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.add-line-btn i {
    font-size: 16px;
    color: var(--accent-blue);
}

.add-line-btn:hover {
    background: #F9FAFB;
    color: #111827;
}

.add-line-btn:active {
    background: #F3F4F6;
}

/* Footer Layout (Notes & Totals) */
.invoice-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 40px;
    flex-wrap: wrap;
    /* Added for responsiveness */
    margin-top: auto;
    /* Push to bottom if height is fixed, but here it flows */
    padding-top: 20px;
}

.notes-section {
    flex: 1;
    max-width: 50%;
}

.notes-section label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #9CA3AF;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.notes-section textarea {
    width: 100%;
    border: 1px solid transparent;
    color: #4B5563;
    font-size: 13px;
    resize: none;
    outline: none;
    background: #F9FAFB;
    padding: 12px;
    border-radius: 8px;
    line-height: 1.6;
    transition: all 0.2s;
    height: 100px;
}

.notes-section textarea:focus {
    background: white;
    border-color: #E5E7EB;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.totals-section {
    width: 300px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: #6B7280;
}

.summary-row .label {
    font-weight: 500;
}

.summary-row .value {
    color: #374151;
    font-weight: 600;
}

.summary-divider {
    height: 1px;
    background: #E5E7EB;
    margin: 4px 0;
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 16px;
    color: #111827;
}

.total-row .label {
    font-weight: 600;
}

.total-val {
    font-size: 24px;
    font-weight: 700;
    color: #111827;
    /* Standard black for professional look */
}

/* Sidebar */
.invoice-sidebar {
    width: 300px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0, 0, 0, 0.03);
}

.actions-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-primary-black,
.btn-secondary-white {
    width: 100%;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: var(--transition-base);
}

.btn-primary-black {
    background: var(--text-primary);
    color: #fff;
    border: 1px solid var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.btn-primary-black:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary-white {
    background: #fff;
    color: var(--text-primary);
    border: 1px solid #E5E7EB;
}

.btn-secondary-white:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-success {
    background: #10B981 !important;
    color: white !important;
    border-color: #10B981 !important;
}

.settings-title {
    font-size: 11px;
    font-weight: 700;
    color: #9CA3AF;
    letter-spacing: 1px;
    margin-bottom: 16px;
    text-transform: uppercase;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

.setting-row:last-child {
    margin-bottom: 0;
}

/* Inputs in sidebar */
.currency-select,
.tax-input {
    background: #FFFFFF;
    border: 1px solid #E5E7EB;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 13px;
    color: #111827;
    outline: none;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    cursor: pointer;
    transition: all 0.2s ease;
}

.currency-select:hover,
.tax-input:hover {
    border-color: var(--accent-blue);
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.1);
}

.currency-select:focus,
.tax-input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.currency-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M2 2l4 4 4-4' fill='none' stroke='%239CA3AF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.currency-select option {
    padding: 10px;
    font-weight: 500;
    background: white;
    color: #111827;
}

.currency-select:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.currency-select option {
    background: #ffffff;
    color: #111827;
}

.invoice-toast {
    position: fixed;
    right: 28px;
    bottom: 28px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 12px;
    background: #111827;
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: var(--transition-base);
    z-index: 9999;
}

.invoice-toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.invoice-toast.error {
    background: #DC2626;
}

.toggle-switch-sm {
    width: 32px;
    height: 18px;
    background: #E5E7EB;
    border-radius: 20px;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
}

.toggle-switch-sm .knob {
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: left 0.2s, right 0.2s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Print Styles */
@media print {
    body {
        margin: 0;
        padding: 0;
        background: white;
    }

    .invoice-workspace {
        display: block;
        padding: 0;
        width: 100%;
        margin: 0;
    }

    .page-paper {
        box-shadow: none;
        padding: 40px !important;
        width: 100% !important;
        margin: 0;
        border-radius: 0;
    }

    .tool-nav,
    .invoice-sidebar,
    .add-line-btn,
    .col-actions,
    .actions,
    .logo-placeholder span,
    /* Hide "Add Logo" text if empty */
    .remove-logo-btn {
        display: none !important;
    }

    /* Ensure inputs look like text */
    input,
    textarea {
        border: none !important;
        background: transparent !important;
        padding: 0 !important;
        resize: none;
    }

    .meta-row input {
        text-align: right;
    }

    /* Hide placeholder text when printing */
    input::placeholder,
    textarea::placeholder {
        color: transparent;
    }
}

/* Responsive Overrides */
@media (max-width: 1200px) {
    .invoice-workspace {
        flex-direction: column;
        align-items: center;
        padding: 20px;
    }
    .page-paper {
        width: 100% !important;
        padding: 40px;
    }
    .invoice-sidebar {
        width: 100%;
        max-width: 800px;
    }
}

@media (max-width: 600px) {
    .page-paper {
        padding: 20px;
    }
    .invoice-header {
        flex-direction: column;
        gap: 20px;
    }
    .invoice-title-block {
        text-align: left;
    }
    .meta-row {
        justify-content: flex-start;
    }
    .totals-section {
        width: 100%;
    }
    .notes-section {
        max-width: 100%;
    }
}
