/* ════════════════════════════════════════════════════════════════════════════
   Zeroo Cloud Forms Web Viewer — Design Tokens & Styles
   Ultra-lightweight (< 15 KB), Zero Dependencies, Fully Responsive
   ════════════════════════════════════════════════════════════════════════════ */

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --primary-border: #c7d2fe;
    
    --success: #10b981;
    --success-light: #ecfdf5;
    --success-border: #a7f3d0;
    
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --warning-border: #fde68a;
    
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --danger-border: #fecaca;
    
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --border-color: #e2e8f0;
    --border-focus: #818cf8;
    
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-page);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ─── Header ───────────────────────────────────────────────────────────── */
.app-header {
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.header-container {
    max-width: 860px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon {
    width: 28px;
    height: 28px;
    color: var(--primary);
}

.brand-text {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-name {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: #1e1b4b;
}

.brand-dot {
    color: var(--primary);
}

.brand-badge {
    font-size: 0.72rem;
    font-weight: 600;
    background: var(--primary-light);
    color: var(--primary);
    padding: 2px 8px;
    border-radius: 12px;
    border: 1px solid var(--primary-border);
}

.header-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--success);
    box-shadow: 0 0 0 2px var(--success-light);
}

/* ─── Main Container ───────────────────────────────────────────────────── */
.main-container {
    flex: 1;
    max-width: 860px;
    width: 100%;
    margin: 24px auto;
    padding: 0 16px;
}

/* ─── Banners ──────────────────────────────────────────────────────────── */
.alert-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    animation: fadeIn 0.3s ease;
}

.alert-demo {
    background-color: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.alert-demo strong {
    color: #14532d;
}

.alert-error {
    background-color: var(--danger-light);
    border: 1px solid var(--danger-border);
    color: #991b1b;
}

.alert-icon {
    font-size: 1.4rem;
    flex-shrink: 0;
}

.alert-content {
    flex: 1;
    font-size: 0.88rem;
}

.alert-content p {
    margin-top: 2px;
    color: inherit;
    opacity: 0.9;
}

.btn-demo-toggle {
    background: #ffffff;
    border: 1px solid #86efac;
    color: #166534;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-demo-toggle:hover {
    background: #dcfce7;
}

/* ─── Form Card ────────────────────────────────────────────────────────── */
.form-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 32px;
    margin-bottom: 30px;
    transition: all 0.2s ease;
}

.form-card-header {
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.form-ticket-badge {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-light);
    border: 1px solid var(--primary-border);
    padding: 3px 10px;
    border-radius: 20px;
    margin-bottom: 10px;
}

.form-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.02em;
    margin-bottom: 6px;
}

.form-instruction {
    font-size: 0.95rem;
    color: var(--text-muted);
}

/* ─── Fields Grid & Form Controls ──────────────────────────────────────── */
.fields-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.col-span-2 {
    grid-column: span 2;
}

.form-label {
    font-size: 0.88rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.required-star {
    color: var(--danger);
    font-weight: bold;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.92rem;
    font-family: inherit;
    color: var(--text-main);
    background-color: #ffffff;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-control.is-invalid {
    border-color: var(--danger);
    background-color: #fff8f8;
}

.form-control.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 36px;
}

.form-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #334155;
    user-select: none;
}

.form-checkbox {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    accent-color: var(--primary);
    cursor: pointer;
}

.field-error-msg {
    font-size: 0.78rem;
    color: var(--danger);
    margin-top: 4px;
    display: none;
}

.field-error-msg.show {
    display: block;
}

/* ─── Form Actions & Buttons ───────────────────────────────────────────── */
.form-actions {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 11px 24px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-primary {
    background-color: var(--primary);
    color: #ffffff;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.25);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 8px rgba(79, 70, 229, 0.35);
    transform: translateY(-1px);
}

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

.btn-secondary {
    background-color: #f1f5f9;
    color: #334155;
    border-color: #cbd5e1;
}

.btn-secondary:hover {
    background-color: #e2e8f0;
}

.btn-outline {
    background: transparent;
    border-color: #cbd5e1;
    color: #475569;
}

.btn-outline:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.82rem;
}

/* ─── Success Screen ───────────────────────────────────────────────────── */
.success-card {
    text-align: center;
    padding: 40px 32px;
}

.success-icon-wrapper {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background-color: var(--success-light);
    border: 2px solid var(--success-border);
    color: var(--success);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 18px auto;
}

.success-icon {
    width: 34px;
    height: 34px;
}

.success-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: #065f46;
    margin-bottom: 8px;
}

.success-description {
    font-size: 0.95rem;
    color: var(--text-muted);
    max-width: 580px;
    margin: 0 auto 24px auto;
}

.success-details-box {
    background-color: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px;
    text-align: left;
    margin-bottom: 24px;
}

.details-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: #334155;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.badge-ticket {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    background: #e2e8f0;
    color: #1e293b;
    padding: 2px 8px;
    border-radius: 4px;
}

.summary-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.86rem;
    padding: 4px 0;
    border-bottom: 1px dashed #e2e8f0;
}

.summary-key {
    color: var(--text-muted);
    font-weight: 500;
}

.summary-val {
    color: var(--text-main);
    font-weight: 600;
    text-align: right;
}

/* ─── PoC Mail-Payload Inspector ───────────────────────────────────────── */
.payload-inspector {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: 24px;
    text-align: left;
    overflow: hidden;
}

.btn-toggle-inspector {
    width: 100%;
    background: #f1f5f9;
    border: none;
    padding: 10px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #475569;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-toggle-inspector:hover {
    background: #e2e8f0;
}

.inspector-content {
    padding: 14px;
    background: #0f172a;
    color: #f8fafc;
}

.inspector-meta {
    font-size: 0.8rem;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #334155;
    color: #cbd5e1;
}

.inspector-meta code {
    color: #38bdf8;
}

.inspector-content pre {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    white-space: pre-wrap;
    word-break: break-word;
    color: #e2e8f0;
    background: #1e293b;
    padding: 10px;
    border-radius: 4px;
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 10px;
}

/* ─── Modal Overlay (Playground) ───────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 16px;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

.modal-card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.1rem;
    color: var(--text-main);
}

.btn-close-modal {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    color: var(--text-muted);
    cursor: pointer;
}

.modal-body {
    padding: 20px;
}

.code-textarea {
    width: 100%;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: #f8fafc;
    margin-top: 6px;
    margin-bottom: 12px;
}

.modal-actions {
    display: flex;
    gap: 10px;
}

.copy-url-group {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

.copy-url-group input {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: #f8fafc;
}

/* ─── Loading Spinner ──────────────────────────────────────────────────── */
.loading-spinner-container {
    grid-column: span 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(99, 102, 241, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.btn-spinner {
    width: 16px;
    height: 16px;
    border-width: 2px;
    border-color: rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ─── Footer ───────────────────────────────────────────────────────────── */
.app-footer {
    background: #ffffff;
    border-top: 1px solid var(--border-color);
    padding: 16px 20px;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: auto;
}

.footer-container {
    max-width: 860px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

/* ─── Mobile Responsiveness ────────────────────────────────────────────── */
@media (max-width: 640px) {
    .fields-grid {
        grid-template-columns: 1fr;
    }
    .form-group.col-span-2 {
        grid-column: span 1;
    }
    .form-card {
        padding: 20px 16px;
    }
    .footer-container {
        flex-direction: column;
        text-align: center;
    }
}
