/* Creddo Invoice Generator — Frontend Styles */
.creddo-invoice-wrap {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #1a1a2e;
}
.creddo-invoice-wrap *, .creddo-invoice-wrap *::before, .creddo-invoice-wrap *::after {
    box-sizing: border-box;
}

/* Header */
.creddo-inv-header {
    text-align: center;
    margin-bottom: 24px;
}
.creddo-inv-header h2 {
    font-size: 24px;
    color: #1e40af;
    margin: 0 0 4px;
}
.creddo-inv-header p {
    color: #6b7280;
    font-size: 14px;
    margin: 0;
}

/* Sections */
.creddo-inv-section {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    margin-bottom: 16px;
    overflow: hidden;
}
.creddo-inv-section-header {
    background: #f0f4ff;
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    -webkit-user-select: none;
}
.creddo-inv-section-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: #1e40af;
    margin: 0;
}
.creddo-inv-section-header .toggle-icon {
    font-size: 18px;
    color: #6b7280;
    transition: transform 0.2s;
}
.creddo-inv-section-header.collapsed .toggle-icon {
    transform: rotate(-90deg);
}
.creddo-inv-section-body {
    padding: 16px;
}
.creddo-inv-section-body.hidden {
    display: none;
}

/* Form fields */
.creddo-inv-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}
.creddo-inv-field {
    display: flex;
    flex-direction: column;
}
.creddo-inv-field.full {
    grid-column: 1 / -1;
}
.creddo-inv-field label {
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.creddo-inv-field label .required {
    color: #dc2626;
}
.creddo-inv-field input,
.creddo-inv-field textarea,
.creddo-inv-field select {
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    color: #1a1a2e;
    background: #fff;
    transition: border-color 0.15s;
    width: 100%;
}
.creddo-inv-field input:focus,
.creddo-inv-field textarea:focus,
.creddo-inv-field select:focus {
    outline: none;
    border-color: #1e40af;
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}
.creddo-inv-field textarea {
    resize: vertical;
    min-height: 60px;
}

/* Line items */
.creddo-inv-line-item {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    position: relative;
}
.creddo-inv-line-item .line-number {
    position: absolute;
    top: 8px;
    left: 12px;
    font-size: 11px;
    font-weight: 700;
    color: #9ca3af;
}
.creddo-inv-line-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #fee2e2;
    color: #dc2626;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.creddo-inv-line-remove:hover {
    background: #dc2626;
    color: #fff;
}
.creddo-inv-line-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 4px;
}
.creddo-inv-line-grid-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}

/* Buttons */
.creddo-inv-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.creddo-inv-btn:active {
    transform: scale(0.97);
}
.creddo-inv-btn-primary {
    background: #1e40af;
    color: #fff;
}
.creddo-inv-btn-primary:hover {
    background: #1e3a8a;
}
.creddo-inv-btn-secondary {
    background: #c8cdd3;
    color: #fff;
}
.creddo-inv-btn-secondary:hover {
    background: #9ca3af;
}
.creddo-inv-btn-add {
    background: #ecfdf5;
    color: #059669;
    border: 1px dashed #059669;
    width: 100%;
    justify-content: center;
    margin-top: 8px;
}
.creddo-inv-btn-add:hover {
    background: #d1fae5;
}

/* Action bar — sticky on mobile */
.creddo-inv-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    padding: 16px 0;
    position: sticky;
    bottom: 0;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    z-index: 10;
}

/* Preview area */
.creddo-inv-preview-frame {
    width: 100%;
    min-height: 500px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
}

/* Totals in form */
.creddo-inv-totals {
    background: #f0f4ff;
    border-radius: 8px;
    padding: 16px;
    margin-top: 12px;
}
.creddo-inv-totals-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 14px;
}
.creddo-inv-totals-row.grand {
    font-size: 18px;
    font-weight: 700;
    color: #1e40af;
    border-top: 2px solid #1e40af;
    margin-top: 8px;
    padding-top: 10px;
}

/* Loading overlay */
.creddo-inv-loading {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    font-size: 16px;
    font-weight: 600;
    color: #1e40af;
}
.creddo-inv-loading.hidden { display: none; }

/* Responsive */
@media (max-width: 640px) {
    .creddo-inv-row {
        grid-template-columns: 1fr;
    }
    .creddo-inv-line-grid-row {
        grid-template-columns: 1fr 1fr;
    }
    .creddo-inv-header h2 {
        font-size: 20px;
    }
    .creddo-inv-actions {
        flex-direction: column;
    }
    .creddo-inv-actions .creddo-inv-btn {
        width: 100%;
        justify-content: center;
    }
}
