/* =============================================================================
   ai-control.css — Emerald-tier AI Control Center (/owner/ai)
   Layered on shared-dashboard-styles.css; renders over the universe background.
   ========================================================================== */

.aic-page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 130px 20px 90px;
    box-sizing: border-box;
    color: #e8eefc;
}

/* ── Access gate ─────────────────────────────────────────────────────────── */
.aic-auth {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.aic-auth-box {
    text-align: center;
    padding: 44px 40px;
    border-radius: 18px;
    background: rgba(14, 20, 38, 0.6);
    border: 1px solid rgba(116, 211, 255, 0.16);
    backdrop-filter: blur(10px);
    max-width: 480px;
}
.aic-auth-state h1 { font-size: 1.6rem; margin: 14px 0 8px; }
.aic-auth-state p { color: rgba(200, 214, 240, 0.72); margin: 6px 0; }
.aic-back-link { color: #74d3ff; text-decoration: none; }
.aic-back-link:hover { text-decoration: underline; }
.aic-spinner {
    width: 38px; height: 38px; margin: 0 auto;
    border: 3px solid rgba(116, 211, 255, 0.2);
    border-top-color: #4a90e2;
    border-radius: 50%;
    animation: aicSpin 0.8s linear infinite;
}
@keyframes aicSpin { to { transform: rotate(360deg); } }

/* ── Header ──────────────────────────────────────────────────────────────── */
.aic-header { margin-bottom: 22px; }
.aic-eyebrow {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    color: #34d399;
    padding: 4px 10px;
    border: 1px solid rgba(52, 211, 153, 0.35);
    border-radius: 999px;
    margin-bottom: 10px;
}
.aic-header h1 { font-size: clamp(1.8rem, 4vw, 2.4rem); margin: 0 0 6px; }
.aic-sub { color: rgba(200, 214, 240, 0.66); margin: 0; }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.aic-toast {
    margin-bottom: 16px;
    padding: 12px 16px;
    border-radius: 12px;
    font-weight: 600;
    background: rgba(74, 144, 226, 0.14);
    border: 1px solid rgba(74, 144, 226, 0.4);
}
.aic-toast[data-type="success"] { background: rgba(34, 197, 94, 0.14); border-color: rgba(34, 197, 94, 0.45); }
.aic-toast[data-type="error"] { background: rgba(248, 113, 113, 0.14); border-color: rgba(248, 113, 113, 0.5); color: #fecaca; }

/* ── Grid + cards ────────────────────────────────────────────────────────── */
.aic-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}
.aic-card {
    background: linear-gradient(180deg, rgba(16, 24, 44, 0.62), rgba(10, 16, 32, 0.5));
    border: 1px solid rgba(116, 211, 255, 0.14);
    border-radius: 16px;
    padding: 22px 22px 20px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}
.aic-card--wide { grid-column: 1 / -1; }
.aic-card h2 {
    display: flex; align-items: center; gap: 9px;
    font-size: 1.12rem; margin: 0 0 8px;
}
.aic-card h2 .material-symbols-outlined { font-size: 1.3rem; color: #74d3ff; }
.aic-card-note { color: rgba(200, 214, 240, 0.6); font-size: 0.88rem; line-height: 1.5; margin: 0 0 16px; }
.aic-card-note code { color: #9defb9; background: rgba(34, 197, 94, 0.1); padding: 1px 6px; border-radius: 5px; }

/* ── Stats ───────────────────────────────────────────────────────────────── */
.aic-stats { display: flex; flex-wrap: wrap; gap: 18px 28px; margin: 0 0 18px; }
.aic-stats > div { display: flex; flex-direction: column; }
.aic-stats dt { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: rgba(200, 214, 240, 0.5); }
.aic-stats dd { margin: 2px 0 0; font-size: 1.25rem; font-weight: 700; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.aic-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.aic-btn {
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid transparent;
    transition: transform 0.15s ease, background-color 0.2s ease, opacity 0.2s ease;
}
.aic-btn:hover { transform: translateY(-1px); }
.aic-btn:disabled, .aic-btn.is-busy { opacity: 0.55; cursor: default; transform: none; }
.aic-btn--primary { background: linear-gradient(45deg, #4a90e2, #5aa1f2); color: #fff; }
.aic-btn--ghost { background: rgba(255, 255, 255, 0.05); border-color: rgba(116, 211, 255, 0.3); color: #dbe7ff; }
.aic-btn--ghost:hover { background: rgba(116, 211, 255, 0.12); }
.aic-btn--danger { background: rgba(248, 113, 113, 0.16); border-color: rgba(248, 113, 113, 0.5); color: #fecaca; }
.aic-btn--danger:hover { background: rgba(248, 113, 113, 0.28); }

/* ── Toggle + fields ─────────────────────────────────────────────────────── */
.aic-toggle { display: flex; align-items: center; gap: 12px; cursor: pointer; margin-bottom: 16px; }
.aic-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.aic-toggle-track {
    position: relative; width: 46px; height: 26px; flex: none;
    background: rgba(255, 255, 255, 0.16); border-radius: 999px;
    transition: background 0.2s ease;
}
.aic-toggle-track::after {
    content: ''; position: absolute; top: 3px; left: 3px;
    width: 20px; height: 20px; border-radius: 50%; background: #fff;
    transition: transform 0.2s ease;
}
.aic-toggle input:checked + .aic-toggle-track { background: #22c55e; }
.aic-toggle input:checked + .aic-toggle-track::after { transform: translateX(20px); }
.aic-toggle-label strong { color: #fff; }

.aic-field { display: block; margin-bottom: 14px; }
.aic-field > span { display: block; font-size: 0.82rem; color: rgba(200, 214, 240, 0.66); margin-bottom: 6px; }
.aic-field textarea,
.aic-search input,
.aic-card input[type="text"] {
    width: 100%; box-sizing: border-box;
    background: rgba(8, 12, 24, 0.6);
    border: 1px solid rgba(116, 211, 255, 0.2);
    border-radius: 10px; color: #eaf2ff; padding: 10px 12px;
    font-family: inherit; font-size: 0.92rem;
}
.aic-field textarea:focus,
.aic-search input:focus { outline: none; border-color: #4a90e2; }

/* ── Quota ───────────────────────────────────────────────────────────────── */
.aic-search { display: flex; gap: 10px; margin-bottom: 14px; }
.aic-search input { flex: 1; }
.aic-empty { color: rgba(200, 214, 240, 0.5); font-style: italic; }
.aic-match-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.aic-match {
    width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 10px;
    background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(116, 211, 255, 0.16);
    border-radius: 9px; padding: 9px 12px; color: #e8eefc; cursor: pointer; text-align: left;
}
.aic-match:hover { background: rgba(116, 211, 255, 0.1); }
.aic-match code, .aic-uid { font-size: 0.72rem; color: rgba(200, 214, 240, 0.5); }
.aic-usage-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.aic-role {
    font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em;
    padding: 2px 8px; border-radius: 999px; background: rgba(116, 211, 255, 0.12); color: #74d3ff;
}
.aic-uid { display: block; margin-bottom: 12px; }

/* ── Flagged ─────────────────────────────────────────────────────────────── */
.aic-flagged-list { margin-top: 12px; }
.aic-flagged-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.aic-flagged-item {
    background: rgba(248, 113, 113, 0.06);
    border: 1px solid rgba(248, 113, 113, 0.22);
    border-radius: 10px; padding: 12px 14px;
}
.aic-flagged-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 12px; margin-bottom: 6px; }
.aic-flagged-meta code { font-size: 0.7rem; color: rgba(200, 214, 240, 0.5); }
.aic-flagged-when { font-size: 0.74rem; color: rgba(200, 214, 240, 0.55); margin-left: auto; }
.aic-flagged-q { margin: 0; font-size: 0.9rem; color: #fde4e4; word-break: break-word; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 760px) {
    .aic-page { padding: 110px 14px 70px; }
    .aic-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    .aic-spinner { animation-duration: 1.6s; }
    .aic-btn:hover { transform: none; }
}
