/* Scoped Container variables so they do not leak to the main theme */
.fo-form-wrapper {
    --bg-color: transparent;
    --surface: #1e293b;
    --surface-border: #334155;
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --danger: #ef4444;
    --danger-hover: #f87171;
    --success: #22c55e;
    
    --radius: 16px;
    --transition: 0.3s ease;

    font-family: inherit; /* Inherit theme font or define specific */
    color: var(--text-main);
    line-height: 1.6;
    display: flex;
    justify-content: center;
    padding: 2rem 0;
}

/* Scoped resets */
.fo-form-wrapper *,
.fo-form-wrapper *::before,
.fo-form-wrapper *::after {
    box-sizing: border-box;
}

.fo-form-wrapper .app-container {
    width: 100%;
    max-width: 760px;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius);
    padding: 3rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

.fo-form-wrapper header {
    text-align: center;
    margin-bottom: 3.5rem;
}

.fo-form-wrapper header h2 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--primary-hover);
    border: none;
    padding-bottom: 0;
}

.fo-form-wrapper header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.fo-form-wrapper .form-section {
    margin-bottom: 2.5rem;
    padding-bottom: 2.5rem;
    border-bottom: 1px solid var(--surface-border);
}

.fo-form-wrapper .form-section:last-of-type {
    border-bottom: none;
    margin-bottom: 1.5rem;
}

.fo-form-wrapper .section-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.fo-form-wrapper .section-desc {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: -1rem;
    margin-bottom: 1.5rem;
}

.fo-form-wrapper .input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.fo-form-wrapper .input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.fo-form-wrapper .input-grid .input-group {
    margin-bottom: 0;
}

.fo-form-wrapper label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
}

.fo-form-wrapper input, 
.fo-form-wrapper select, 
.fo-form-wrapper textarea {
    width: 100%;
    padding: 0.875rem 1.25rem;
    background: #0f172a;
    border: 1px solid var(--surface-border);
    border-radius: 10px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
}

.fo-form-wrapper input:focus, 
.fo-form-wrapper select:focus, 
.fo-form-wrapper textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
    background: #0f172a;
}

.fo-form-wrapper input::placeholder, 
.fo-form-wrapper textarea::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.fo-form-wrapper .item-row {
    display: grid;
    grid-template-columns: 1fr 120px auto;
    gap: 1.25rem;
    align-items: end;
    margin-bottom: 1rem;
    padding: 1.25rem;
    background: #0f172a;
    border-radius: 12px;
    border: 1px solid var(--surface-border);
    transition: var(--transition);
}

.fo-form-wrapper .item-row .input-group {
    margin-bottom: 0;
}

.fo-form-wrapper .btn-icon {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 10px;
    color: var(--danger);
    cursor: pointer;
    transition: var(--transition);
}

.fo-form-wrapper .btn-icon:not(:disabled):hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--danger);
}

.fo-form-wrapper .btn-icon:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    border-color: var(--surface-border);
    color: var(--text-muted);
}

.fo-form-wrapper .btn-secondary {
    background: transparent;
    color: var(--primary);
    border: 1px dashed var(--primary);
    padding: 1rem 1.5rem;
    border-radius: 10px;
    font-weight: 500;
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
    margin-top: 0.5rem;
}

.fo-form-wrapper .btn-secondary:hover {
    background: rgba(59, 130, 246, 0.1);
}

.fo-form-wrapper .form-actions {
    margin-top: 3rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.fo-form-wrapper .btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 1.25rem;
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.fo-form-wrapper .btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.fo-form-wrapper .btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Loader */
.fo-form-wrapper .loader {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: fo-spin 1s cubic-bezier(0.5, 0.1, 0.5, 0.9) infinite;
    position: absolute;
}

.fo-form-wrapper .hidden {
    display: none !important;
}

@keyframes fo-spin {
    100% { transform: rotate(360deg); }
}

.fo-form-wrapper .status-message {
    padding: 1.25rem;
    border-radius: 12px;
    text-align: center;
    font-weight: 500;
    display: none;
}

.fo-form-wrapper .status-message.success {
    display: block;
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.fo-form-wrapper .status-message.error {
    display: block;
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Responsive */
@media (max-width: 640px) {
    .fo-form-wrapper .app-container {
        padding: 2rem 1.5rem;
    }
    .fo-form-wrapper .input-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }
    .fo-form-wrapper .input-grid .input-group {
        margin-bottom: 1.5rem;
    }
    .fo-form-wrapper .item-row {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 1rem;
    }
    .fo-form-wrapper .item-row .btn-icon {
        width: 100%;
        margin-top: 0.5rem;
    }
}

/* Modal Styles */
.fo-form-wrapper .fo-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}
.fo-form-wrapper .fo-modal.active {
    opacity: 1;
    visibility: visible;
}
.fo-form-wrapper .fo-modal-content {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
}
.fo-form-wrapper .fo-modal.active .fo-modal-content {
    transform: scale(1);
}
.fo-form-wrapper .fo-modal-icon {
    width: 80px; height: 80px;
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
}
.fo-form-wrapper .fo-modal-icon svg {
    width: 40px; height: 40px;
}
.fo-form-wrapper .fo-modal h3 {
    color: var(--text-main);
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    border-bottom: none;
    padding-bottom: 0;
}
.fo-form-wrapper .fo-modal p {
    color: var(--text-muted);
    margin-bottom: 2rem;
}
