/* Smart Invoice Generator Pro - Frontend Styles */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    --sigp-primary: #7030A0;
    --sigp-primary-hover: #5c2785;
    --sigp-primary-light: #f5f0fa;
    --sigp-primary-light-hover: #ebe0f5;
    --sigp-secondary: #F2A900;
    --sigp-secondary-hover: #d19200;
    --sigp-success: #10b981;
    --sigp-success-light: #ecfdf5;
    --sigp-danger: #ef4444;
    --sigp-danger-hover: #dc2626;
    --sigp-danger-light: #fef2f2;
    
    /* Neutrals */
    --sigp-neutral-50: #f8fafc;
    --sigp-neutral-100: #f1f5f9;
    --sigp-neutral-200: #e2e8f0;
    --sigp-neutral-300: #cbd5e1;
    --sigp-neutral-400: #94a3b8;
    --sigp-neutral-500: #64748b;
    --sigp-neutral-600: #475569;
    --sigp-neutral-700: #334155;
    --sigp-neutral-800: #1e293b;
    --sigp-neutral-900: #0f172a;

    /* Shadows */
    --sigp-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --sigp-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --sigp-shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.03);
    --sigp-shadow-premium: 0 20px 40px -15px rgba(112, 48, 160, 0.08), 0 15px 30px -10px rgba(0, 0, 0, 0.04);
}

.sigp-wrapper {
    font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--sigp-neutral-800);
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    box-sizing: border-box;
    width: 100%;
}

.sigp-wrapper * {
    box-sizing: border-box;
}

.sigp-container {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 0;
}

/* Sidebar */
.sigp-sidebar {
    flex: 1 1 320px;
    padding: 10px 10px 20px 10px;
}

.sigp-sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.sigp-brand-badge {
    background: linear-gradient(135deg, var(--sigp-primary), #9d50bb);
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 6px;
    letter-spacing: 1px;
    box-shadow: 0 2px 8px rgba(112, 48, 160, 0.3);
}

.sigp-headline {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--sigp-neutral-900);
    margin: 0;
    line-height: 1.15;
    background: linear-gradient(to right, var(--sigp-neutral-900), var(--sigp-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sigp-description {
    font-size: 1.05rem;
    color: var(--sigp-neutral-500);
    margin-top: 15px;
    margin-bottom: 30px;
    line-height: 1.6;
}

.sigp-sidebar-features {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.sigp-feature-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--sigp-neutral-700);
}

.sigp-feature-icon {
    width: 20px;
    height: 20px;
    color: var(--sigp-primary);
    flex-shrink: 0;
}

.sigp-sidebar-footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--sigp-neutral-200);
}

.sigp-secure-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--sigp-neutral-400);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sigp-secure-badge svg {
    color: var(--sigp-neutral-400);
}

/* Form Card */
.sigp-form-card {
    width: 100%;
    background: #ffffff;
    padding: 40px;
    border-radius: 20px;
    box-shadow: var(--sigp-shadow-premium);
    border: 1px solid rgba(255, 255, 255, 0.8);
    position: relative;
    overflow: hidden;
}

.sigp-form-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: linear-gradient(to right, var(--sigp-primary), var(--sigp-secondary));
}

.sigp-section-header {
    margin-bottom: 25px;
    margin-top: 10px;
}

.sigp-section-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--sigp-neutral-900);
    margin: 0 0 4px 0;
}

.sigp-section-subtitle {
    font-size: 0.9rem;
    color: var(--sigp-neutral-500);
    margin: 0;
}

.sigp-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.sigp-col {
    flex: 1;
    min-width: 0;
}

.sigp-col-full {
    flex: 1 1 100%;
}

label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--sigp-neutral-700);
    margin-bottom: 8px;
    letter-spacing: 0.3px;
}

.sigp-required {
    color: var(--sigp-danger);
    margin-left: 2px;
}

/* Form Controls */
html body .sigp-wrapper input[type="text"],
html body .sigp-wrapper input[type="email"],
html body .sigp-wrapper input[type="number"],
html body .sigp-wrapper input[type="date"],
html body .sigp-wrapper textarea,
html body .sigp-wrapper select {
    width: 100% !important;
    padding: 12px 10px !important;
    border: 1.5px solid var(--sigp-neutral-200) !important;
    border-radius: 10px !important;
    font-size: 0.95rem !important;
    color: var(--sigp-neutral-800) !important;
    background: var(--sigp-neutral-50) !important;
    transition: var(--sigp-transition-all) !important;
    font-family: inherit !important;
    outline: none !important;
    line-height: 1.5 !important;
    box-sizing: border-box !important;
}

html body .sigp-wrapper input[type="text"],
html body .sigp-wrapper input[type="email"],
html body .sigp-wrapper input[type="number"],
html body .sigp-wrapper input[type="date"],
html body .sigp-wrapper select {
    height: 48px !important;
}

.sigp-wrapper input:focus,
.sigp-wrapper textarea:focus,
.sigp-wrapper select:focus {
    border-color: var(--sigp-primary);
    box-shadow: 0 0 0 4px rgba(112, 48, 160, 0.12);
    background: #ffffff;
}

/* Custom Select Styling */
.sigp-wrapper select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
    padding-right: 40px;
}

/* Solve Appended Select Field Not Showing:
   If select is NOT initialized by custom library (e.g. select2-hidden-accessible), force it to show!
*/
html body .sigp-wrapper select:not(.select2-hidden-accessible):not(.selectized):not(.choices__input) {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: 48px !important;
    box-sizing: border-box !important;
}

.sigp-wrapper textarea {
    resize: vertical;
}

/* Service Item Row */
.sigp-item-row {
    background: #ffffff;
    border: 1px solid var(--sigp-neutral-200);
    border-radius: 12px;
    margin-bottom: 16px;
    padding: 16px;
    transition: var(--sigp-transition-all);
}

.sigp-item-row:hover {
    border-color: var(--sigp-neutral-300);
    box-shadow: var(--sigp-shadow-md);
}

.sigp-item-top {
    display: flex;
    gap: 15px;
    align-items: flex-end;
    margin-bottom: 12px;
}

.sigp-item-field-name {
    flex: 2;
    min-width: 120px;
}

.sigp-item-field-price {
    width: 130px;
}

.sigp-item-field-qty {
    width: 90px;
}

/* Improve input/select appearance inside service rows */
.sigp-item-field-name .sigp-item-name,
.sigp-item-field-price input,
.sigp-item-field-qty input {
    height: 44px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--sigp-neutral-200);
    background: #fff;
    box-sizing: border-box;
}

.sigp-item-field-name .sigp-item-name {
    width: 100%;
}

/* Make price/qty visually consistent (desktop) */
.sigp-item-field-price { width: 140px; }
.sigp-item-field-qty { width: 90px; }

.sigp-item-total-wrapper {
    width: 140px;
    text-align: right;
    padding-bottom: 12px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--sigp-neutral-900);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    height: 100%;
}

.sigp-mini-curr {
    font-size: 0.75rem;
    color: var(--sigp-neutral-400);
    font-weight: 600;
}

.sigp-remove-item {
    background: var(--sigp-danger-light);
    color: var(--sigp-danger);
    border: 1px solid transparent;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--sigp-transition-all);
    padding: 0;
    margin-bottom: 3px;
    flex-shrink: 0;
}

.sigp-remove-item:hover {
    background: var(--sigp-danger);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

.sigp-remove-item svg {
    width: 16px;
    height: 16px;
}

.sigp-item-bottom {
    display: block;
}

.sigp-item-desc {
    margin: 0;
    height: 48px;
    font-size: 0.9rem !important;
}

html body .sigp-wrapper .sigp-mobile-label {
    display: none !important;
}

/* Step tracker */
.sigp-progress-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--sigp-neutral-200);
}

.sigp-progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
}

.sigp-step-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--sigp-neutral-100);
    border: 2px solid var(--sigp-neutral-200);
    color: var(--sigp-neutral-400);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    transition: var(--sigp-transition-all);
    position: relative;
    overflow: hidden !important;
}

.sigp-step-check {
    display: none !important;
    width: 16px !important;
    height: 16px !important;
    stroke: #ffffff !important;
    fill: none !important;
    stroke-width: 3.5 !important;
}

.sigp-step-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--sigp-neutral-400);
    transition: var(--sigp-transition-all);
    white-space: nowrap;
}

.sigp-progress-line {
    flex: 1;
    height: 2px;
    background-color: var(--sigp-neutral-200);
    margin: 0 15px;
    margin-top: -24px;
    border-radius: 2px;
    transition: var(--sigp-transition-all);
}

/* Active & Completed States */
.sigp-progress-step.active .sigp-step-circle {
    background-color: var(--sigp-primary);
    border-color: var(--sigp-primary);
    color: #ffffff;
    box-shadow: 0 0 0 4px rgba(112, 48, 160, 0.2);
}

.sigp-progress-step.active .sigp-step-label {
    color: var(--sigp-primary);
}

.sigp-progress-step.completed .sigp-step-circle {
    background-color: var(--sigp-success);
    border-color: var(--sigp-success);
    color: #ffffff;
}

.sigp-progress-step.completed .sigp-step-num {
    display: none !important;
}

.sigp-progress-step.completed .sigp-step-check {
    display: block !important;
}

.sigp-progress-step.completed .sigp-step-label {
    color: var(--sigp-success);
}

.sigp-progress-line.completed {
    background-color: var(--sigp-success);
}

/* Form Steps Panel */
.sigp-form-step {
    display: none;
}

.sigp-form-step.active {
    display: block;
    animation: sigpFadeSlide 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Buttons */
.sigp-btn-primary,
.sigp-btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--sigp-transition-all);
    border: none;
    font-family: inherit;
    line-height: 1.5;
}

.sigp-btn-primary {
    background: var(--sigp-primary);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(112, 48, 160, 0.2);
}

.sigp-btn-primary:hover {
    background: var(--sigp-primary-hover);
    box-shadow: 0 6px 20px rgba(112, 48, 160, 0.3);
    transform: translateY(-1px);
}

.sigp-btn-primary:active {
    transform: translateY(0);
}

.sigp-btn-secondary {
    background: #ffffff;
    color: var(--sigp-neutral-700);
    border: 1.5px solid var(--sigp-neutral-200);
}

.sigp-btn-secondary:hover {
    background: var(--sigp-neutral-50);
    color: var(--sigp-neutral-900);
    border-color: var(--sigp-neutral-300);
}

.sigp-btn-add {
    width: 100%;
    border-style: dashed;
    border-width: 2px;
    background: var(--sigp-neutral-50);
    color: var(--sigp-primary);
    border-color: rgba(112, 48, 160, 0.3);
    padding: 14px;
    margin-bottom: 25px;
}

.sigp-btn-add:hover {
    background: var(--sigp-primary-light);
    border-color: var(--sigp-primary);
    color: var(--sigp-primary-hover);
}

.sigp-btn-icon {
    flex-shrink: 0;
}

.sigp-step-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    padding-top: 25px;
    border-top: 1px solid var(--sigp-neutral-200);
}

.sigp-step-actions > .sigp-btn-primary:only-child {
    margin-left: auto;
}

/* Totals Section */
.sigp-totals-section {
    background: var(--sigp-neutral-50);
    border: 1px dashed var(--sigp-neutral-300);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 30px;
    margin-top: 25px;
}

.sigp-totals-grid {
    display: flex;
    gap: 30px;
}

.sigp-totals-col {
    flex: 1;
}

.sigp-advance-col {
    display: flex;
    align-items: center;
}

.sigp-card-input {
    width: 100%;
}

.sigp-currency-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.sigp-currency-input-wrapper input {
    padding-right: 60px !important;
}

html body .sigp-wrapper .sigp-currency-suffix {
    position: absolute !important;
    right: 16px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    display: inline-block !important;
    font-size: 0.85rem !important;
    font-weight: 700 !important;
    color: var(--sigp-neutral-400) !important;
    pointer-events: none !important;
    z-index: 5 !important;
}

.sigp-receipt-card {
    background: #ffffff;
    border: 1px solid var(--sigp-neutral-200);
    border-radius: 12px;
    padding: 18px;
    box-shadow: var(--sigp-shadow-sm);
}

/* Totals container adjustments for layout and responsiveness */
.sigp-totals-section {
    display: flex;
    gap: 18px;
    align-items: flex-start;
}

.sigp-totals-grid {
    flex: 1 1 auto;
}

.sigp-receipt-card {
    width: 220px;
    margin-left: auto;
}

@media (max-width: 768px) {
    .sigp-totals-section { flex-direction: column; gap: 12px; }
    .sigp-receipt-card { width: 100%; margin-left: 0; }
}

/* Ensure service select is always visible and styled consistently */
.sigp-item-name {
    display: block !important;
    width: 100% !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    background-color: #fff !important;
}

/* If Select2 is used, make its container match our inputs */
.select2-container { width: 100% !important; }
.select2-container .select2-selection {
    height: 44px !important;
    border-radius: 10px !important;
    border: 1px solid var(--sigp-neutral-200) !important;
    box-sizing: border-box !important;
    padding: 6px 10px !important;
}

/* Tighter totals layout to avoid large empty gaps */
.sigp-totals-section {
    padding: 16px;
}
.sigp-totals-grid {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}
.sigp-advance-col {
    flex: 1 1 420px; /* allow grow but limit width */
    max-width: 520px;
}
.sigp-receipt-card {
    flex: 0 0 220px;
    margin-left: 0;
}

.sigp-receipt-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 0.95rem;
    color: var(--sigp-neutral-600);
}

.sigp-receipt-line:not(:last-child) {
    border-bottom: 1px solid var(--sigp-neutral-100);
}

.sigp-receipt-label {
    font-weight: 500;
}

.sigp-receipt-value {
    font-weight: 600;
    color: var(--sigp-neutral-800);
}

.sigp-receipt-line.sigp-grand-total {
    color: var(--sigp-primary);
    font-weight: 700;
    font-size: 1.15rem;
    border-top: 1.5px solid var(--sigp-neutral-200);
    border-bottom: 1.5px solid var(--sigp-neutral-200);
    padding: 12px 0;
    margin: 4px 0;
}

.sigp-receipt-line.sigp-grand-total .sigp-receipt-value {
    color: var(--sigp-primary);
}

.sigp-receipt-line.sigp-remaining {
    font-weight: 700;
    color: var(--sigp-neutral-800);
    padding-top: 10px;
}

.sigp-curr {
    font-size: 0.8rem;
    color: var(--sigp-neutral-400);
    font-weight: 600;
    margin-left: 2px;
}

/* Form Submit Feedback Message */
#sigp-form-message {
    margin-top: 25px;
    padding: 14px;
    border-radius: 10px;
    text-align: center;
    font-weight: 600;
    font-size: 0.95rem;
    display: none;
    animation: sigpFadeSlide 0.3s ease-out;
}

#sigp-form-message.success {
    display: block;
    background-color: var(--sigp-success-light);
    color: var(--sigp-success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

#sigp-form-message.success a {
    color: var(--sigp-success);
    text-decoration: underline;
    font-weight: 700;
    margin-left: 5px;
}

#sigp-form-message.error {
    display: block;
    background-color: var(--sigp-danger-light);
    color: var(--sigp-danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Animations */
@keyframes sigpFadeSlide {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-in {
    animation: sigpFadeSlide 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Responsive Styles */
@media (max-width: 900px) {
    .sigp-totals-grid {
        flex-direction: column;
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .sigp-container {
        flex-direction: column;
        gap: 15px;
    }

    .sigp-sidebar {
        text-align: center;
        padding-bottom: 10px;
        width: 100%;
    }

    .sigp-sidebar-header {
        justify-content: center;
    }

    .sigp-sidebar-features {
        align-items: center;
    }

    .sigp-wrapper {
        padding: 0;
    }

    .sigp-form-card {
        padding: 25px 15px;
        width: 100%;
    }

    .sigp-row {
        flex-direction: column;
        gap: 15px;
    }

    .sigp-col,
    .sigp-col-half {
        flex: 1 1 100%;
    }

    /* Stack Service Row on Mobile */
    .sigp-item-row {
        padding: 12px;
    }
    
    .sigp-item-top {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .sigp-item-field-name,
    .sigp-item-field-price,
    .sigp-item-field-qty {
        width: 100% !important;
    }

    html body .sigp-wrapper .sigp-mobile-label {
        display: block !important;
    }

    .sigp-item-top label {
        margin-bottom: 6px;
    }

    .sigp-item-total-wrapper {
        width: 100%;
        text-align: left;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        border-top: 1px solid var(--sigp-neutral-100);
        padding-top: 12px;
        padding-bottom: 0;
        margin-top: 4px;
    }

    .sigp-remove-item {
        width: 100%;
        margin-top: 8px;
        height: 44px;
    }

    .sigp-progress-container {
        margin-bottom: 30px;
    }

    .sigp-step-label {
        display: none; /* Hide labels on mobile to save space */
    }

    .sigp-progress-line {
        margin: 0 5px;
        margin-top: -8px;
    }
}