/* ==========================================================================
   FlowDL Frontend — Input Capsule + Results UI
   All admin-customizable values are CSS custom properties, set inline on
   .flowdl-widget from PHP (see FlowDL_Shortcode::render_box()):
     --flow-primary-color, --flow-primary-hover, --flow-btn-radius,
     --flow-card-bg, --flow-text-main
   ========================================================================== */

.flowdl-widget {
    --flow-primary-color: #ff0000;
    --flow-primary-hover: #cc0000;
    --flow-btn-radius: 12px;
    --flow-card-bg: #ffffff;
    --flow-text-main: #1e293b;
    --flow-dark: #3f3f46;
    --flow-dark-hover: #27272a;
    --flow-muted-bg: #f4f4f5;
    --flow-muted-text: #71717a;
    --flow-border: #ecebee;

    max-width: 640px;
    margin: 1.5em auto;
    direction: rtl;
    text-align: right;
    font-family: inherit;
    color: var(--flow-text-main);
    box-sizing: border-box;
}

.flowdl-widget *,
.flowdl-widget *::before,
.flowdl-widget *::after {
    box-sizing: border-box;
}

.flowdl-widget button {
    font-family: inherit;
}

/* ---------------------------- Input capsule bar --------------------------- */

.flowdl-bar {
    position: relative;
    display: flex;
    align-items: stretch;
    background: #ffffff;
    border-radius: 50px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.flowdl-bar__input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    padding: 0 1.4em;
    font-size: 0.95em;
    color: var(--flow-text-main);
    direction: rtl;
    text-align: right;
}

.flowdl-bar__input::placeholder {
    color: #9ca3af;
}

.flowdl-bar__input:focus {
    outline: none;
}

.flowdl-bar__submit {
    border: none;
    background: var(--flow-dark);
    color: #fff;
    font-weight: 600;
    font-size: 0.95em;
    padding: 0 1.6em;
    cursor: pointer;
    transition: background-color 0.15s ease;
    white-space: nowrap;
}

.flowdl-bar__submit:hover {
    background: var(--flow-dark-hover);
}

.flowdl-bar__submit:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.flowdl-bar__divider {
    width: 1px;
    background: rgba(255, 255, 255, 0.18);
    align-self: center;
    height: 55%;
}

.flowdl-bar__gear {
    position: relative;
    border: none;
    background: var(--flow-dark);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 1.1em;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.flowdl-bar__gear:hover {
    background: var(--flow-dark-hover);
}

.flowdl-bar__badge {
    position: absolute;
    top: -8px;
    left: -6px;
    background: #f6c445;
    color: #5c4300;
    font-size: 0.62em;
    font-weight: 800;
    line-height: 1;
    padding: 0.35em 0.5em;
    border-radius: 999px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

/* -------------------------------- Status line ------------------------------ */

.flowdl-status {
    margin-top: 0.9em;
    padding: 0 0.4em;
    font-size: 0.88em;
    color: var(--flow-muted-text);
}

.flowdl-status.is-error {
    color: #d63031;
}

/* -------------------------------- Results wrap ------------------------------ */

.flowdl-results {
    margin-top: 1em;
}

/* ------------------------------ Header media card ---------------------------- */

.flowdl-media-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.2em;
    background: var(--flow-card-bg);
    border: 1px solid var(--flow-border);
    border-radius: 20px;
    padding: 1em;
    margin-bottom: 0.9em;
}

.flowdl-media-card__cover {
    width: 150px;
    height: 105px;
    object-fit: cover;
    border-radius: 14px;
    flex-shrink: 0;
    background: var(--flow-muted-bg);
}

.flowdl-media-card__info {
    flex: 1;
    min-width: 0;
}

.flowdl-media-card__title {
    font-weight: 700;
    font-size: 1.02em;
    color: var(--flow-text-main);
    margin-bottom: 0.25em;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.flowdl-media-card__author {
    font-size: 0.82em;
    color: var(--flow-muted-text);
    margin-bottom: 0.9em;
}

.flowdl-media-card__actions {
    display: flex;
    gap: 0.6em;
    flex-wrap: wrap;
}

.flowdl-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    border-radius: 999px;
    padding: 0.55em 1.1em;
    font-size: 0.82em;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.15s ease, background-color 0.15s ease;
}

.flowdl-btn--solid {
    border: 1px solid var(--flow-primary-color);
    background: var(--flow-primary-color);
    color: #fff;
}

.flowdl-btn--solid:hover {
    background: var(--flow-primary-hover);
    border-color: var(--flow-primary-hover);
}

.flowdl-btn--outline {
    border: 1px solid var(--flow-primary-color);
    background: transparent;
    color: var(--flow-primary-color);
}

.flowdl-btn--outline:hover {
    background: rgba(255, 0, 0, 0.06);
}

/* ------------------------------------ Tabs ----------------------------------- */

.flowdl-tabs {
    display: flex;
    gap: 0.7em;
    margin-bottom: 0.9em;
}

.flowdl-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5em;
    border: 1.5px solid transparent;
    background: var(--flow-muted-bg);
    color: var(--flow-muted-text);
    border-radius: 14px;
    padding: 0.85em 1em;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.flowdl-tab.is-active {
    background: var(--flow-card-bg);
    border-color: var(--flow-primary-color);
    color: var(--flow-primary-color);
    box-shadow: 0 6px 16px -6px rgba(0, 0, 0, 0.12);
}

/* --------------------------------- Quality list -------------------------------- */

.flowdl-quality-list {
    display: flex;
    flex-direction: column;
    gap: 0.6em;
    background: var(--flow-card-bg);
    border: 1px solid var(--flow-border);
    border-radius: 18px;
    padding: 0.6em;
}

.flowdl-quality-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8em;
    background: var(--flow-card-bg);
    border: 1px solid var(--flow-border);
    border-radius: 14px;
    padding: 0.7em 0.9em;
}

.flowdl-quality-item__meta {
    display: flex;
    align-items: center;
    gap: 0.7em;
    min-width: 0;
}

.flowdl-quality-item__icon {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--flow-muted-bg);
    color: var(--flow-muted-text);
    border-radius: 10px;
}

.flowdl-quality-item__text {
    min-width: 0;
}

.flowdl-quality-item__label {
    font-weight: 700;
    font-size: 0.92em;
    color: var(--flow-text-main);
    display: block;
}

.flowdl-quality-item__sub {
    display: flex;
    align-items: center;
    gap: 0.5em;
    margin-top: 0.15em;
    font-size: 0.78em;
    color: var(--flow-muted-text);
}

.flowdl-quality-item__badge {
    background: var(--flow-muted-bg);
    color: var(--flow-muted-text);
    font-weight: 700;
    font-size: 0.72em;
    padding: 0.15em 0.5em;
    border-radius: 6px;
}

.flowdl-quality-item__action {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    border: none;
    border-radius: var(--flow-btn-radius);
    background: var(--flow-primary-color);
    color: #fff;
    font-size: 0.82em;
    font-weight: 700;
    padding: 0.6em 1em;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background-color 0.15s ease;
}

.flowdl-quality-item__action:hover {
    background: var(--flow-primary-hover);
}

.flowdl-quality-item__action.is-locked {
    background: var(--flow-muted-bg);
    color: var(--flow-muted-text);
}

.flowdl-quality-item__lock-badge {
    background: #f6c445;
    color: #5c4300;
    font-size: 0.68em;
    font-weight: 800;
    padding: 0.15em 0.5em;
    border-radius: 999px;
    margin-inline-start: 0.4em;
}

.flowdl-empty-state {
    text-align: center;
    padding: 1.5em 1em;
    color: var(--flow-muted-text);
    font-size: 0.88em;
}

/* --------------------------------- Upgrade modal -------------------------------- */

.flowdl-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    padding: 1em;
}

.flowdl-modal[hidden] {
    display: none;
}

.flowdl-modal__card {
    background: #fff;
    border-radius: 20px;
    padding: 1.5em;
    max-width: 420px;
    width: 100%;
    direction: rtl;
    text-align: right;
}

.flowdl-modal__card h3 {
    margin-top: 0;
    color: var(--flow-text-main, #1e293b);
}

.flowdl-modal__row {
    display: flex;
    justify-content: space-between;
    padding: 0.4em 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.92em;
}

.flowdl-modal__submit {
    border: none;
    border-radius: var(--flow-btn-radius, 12px);
    background: var(--flow-primary-color, #ff0000);
    color: #fff;
    font-weight: 700;
    padding: 0.6em 1.2em;
    cursor: pointer;
}

.flowdl-modal__close {
    margin-top: 1em;
    background: none;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 0.5em 1em;
    cursor: pointer;
}

/* ------------------------------------ Responsive -------------------------------- */

@media (max-width: 480px) {
    .flowdl-media-card {
        flex-direction: column;
        align-items: stretch;
    }
    .flowdl-media-card__cover {
        width: 100%;
        height: 160px;
    }
    .flowdl-bar__submit {
        padding: 0 1.1em;
    }
}

@media (prefers-reduced-motion: reduce) {
    .flowdl-widget * {
        transition: none !important;
    }
}
