/* ============================================================
   Digital Form AI - Frontend Styles (Glassmorphism)
   ============================================================ */

.dfai-form-wrapper {
    --dfai-f-primary: #6366f1;
    --dfai-f-bg: #ffffff;
    --dfai-f-text: #1e293b;
    --dfai-f-text-secondary: #64748b;
    --dfai-f-border: #e2e8f0;
    --dfai-f-radius: 12px;
    --dfai-f-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    max-width: 720px;
    margin: 0 auto;
}

.dfai-form-wrapper *,
.dfai-display-wrapper * { box-sizing: border-box; }

/* Form Card */
.dfai-form-wrapper {
    background: var(--dfai-f-bg);
    border-radius: var(--dfai-f-radius);
    box-shadow: var(--dfai-f-shadow);
    padding: 32px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.dfai-form-header {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--dfai-f-border);
}

.dfai-form-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--dfai-f-text);
    margin: 0 0 6px;
}

.dfai-form-desc {
    font-size: 14px;
    color: var(--dfai-f-text-secondary);
    margin: 0;
    line-height: 1.5;
}

/* Fields Grid */
.dfai-fields-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 24px;
}

.dfai-field-wrap { width: 100%; }
.dfai-field-full { width: 100%; }
.dfai-field-half { width: calc(50% - 10px); }
.dfai-field-third { width: calc(33.333% - 14px); }

.dfai-field-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--dfai-f-text);
    margin-bottom: 6px;
}

.dfai-required { color: #ef4444; }

.dfai-field-input {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--dfai-f-border);
    border-radius: var(--dfai-f-radius);
    font-size: 14px;
    color: var(--dfai-f-text);
    background: var(--dfai-f-bg);
    outline: none;
    transition: all 0.3s ease;
    font-family: inherit;
}

.dfai-field-input:focus {
    border-color: var(--dfai-f-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.dfai-field-input::placeholder {
    color: #94a3b8;
}

textarea.dfai-field-input {
    resize: vertical;
    min-height: 100px;
}

select.dfai-field-input {
    cursor: pointer;
}

/* Checkbox & Radio */
.dfai-checkbox-group, .dfai-radio-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dfai-checkbox-label, .dfai-radio-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--dfai-f-text);
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.dfai-checkbox-label:hover, .dfai-radio-label:hover {
    background: rgba(99, 102, 241, 0.05);
}

.dfai-checkbox-label input, .dfai-radio-label input {
    width: 18px;
    height: 18px;
    accent-color: var(--dfai-f-primary);
    cursor: pointer;
}

/* Submit */
.dfai-form-actions {
    padding-top: 8px;
}

.dfai-submit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 32px;
    background: linear-gradient(135deg, var(--dfai-f-primary), #8b5cf6);
    color: #fff;
    border: none;
    border-radius: var(--dfai-f-radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
    width: 100%;
}

.dfai-submit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 25px rgba(99, 102, 241, 0.4);
}

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

/* Messages */
.dfai-form-message {
    margin-top: 16px;
    padding: 14px 20px;
    border-radius: var(--dfai-f-radius);
    font-size: 14px;
    font-weight: 500;
    animation: dfaiFadeIn 0.3s ease;
}

.dfai-form-message.success {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.dfai-form-message.error {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* ============================================================
   Display Types
   ============================================================ */
.dfai-display-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    max-width: 900px;
    margin: 0 auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
    padding: 32px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.dfai-display-title {
    font-size: 22px;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 24px;
}

/* Table */
.dfai-table-container {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.dfai-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.dfai-data-table th {
    background: #f8fafc;
    color: #475569;
    font-weight: 600;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}

.dfai-data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
}

.dfai-data-table tr:hover td {
    background: rgba(99, 102, 241, 0.03);
}

.dfai-empty-state {
    text-align: center;
    color: #94a3b8;
    padding: 40px 16px !important;
    font-style: italic;
}

/* Chart */
.dfai-chart-container {
    max-width: 600px;
    margin: 0 auto;
}

/* Info Cards */
.dfai-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.dfai-info-card {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(139, 92, 246, 0.05));
    border: 1px solid rgba(99, 102, 241, 0.1);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
}

.dfai-info-number {
    display: block;
    font-size: 28px;
    font-weight: 800;
    color: #6366f1;
    margin-bottom: 4px;
}

.dfai-info-label {
    display: block;
    font-size: 12px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Responsive */
@media (max-width: 640px) {
    .dfai-form-wrapper, .dfai-display-wrapper { padding: 20px; }
    .dfai-field-half, .dfai-field-third { width: 100%; }
    .dfai-info-grid { grid-template-columns: 1fr 1fr; }
}

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

/* ============================================================
   Result Modal
   ============================================================ */
.dfai-result-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    opacity: 0;
    transition: opacity 0.2s ease;
    backdrop-filter: blur(4px);
}
.dfai-result-modal-overlay.active {
    opacity: 1;
}
.dfai-result-modal {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    max-width: 680px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.95);
    transition: transform 0.2s ease;
    overflow: hidden;
}
.dfai-result-modal-overlay.active .dfai-result-modal {
    transform: scale(1);
}
.dfai-result-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e2e8f0;
}
.dfai-result-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1e293b;
}
.dfai-result-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #94a3b8;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.dfai-result-modal-close:hover {
    color: #475569;
}
.dfai-result-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}
.dfai-result-modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 16px 24px;
    border-top: 1px solid #e2e8f0;
}
.dfai-result-modal-btn {
    padding: 8px 20px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #475569;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s;
}
.dfai-result-modal-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}
.dfai-result-retry-btn {
    background: #6366f1;
    color: #fff;
    border-color: #6366f1;
}
.dfai-result-retry-btn:hover {
    background: #4f46e5;
    border-color: #4f46e5;
}

/* Result Info Grid */
.dfai-result-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}
.dfai-result-card {
    background: linear-gradient(135deg, #f8fafc 0%, #eef2ff 100%);
    border-radius: 12px;
    padding: 20px 16px;
    text-align: center;
    border: 1px solid #e0e7ff;
}
.dfai-result-value {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 6px;
    word-break: break-word;
}
.dfai-result-label {
    display: block;
    font-size: 12px;
    color: #6366f1;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.dfai-result-note {
    margin: 12px 0;
    font-size: 14px;
    color: #475569;
    line-height: 1.6;
    grid-column: 1 / -1;
}

/* Result Table */
.dfai-result-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    margin: 8px 0;
}
.dfai-result-table th {
    background: #f1f5f9;
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    color: #334155;
    border-bottom: 2px solid #e2e8f0;
}
.dfai-result-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #f1f5f9;
    color: #475569;
}
.dfai-result-table tr:hover td {
    background: #f8fafc;
}

/* Result Text */
.dfai-result-text {
    font-size: 14px;
    line-height: 1.7;
    color: #334155;
}
.dfai-result-text strong {
    color: #1e293b;
}
.dfai-result-text ul {
    padding-left: 20px;
    margin: 10px 0;
}
.dfai-result-text li {
    margin-bottom: 6px;
}

/* Result Chart */
.dfai-result-chart-wrap {
    max-width: 500px;
    margin: 16px auto;
}

@media (max-width: 640px) {
    .dfai-result-modal { width: 95%; max-height: 90vh; border-radius: 12px; }
    .dfai-result-info-grid { grid-template-columns: 1fr 1fr; }
    .dfai-result-modal-body { padding: 16px; }
}
