/* =============================================
   Invoice Generator Widget — Styles
   BC Invoice Generator Plugin v1.0.0
   ============================================= */

/* ---- Variables ---- */
.bcs-invoice-generator {
    --inv-accent: #1a1a2e;
    --inv-bg: #ffffff;
    --inv-border: #e2e8f0;
    --inv-text: #1e293b;
    --inv-text-light: #64748b;
    --inv-success: #059669;
    --inv-success-light: #d1fae5;
    --inv-warning: #d97706;
    --inv-danger: #dc2626;
    --inv-radius: 12px;
    --inv-radius-sm: 8px;
    --inv-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --inv-shadow-lg: 0 10px 25px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.04);
    --inv-transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);

    font-family: 'Plus Jakarta Sans', 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: var(--inv-text);
    line-height: 1.6;
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* ---- Form Section ---- */
.inv-form-section {
    background: var(--inv-bg);
    border-radius: var(--inv-radius);
    box-shadow: var(--inv-shadow-lg);
    overflow: hidden;
    border: 1px solid var(--inv-border);
}

.inv-form-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 24px 28px;
    background: linear-gradient(135deg, var(--inv-accent), #2d2d5e);
    color: #fff;
}

.inv-form-icon {
    width: 48px;
    height: 48px;
    background: rgba(255,255,255,0.15);
    border-radius: var(--inv-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    backdrop-filter: blur(8px);
}

.inv-form-icon svg {
    color: #fff;
}

.inv-form-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.02em;
}

.inv-form-subtitle {
    font-size: 0.85rem;
    opacity: 0.8;
    margin: 2px 0 0;
}

/* ---- Parse Section ---- */
.inv-parse-section {
    padding: 20px 28px;
    background: #f8fafc;
    border-bottom: 1px solid var(--inv-border);
}

.inv-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--inv-text-light);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
}

.inv-label svg {
    flex-shrink: 0;
}

.inv-textarea,
.inv-input,
.inv-select {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--inv-border);
    border-radius: var(--inv-radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--inv-text);
    background: #fff;
    transition: var(--inv-transition);
    outline: none;
}

.inv-textarea:focus,
.inv-input:focus,
.inv-select:focus {
    border-color: var(--inv-accent);
    box-shadow: 0 0 0 3px rgba(26, 26, 46, 0.1);
}

.inv-textarea::placeholder,
.inv-input::placeholder {
    color: #94a3b8;
}

.inv-paste-area {
    resize: vertical;
    font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.82rem;
    line-height: 1.7;
    background: #fff;
}

/* ---- Buttons ---- */
.inv-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--inv-radius-sm);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--inv-transition);
    outline: none;
    text-decoration: none;
}

.inv-btn:hover { transform: translateY(-1px); }
.inv-btn:active { transform: translateY(0); }

.inv-btn-parse {
    margin-top: 10px;
    background: var(--inv-accent);
    color: #fff;
    width: 100%;
    justify-content: center;
}
.inv-btn-parse:hover {
    background: #2d2d5e;
    box-shadow: 0 4px 12px rgba(26, 26, 46, 0.3);
}

.inv-btn-generate {
    background: var(--inv-success);
    color: #fff;
    flex: 1;
    justify-content: center;
    padding: 12px 24px;
}
.inv-btn-generate:hover {
    background: #047857;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

.inv-btn-reset {
    background: #f1f5f9;
    color: var(--inv-text-light);
    border: 1.5px solid var(--inv-border);
}
.inv-btn-reset:hover { background: #e2e8f0; color: var(--inv-text); }

.inv-btn-download {
    background: var(--inv-accent);
    color: #fff;
}
.inv-btn-download:hover {
    background: #2d2d5e;
    box-shadow: 0 4px 12px rgba(26, 26, 46, 0.3);
}

.inv-btn-back {
    background: #f1f5f9;
    color: var(--inv-text-light);
    border: 1.5px solid var(--inv-border);
}
.inv-btn-back:hover { background: #e2e8f0; color: var(--inv-text); }

/* ---- Divider ---- */
.inv-divider {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 28px;
    margin: 0;
}
.inv-divider::before,
.inv-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--inv-border);
}
.inv-divider span {
    font-size: 0.78rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

/* ---- Form Layout ---- */
.inv-form { padding: 20px 28px 28px; }

.inv-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.inv-field { display: flex; flex-direction: column; }
.inv-field-full { grid-column: 1 / -1; }

/* ---- Input Groups ---- */
.inv-input-group {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px dashed var(--inv-border);
}
.inv-input-group:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.inv-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0 0 16px;
    color: var(--inv-text);
    flex-wrap: wrap;
}
.inv-section-title svg {
    color: var(--inv-accent);
    flex-shrink: 0;
}

/* ---- INPUT / AUTO Badges ---- */
.inv-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.6rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    line-height: 1.4;
    white-space: nowrap;
}
.inv-badge-input {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}
.inv-badge-auto {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

/* ---- Input Highlight (red left-border for INPUT fields) ---- */
.inv-input-highlight { border-left: 3px solid #dc2626; }
.inv-input-highlight:focus { border-left-color: #dc2626; }

/* ---- Input Dot Indicator ---- */
.inv-input-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #dc2626;
    border-radius: 50%;
    vertical-align: middle;
    margin-left: 2px;
}

/* ---- Help Text ---- */
.inv-help-text {
    font-size: 0.78rem;
    color: #94a3b8;
    margin: -8px 0 16px;
    line-height: 1.5;
}

/* ---- Live Calculation Preview ---- */
.inv-calc-preview {
    margin-top: 20px;
    background: #f8fafc;
    border: 1px solid var(--inv-border);
    border-radius: var(--inv-radius-sm);
    overflow: hidden;
}
.inv-calc-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--inv-border);
}
.inv-calc-row:last-child { border-bottom: none; }
.inv-calc-row span:first-child { color: var(--inv-text-light); font-weight: 500; }
.inv-calc-value { font-weight: 700; color: var(--inv-text); font-variant-numeric: tabular-nums; }
.inv-calc-row-remaining { background: #fef2f2; }
.inv-calc-remaining { color: var(--inv-danger) !important; font-size: 1rem; }

/* ---- Actions ---- */
.inv-actions { display: flex; gap: 12px; margin-top: 28px; }

/* ---- Preview Section ---- */
.inv-preview-section { margin-top: 32px; }

.inv-preview-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--inv-accent);
    border-radius: var(--inv-radius) var(--inv-radius) 0 0;
    color: #fff;
}
.inv-preview-toolbar-title { font-size: 1rem; font-weight: 700; margin: 0; }
.inv-preview-toolbar-actions { display: flex; gap: 8px; }

.inv-document-wrapper {
    background: #e2e8f0;
    padding: 32px;
    border-radius: 0 0 var(--inv-radius) var(--inv-radius);
    overflow-x: auto;
}

/* ---- Invoice Document (PDF-like) ---- */
.inv-document {
    background: #fff;
    width: 100%;
    margin: 0 auto;
    padding: 28px 32px;
    box-sizing: border-box;
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
    font-size: 10pt;
    color: #000;
    line-height: 1.4;
    font-family: 'Plus Jakarta Sans', 'Segoe UI', Arial, sans-serif;
}

.inv-doc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #999;
}
.inv-doc-logo { max-height: 44px; width: auto; object-fit: contain; }
.inv-doc-logo-text { font-size: 18pt; font-weight: 800; color: #000; letter-spacing: -0.02em; }
.inv-doc-header-right { text-align: right; }
.inv-doc-invoice-title { font-size: 20pt; font-weight: 800; color: #000; margin: 0; letter-spacing: 0.05em; }
.inv-doc-invoice-date { font-size: 9pt; color: #333; margin: 2px 0 0; }

/* ---- Parties ---- */
.inv-doc-parties { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 16px; }
.inv-doc-from, .inv-doc-to { flex: 1; }
.inv-doc-party-label { font-size: 8pt; font-weight: 700; color: #555; margin: 0 0 1px; }
.inv-doc-party-name { font-size: 11pt; font-weight: 800; color: #000; margin: 0 0 2px; }
.inv-doc-party-detail { font-size: 8.5pt; color: #333; margin: 0; line-height: 1.4; }

/* ---- Description ---- */
.inv-doc-description { font-size: 9pt; color: #000; margin: 0 0 10px; font-weight: 700; }

/* ---- Services Table ---- */
.inv-doc-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
    font-size: 9pt;
    table-layout: fixed; /* Force table to respect container width */
    word-wrap: break-word;
}
.inv-doc-table thead th {
    background: #f0f0f0;
    border: 1px solid #ccc;
    padding: 8px 4px;
    text-align: center;
    font-weight: 700;
    font-size: 7.5pt;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: #000;
}
.inv-doc-table tbody td {
    border: 1px solid #ccc;
    padding: 10px 6px;
    text-align: center;
    vertical-align: top;
}
.inv-doc-table tbody td:first-child { text-align: left; }
.inv-doc-table tfoot td { border: 1px solid #ccc; padding: 8px 6px; font-size: 9pt; }

/* Column Widths (total 100%) */
.inv-doc-table th:nth-child(1), .inv-doc-table td:nth-child(1) { width: 30%; } /* Service Description */
.inv-doc-table th:nth-child(2), .inv-doc-table td:nth-child(2) { width: 16%; } /* Normal Price */
.inv-doc-table th:nth-child(3), .inv-doc-table td:nth-child(3) { width: 12%; } /* Promo Discount */
.inv-doc-table th:nth-child(4), .inv-doc-table td:nth-child(4) { width: 8%; }  /* Qty */
.inv-doc-table th:nth-child(5), .inv-doc-table td:nth-child(5) { width: 17%; } /* Price */
.inv-doc-table th:nth-child(6), .inv-doc-table td:nth-child(6) { width: 17%; } /* Total */
.inv-doc-summary-label { text-align: right !important; font-weight: 600; }
.inv-doc-summary-total, .inv-doc-summary-dp, .inv-doc-summary-full, .inv-doc-summary-remaining-val { text-align: right !important; font-weight: 700; }
.inv-doc-summary-blank { background: #f0f0f0; }
.inv-doc-summary-remaining td { background: #fff; }
.inv-doc-summary-remaining .inv-doc-summary-label { font-weight: 800; }
.inv-doc-summary-remaining .inv-doc-summary-remaining-val { color: #000; font-size: 11pt; }

/* ---- Bank Details ---- */
.inv-doc-bank { margin-top: 18px; padding-top: 0; }
.inv-doc-bank-title { font-size: 9pt; font-weight: 800; color: #000; margin: 0 0 6px; letter-spacing: 0.03em; }
.inv-doc-bank-table { font-size: 8.5pt; border-collapse: collapse; }
.inv-doc-bank-table td { padding: 3px 10px 3px 0; color: #333; }
.inv-doc-bank-table td:first-child { font-weight: 400; color: #555; min-width: 180px; }
.inv-doc-bank-value { font-weight: 800; color: #000; }

/* ---- Footer Notes ---- */
.inv-doc-notes { margin-top: 28px; text-align: center; }
.inv-doc-notes-line { font-size: 8.5pt; color: #555; margin: 0 0 6px; font-style: normal; }
.inv-doc-notes-thanks { font-size: 9pt; font-weight: 700; color: #000; margin: 0; letter-spacing: 0.04em; }

/* ---- Animations ---- */
@keyframes invSlideIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.inv-preview-section { animation: invSlideIn 0.4s ease-out; }

/* ---- Toast ---- */
.inv-toast {
    position: fixed; bottom: 24px; right: 24px;
    background: var(--inv-accent); color: #fff;
    padding: 12px 20px; border-radius: var(--inv-radius-sm);
    font-size: 0.88rem; font-weight: 600;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    z-index: 99999;
    animation: invToastIn 0.3s ease-out, invToastOut 0.3s ease-in 2.5s forwards;
    font-family: 'Plus Jakarta Sans', 'Segoe UI', sans-serif;
}
.inv-toast.inv-toast-success { background: var(--inv-success); }
.inv-toast.inv-toast-error { background: var(--inv-danger); }
@keyframes invToastIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes invToastOut { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(16px); } }

/* ---- Responsive ---- */
@media screen and (max-width: 768px) {
    .bcs-invoice-generator { padding: 12px 8px; }
    .inv-form-header { padding: 16px 20px; }
    .inv-parse-section { padding: 16px 20px; }
    .inv-form { padding: 16px 20px 20px; }
    .inv-form-grid { grid-template-columns: 1fr; }
    .inv-actions { flex-direction: column; }
    .inv-preview-toolbar { flex-direction: column; gap: 12px; align-items: flex-start; }
    .inv-preview-toolbar-actions { width: 100%; }
    .inv-preview-toolbar-actions .inv-btn { flex: 1; justify-content: center; }
    .inv-document-wrapper { padding: 12px; }
    .inv-document { min-height: auto; padding: 20px 16px; font-size: 9pt; }
    .inv-doc-header { flex-direction: column; gap: 12px; }
    .inv-doc-header-right { text-align: left; }
    .inv-doc-parties { flex-direction: column; gap: 16px; }
    .inv-doc-table { font-size: 8pt; }
    .inv-doc-table thead th { font-size: 7pt; padding: 6px 4px; }
    .inv-doc-table tbody td, .inv-doc-table tfoot td { padding: 6px 4px; font-size: 8pt; }
}

/* ---- Print ---- */
@media print {
    .inv-form-section, .inv-preview-toolbar { display: none !important; }
    .inv-preview-section { margin: 0 !important; display: block !important; }
    .inv-document-wrapper { background: none; padding: 0; border-radius: 0; }
    .inv-document { box-shadow: none; padding: 0; width: 100%; }
}
