/* Commons v3 shell additions.
 * Part 1: the rules v2 kept in an inline <style> in base.html (moved here, same values).
 * Part 2: small v3-only classes (explorer, review, admin, auth extras). Tokens from core.css only.
 */

/* ============================================
   Part 1 - v2 base.html shell (was inline)
   ============================================ */
body, html {
    margin: 0;
    padding: 0;
    font-family: 'Roboto', sans-serif;
    background-color: #f5f5f5;
    height: 100vh;
}
.content { display: flex; min-height: 100vh; justify-content: center; }
.workspace {
    flex: 1;
    margin-left: 220px;
    padding: 20px;
    background-color: #f5f5f5;
    width: calc(100% - 250px);
}
.flash-messages { margin: 20px 0; }
.flash-message { padding: 12px; margin: 10px 0; border-radius: 4px; font-weight: 500; }
.flash-message.error { background-color: #fee; color: #c33; border: 1px solid #fcc; }
.flash-message.success { background-color: #efe; color: #3c3; border: 1px solid #cfc; }
.flash-message.info { background-color: #eef; color: #33c; border: 1px solid #ccf; }
.flash-message.warning { background-color: #ffe; color: #cc3; border: 1px solid #ffc; }

/* Sign-in pages */
.conversation-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    width: 100%;
    background-color: #f5f5f5;
}
.conversation-box {
    background-color: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    min-width: 400px;
    max-width: 440px;
    box-sizing: border-box;
}
.title { text-align: center; margin-bottom: 30px; color: #1a2234; font-size: 2em; font-weight: 500; }
.field { margin-bottom: 20px; }
.input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    box-sizing: border-box;
}
.input:focus { outline: none; border-color: #1a2234; }
.button {
    width: 100%;
    padding: 12px;
    background-color: #1a2234;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    font-weight: 500;
}
.button:hover { background-color: #2a3a7a; }
.button-secondary { margin-top: 10px; background-color: var(--color-gray-200, #e5e7eb); color: #1a2234; }
.button-secondary:hover { background-color: #d1d5db; }
.checkbox { display: flex; align-items: center; gap: 8px; margin: 15px 0; }
.text-center { text-align: center; }
.text-center p { margin: 15px 0; }
a { color: #1a2234; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================
   Part 2 - v3 additions
   ============================================ */

/* Sidebar: sign-out is a POST form; make its button look like a nav item. */
.nav-form { margin: 0; }
#flock-sidebar button.nav-item {
    width: 100%;
    background: none;
    border: none;
    font: inherit;
    cursor: pointer;
    text-align: left;
}
.nav-badge {
    margin-left: auto;
    min-width: 18px;
    padding: 0 6px;
    border-radius: 9px;
    background: var(--color-primary-light);
    color: #fff;
    font-size: 11px;
    line-height: 18px;
    text-align: center;
}
.nav-tenant { font-size: 12px; opacity: 0.75; padding: 0 10px 8px; }

/* Toasts (static/js/shell.js) */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 10000; display: flex; flex-direction: column; gap: 8px; }
.toast-container .toast.is-leaving { opacity: 0; transition: opacity 0.3s; }

/* Auth extras */
.auth-brand { display: block; margin: 0 auto 16px; height: 40px; }
.auth-links { margin-top: 18px; font-size: 14px; }
.auth-hint { color: var(--color-text-secondary); font-size: 14px; }
.tenant-pick-list { list-style: none; padding: 0; margin: 0; text-align: left; }
.tenant-pick-list li { margin: 0 0 10px; }
.tenant-pick-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: #fff;
    border: 1px solid var(--color-border-light, #e5e7eb);
    border-radius: 6px;
    font: inherit;
    font-size: 16px;
    cursor: pointer;
}
.tenant-pick-btn:hover { border-color: var(--color-primary); }
.tenant-pick-current { color: var(--color-text-secondary); font-size: 12px; }

/* Error page */
.error-page { max-width: 560px; margin: 80px auto; text-align: center; }
.error-code { font-size: 64px; font-weight: 700; color: var(--color-primary); margin: 0; }

/* Explorer */
.explorer-layout { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: start; }
.explorer-types { list-style: none; margin: 0; padding: 8px 0; }
.explorer-types a {
    display: flex;
    justify-content: space-between;
    padding: 8px 14px;
    color: var(--color-text-primary);
}
.explorer-types a:hover { background: var(--color-bg-light, #f8f9fa); text-decoration: none; }
.explorer-types a.is-active { font-weight: 600; background: var(--color-bg-light, #f8f9fa); }
.explorer-count { color: var(--color-text-secondary); font-size: 12px; }
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }

.pager { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.sort-link { color: inherit; }
.sort-link.is-active { font-weight: 700; }
.kv-table th { width: 220px; text-align: left; color: var(--color-text-secondary); font-weight: 500; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0; border-bottom: 1px solid var(--color-border-light, #eee); }
.timeline-when { color: var(--color-text-secondary); font-size: 12px; }
.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; align-items: start; }

/* Review inbox */
.review-item { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; }
.review-item + .review-item { border-top: 1px solid var(--color-border-light, #eee); padding-top: 14px; margin-top: 14px; }
.review-actions { display: flex; gap: 8px; flex-shrink: 0; }
.review-change { font-size: 13px; color: var(--color-text-secondary); }
.review-change del { color: var(--color-danger); }
.review-change ins { color: var(--color-success); text-decoration: none; }
.inline-form { display: inline; margin: 0; }

/* Admin (cleaner than v2's staff console; same tokens) */
.admin-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--color-border-light, #e5e7eb); margin-bottom: 20px; flex-wrap: wrap; }
.admin-tab {
    padding: 10px 14px;
    color: var(--color-text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.admin-tab:hover { color: var(--color-text-primary); text-decoration: none; }
.admin-tab.is-active { color: var(--color-primary); border-bottom-color: var(--color-primary); font-weight: 600; }
.issue-list { list-style: none; margin: 0; padding: 0; }
.issue { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--color-border-light, #eee); }
.issue-icon-critical { color: var(--color-danger); }
.issue-icon-warning { color: var(--color-warning); }
.issue-icon-info { color: var(--color-info); }
.issue-title { font-weight: 600; }
.issue-detail { color: var(--color-text-secondary); font-size: 14px; }
.key-form { display: flex; gap: 8px; align-items: center; }
.key-form .form-input { max-width: 280px; }
.cap-form { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.meter { height: 8px; background: var(--color-border-light, #eee); border-radius: 4px; overflow: hidden; }
.meter-fill { height: 100%; width: var(--pct, 0%); background: var(--color-primary); }
.meter-fill.is-high { background: var(--color-warning); }
.admin-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.health-group { margin-top: 20px; }
.health-icon-ok { color: var(--color-success); }
.health-icon-warning { color: var(--color-warning); }
.health-icon-failing { color: var(--color-danger); }
.health-count-failing { color: var(--color-danger); }
.health-count-warning { color: var(--color-warning); }
.health-fix { font-size: 14px; margin-top: 4px; }
.health-checked { color: var(--color-text-secondary); font-size: 12px; margin-top: 12px; }

/* Advisor full page: SSE status + confirm buttons spacing */
.advisor-stream-cursor::after { content: "\258D"; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

@media (max-width: 768px) {
    .workspace { margin-left: 0; width: 100%; padding: 12px 12px 80px; }
    .explorer-layout, .detail-grid, .admin-grid-2 { grid-template-columns: 1fr; }
    .conversation-box { min-width: 0; width: calc(100% - 32px); padding: 24px; }
}

/* Filter bars: fixed-width field groups so inputs never overlap the button */
.filter-bar > div { flex: 0 1 200px; min-width: 0; }
.filter-bar .form-input, .filter-bar .form-select { width: 100%; min-width: 0; box-sizing: border-box; }
.cap-form > div { flex: 0 1 200px; min-width: 0; }
.cap-form .form-input { width: 100%; box-sizing: border-box; }
.stat-card-grid + .card-container { margin-top: 20px; }
/* Advisor rail rendered server-side as a list (v2 built it in JS) */
ul.advisor-rail-list { list-style: none; margin: 0; padding: 0; }
.advisor-rail-new { box-sizing: border-box; }
a.advisor-rail-item:hover { text-decoration: none; }
