/**
 * Mood Form Loader - Frontend Styles
 * Reuses CSS variables from Mood Client Portal dashboard.css
 */

.mfl-form-container {
    font-family: var(--mcp-font, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif);
    color: var(--mcp-text, #172B4D);
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 0;
}

.mfl-form-container * {
    box-sizing: border-box;
}

/* Header */
.mfl-header {
    margin-bottom: 16px;
}

.mfl-title {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 4px;
    color: var(--mcp-text, #172B4D);
}

/* Filters */
.mfl-filters {
    margin-bottom: 20px;
}

.mfl-filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.mfl-filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 200px;
    flex: 1;
    max-width: 320px;
}

.mfl-filter-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--mcp-text-light, #5E6C84);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Searchable dropdown wrapper */
.mfl-dropdown-wrapper {
    position: relative;
}

.mfl-dropdown-search {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--mcp-border, #DFE1E6);
    border-radius: var(--mcp-radius, 8px);
    font-size: 14px;
    color: var(--mcp-text, #172B4D);
    background: var(--mcp-card-bg, #FFFFFF);
    outline: none;
    transition: border-color 0.2s;
}

.mfl-dropdown-search:focus {
    border-color: var(--mcp-secondary, #0052CC);
    box-shadow: 0 0 0 2px rgba(0, 82, 204, 0.15);
}

.mfl-dropdown-search::placeholder {
    color: var(--mcp-neutral, #6B778C);
}

.mfl-dropdown-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 240px;
    overflow-y: auto;
    background: var(--mcp-card-bg, #FFFFFF);
    border: 1px solid var(--mcp-border, #DFE1E6);
    border-top: none;
    border-radius: 0 0 var(--mcp-radius, 8px) var(--mcp-radius, 8px);
    box-shadow: var(--mcp-shadow, 0 1px 3px rgba(0,0,0,0.1));
    z-index: 100;
    display: none;
}

.mfl-dropdown-list.mfl-open {
    display: block;
}

.mfl-dropdown-option {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid #f0f0f0;
}

.mfl-dropdown-option:last-child {
    border-bottom: none;
}

.mfl-dropdown-option:hover,
.mfl-dropdown-option.mfl-highlighted {
    background: var(--mcp-primary-light, #E3FCEF);
}

.mfl-dropdown-option.mfl-selected {
    background: var(--mcp-primary-light, #E3FCEF);
    font-weight: 600;
}

.mfl-no-results {
    padding: 8px 12px;
    color: var(--mcp-neutral, #6B778C);
    font-style: italic;
    font-size: 14px;
}

/* Loading & messages */
.mfl-loading-filters,
.mfl-iframe-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    color: var(--mcp-text-light, #5E6C84);
    font-size: 14px;
}

.mfl-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--mcp-border, #DFE1E6);
    border-top-color: var(--mcp-primary, #00875A);
    border-radius: 50%;
    animation: mfl-spin 0.6s linear infinite;
}

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

.mfl-filter-message {
    padding: 10px 14px;
    border-radius: var(--mcp-radius, 8px);
    font-size: 14px;
    margin-top: 8px;
}

.mfl-filter-message.mfl-info {
    background: #e8f4fd;
    color: #0052CC;
}

.mfl-filter-message.mfl-warning {
    background: #fff8e6;
    color: #FF991F;
}

.mfl-filter-message.mfl-error-msg {
    background: #fcf0f1;
    color: #DE350B;
}

/* Launch button (new tab mode) */
.mfl-launch-wrapper {
    margin-top: 16px;
    text-align: center;
}

.mfl-launch-btn {
    display: inline-block;
    padding: 14px 32px;
    background: var(--mcp-primary, #00875A);
    color: #FFFFFF !important;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none !important;
    border-radius: var(--mcp-radius, 8px);
    transition: background 0.2s, box-shadow 0.2s;
    box-shadow: var(--mcp-shadow, 0 1px 3px rgba(0,0,0,0.1));
}

.mfl-launch-btn:hover {
    background: #006644;
    box-shadow: var(--mcp-shadow-hover, 0 4px 12px rgba(0,0,0,0.15));
    color: #FFFFFF !important;
}

.mfl-launch-btn:active {
    background: #005538;
}

/* Iframe wrapper — works for ClickUp, JotForm, and generic embeds */
.mfl-iframe-wrapper {
    border-radius: var(--mcp-radius, 8px);
    overflow: hidden;
    background: transparent;
    position: relative;
    min-height: 500px;
}

.mfl-iframe {
    display: block;
    width: 100%;
    min-height: 500px;
    border: none;
}

/* ClickUp: auto-height via their embed script */
.mfl-iframe.clickup-dynamic-height {
    height: 100%;
}

/* JotForm / generic: starts at configured height, embed handler grows it as needed */
.mfl-iframe:not(.clickup-dynamic-height) {
    height: 539px; /* JotForm initial; overridden inline by JS */
}

.mfl-iframe-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: var(--mcp-card-bg, #FFFFFF);
    z-index: 10;
    justify-content: center;
    padding: 40px;
}

/* Login required / errors */
.mfl-login-required,
.mfl-error {
    padding: 16px 20px;
    background: #fcf0f1;
    border: 1px solid #DE350B;
    border-radius: var(--mcp-radius, 8px);
    color: #DE350B;
    font-size: 14px;
}

/* Responsive */
@media (max-width: 768px) {
    .mfl-filters-row {
        flex-direction: column;
    }

    .mfl-filter-group {
        max-width: 100%;
    }
}
