/* ══ NEPTUNO DESIGN SYSTEM (Vertex Analytics Inspired) ════════ */

:root {
    --background: #F8F9FA;
    --foreground: #111827;
    
    --sidebar: #FFFFFF;
    --sidebar-foreground: #111827;
    --sidebar-muted: #6B7280;
    --sidebar-border: #E5E7EB;
    
    --card: #FFFFFF;
    --card-foreground: #111827;
    --card-border: #E5E7EB;
    
    --primary: #111827;
    --primary-foreground: #FFFFFF;
    
    --muted: #F3F4F6;
    --muted-foreground: #6B7280;
    
    --border: #E5E7EB;
    --radius: 0.75rem;
    
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #3B82F6;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background-color: var(--background);
    color: var(--foreground);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

/* ══ LAYOUT ════════════════════════════════════════════════ */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 260px;
    background: var(--sidebar);
    border-right: 1px solid var(--sidebar-border);
    position: fixed;
    height: 100vh;
    z-index: 50;
    display: flex;
    flex-direction: column;
}

.main-col {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ══ SIDEBAR ═══════════════════════════════════════════════ */
.sidebar-logo-wrap { position: relative; padding: 0.75rem; }

.workspace-switch {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 10px;
    background: #FFF;
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    color: inherit;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.workspace-switch:hover {
    border-color: #D1D5DB;
    background: #FAFAFA;
}
#mode-toggle[aria-expanded="true"] {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.06);
}

.workspace-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFF;
    font-weight: 800;
    font-size: 14px;
    flex-shrink: 0;
    letter-spacing: -0.02em;
}
.workspace-icon-personal { background: linear-gradient(135deg, #111827 0%, #1F2937 100%); }
.workspace-icon-fonko    { background: linear-gradient(135deg, #92400E 0%, #B45309 100%); }
.workspace-icon-sm { width: 28px; height: 28px; font-size: 12px; border-radius: 7px; }

.workspace-meta { flex: 1; min-width: 0; }
.workspace-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--foreground);
    line-height: 1.2;
    letter-spacing: -0.01em;
}
.workspace-sub {
    font-size: 11px;
    color: var(--muted-foreground);
    margin-top: 2px;
    line-height: 1.2;
    display: flex;
    align-items: center;
    gap: 6px;
}
.workspace-version {
    font-size: 9.5px;
    font-weight: 600;
    color: var(--muted-foreground);
    background: var(--muted);
    padding: 1px 5px;
    border-radius: 4px;
    letter-spacing: 0.02em;
}

.workspace-caret {
    color: var(--sidebar-muted);
    opacity: 0.6;
    transition: transform 0.15s;
    flex-shrink: 0;
}
#mode-toggle[aria-expanded="true"] .workspace-caret { transform: rotate(180deg); opacity: 1; }

.mode-menu {
    position: absolute;
    top: calc(100% - 4px);
    left: 12px;
    right: 12px;
    background: #FFF;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 12px 32px -8px rgba(0,0,0,0.18);
    padding: 6px;
    display: none;
    z-index: 60;
}
.mode-menu.is-open { display: block; }

.mode-menu-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 8px 10px 6px;
}

.mode-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    background: none;
    border: none;
    border-radius: 8px;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    color: var(--foreground);
}
.mode-menu-item + .mode-menu-item { margin-top: 2px; }
.mode-menu-item:hover { background: var(--muted); }
.mode-menu-item.is-active { background: var(--muted); }

.mode-menu-text { flex: 1; min-width: 0; }
.mode-menu-text strong { display: block; font-size: 13px; font-weight: 600; line-height: 1.2; }
.mode-menu-text small { display: block; font-size: 11px; color: var(--muted-foreground); margin-top: 2px; line-height: 1.2; }

.mode-check { color: var(--primary); flex-shrink: 0; }

/* ══ PROVIDER CARDS (AI Builder) ═════════════════════════ */
.provider-card {
    display: block;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    background: #FFF;
    transition: all 0.15s;
}
.provider-card:hover { border-color: var(--primary); }
.provider-card.is-active {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.06);
    background: #FAFAFA;
}
.provider-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    margin-bottom: 4px;
}
.provider-card-status { font-size: 11px; font-weight: 600; }
.provider-card-sub { font-size: 11px; color: var(--muted-foreground); }

.sidebar-logo-icon {
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: var(--primary-foreground);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
}

.sidebar-logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.04em;
}

.sidebar-section-label {
    padding: 1.5rem 1.5rem 0.5rem;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: #9CA3AF;
    letter-spacing: 0.08em;
}

.sidebar-divider {
    height: 1px;
    background: #F3F4F6;
    margin: 0.5rem 1rem;
}

.sidebar-nav { padding: 0 0.75rem; }

.nav-item {
    display: flex;
    align-items: center;
    padding: 0.625rem 0.75rem;
    gap: 0.75rem;
    border-radius: 8px;
    color: var(--sidebar-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    margin-bottom: 2px;
}

.nav-item:hover { background: var(--muted); color: var(--foreground); }
.nav-item-active { background: var(--muted); color: var(--foreground); }

.nav-icon { width: 18px; height: 18px; opacity: 0.7; flex-shrink: 0; }
.nav-item-active .nav-icon { opacity: 1; }

.nav-chevron { width: 14px; height: 14px; margin-left: auto; opacity: 0.5; flex-shrink: 0; }
.nav-item-active .nav-chevron { opacity: 1; }

.sidebar-user {
    margin-top: auto;
    padding: 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: #F9FAFB;
}

.sidebar-avatar {
    width: 36px;
    height: 36px;
    background: var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
}

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { display: block; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-email { display: block; font-size: 11px; color: var(--muted-foreground); overflow: hidden; text-overflow: ellipsis; }

/* ══ TOPNAV ════════════════════════════════════════════════ */
.topnav {
    height: 64px;
    background: #FFF;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 40;
}

.topnav-search {
    display: flex;
    align-items: center;
    background: var(--muted);
    border-radius: 8px;
    padding: 0 0.75rem;
    width: 320px;
}

.search-icon {
    width: 16px;
    height: 16px;
    color: var(--muted-foreground);
    flex-shrink: 0;
}

.search-input {
    background: none;
    border: none;
    padding: 0.5rem;
    font-size: 14px;
    width: 100%;
    outline: none;
}

.topnav-right { display: flex; align-items: center; gap: 1.5rem; }
.topnav-bell { background: none; border: none; position: relative; cursor: pointer; color: var(--muted-foreground); }
.bell-dot { position: absolute; top: 0; right: 0; width: 8px; height: 8px; background: var(--danger); border: 2px solid #FFF; border-radius: 50%; }

/* ══ DASHBOARD ═════════════════════════════════════════════ */
.page-main { padding: 2rem; max-width: 1440px; margin: 0 auto; width: 100%; }

.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; }
.page-title { font-size: 1.875rem; font-weight: 700; letter-spacing: -0.025em; }
.page-subtitle { color: var(--muted-foreground); font-size: 0.875rem; }
.page-header-actions { display: flex; gap: 1rem; }

.header-date-picker {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: #FFF;
}

/* ══ STATS ═════════════════════════════════════════════════ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.stat-card-header { display: flex; justify-content: space-between; margin-bottom: 0.5rem; }
.stat-label { font-size: 12px; font-weight: 600; text-transform: uppercase; color: var(--muted-foreground); letter-spacing: 0.025em; }
.stat-icon { width: 16px; height: 16px; color: var(--muted-foreground); }

.stat-value { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.25rem; }
.stat-footer { font-size: 12px; display: flex; align-items: center; gap: 0.25rem; }
.trend-up { color: var(--success); font-weight: 600; }
.stat-footer-label { color: var(--muted-foreground); }

/* ══ TABS ══════════════════════════════════════════════════ */
.tabs-container { margin-bottom: 1.5rem; }
.tabs-list { background: var(--muted); padding: 0.25rem; border-radius: 8px; display: inline-flex; }
.tab-trigger {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--muted-foreground);
    text-decoration: none;
    transition: all 0.2s;
}
.tab-trigger.active { background: #FFF; color: var(--foreground); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.tab-trigger.disabled { opacity: 0.5; cursor: not-allowed; }

/* ══ GRID ══════════════════════════════════════════════════ */
.dashboard-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1.5rem; }

.card { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); }
.card-kanban { grid-column: span 4; }
.card-feed { grid-column: span 3; }
.card-kanban-wide { grid-column: span 7; }
.card-zeus-wide { grid-column: span 4; }

.card-header { padding: 1.5rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: flex-start; }
.card-title { font-size: 1.125rem; font-weight: 600; }
.card-description { font-size: 0.8125rem; color: var(--muted-foreground); font-family: 'Playfair Display', serif; font-style: italic; }

.card-body { padding: 1.5rem; }
.card-body.no-padding { padding: 0; }

/* ══ KANBAN ════════════════════════════════════════════════ */
.kanban-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; align-items: start; }
.kanban-col { background: #F9FAFB; border-radius: 8px; padding: 0.75rem; min-height: 500px; }
.kanban-col-header { display: flex; justify-content: space-between; margin-bottom: 1rem; padding: 0 0.25rem; }
.kanban-col-title { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--muted-foreground); }
.kanban-col-count { font-size: 11px; color: var(--muted-foreground); }

.task-card {
    background: #FFF;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem;
    cursor: pointer;
    margin-bottom: 0.75rem;
    transition: transform 0.2s, box-shadow 0.2s;
}
.task-card:hover { transform: translateY(-2px); box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); border-color: var(--primary); }

.task-card-title { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.25rem; }
.priority-indicator { width: 8px; height: 8px; border-radius: 50%; }
.priority-low { background: var(--success); }
.priority-medium { background: var(--info); }
.priority-high { background: var(--warning); }
.priority-critical { background: var(--danger); }

.task-card-desc { font-size: 11px; color: var(--muted-foreground); margin-bottom: 0.75rem; }
.task-card-footer { display: flex; justify-content: space-between; align-items: center; }

.badge-priority { font-size: 9px; font-weight: 700; text-transform: uppercase; padding: 1px 4px; border-radius: 4px; }
.badge-low { background: #ECFDF5; color: #065F46; }
.badge-medium { background: #EFF6FF; color: #1E40AF; }
.badge-high { background: #FFFBEB; color: #92400E; }
.badge-critical { background: #FEF2F2; color: #991B1B; }

.task-card-date { font-size: 10px; color: var(--muted-foreground); }

/* ══ FEED ══════════════════════════════════════════════════ */
.feed-list { display: flex; flex-direction: column; }
.feed-item { padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; gap: 1rem; align-items: center; }
.feed-item-icon { font-size: 1.25rem; }
.feed-item-content { flex: 1; }
.feed-item-title { font-size: 13px; font-weight: 600; text-transform: capitalize; }
.feed-item-meta { font-size: 11px; color: var(--muted-foreground); }

.feed-placeholder { padding: 4rem 2rem; text-align: center; color: var(--muted-foreground); }
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 1rem; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ══ MODAL ═════════════════════════════════════════════════ */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 100; display: none; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.modal-overlay.active { display: flex; }

.modal-container { background: #FFF; width: 100%; max-width: 500px; border-radius: 12px; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1); }
.modal-header { padding: 1.5rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 1.5rem; }

.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 0.5rem; }
.form-input { width: 100%; padding: 0.625rem; border: 1px solid var(--border); border-radius: 8px; font-family: inherit; font-size: 14px; }
.form-input:focus { outline: none; border-color: var(--primary); ring: 2px solid #E5E7EB; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.modal-footer { display: flex; justify-content: flex-end; gap: 0.75rem; margin-top: 1rem; }

/* ══ BUTTONS ═══════════════════════════════════════════════ */
.btn { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.625rem 1rem; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; border: 1px solid transparent; transition: all 0.2s; }
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { background: #374151; }
.btn-outline { background: #FFF; border-color: var(--border); color: var(--foreground); }
.btn-outline:hover { background: var(--muted); }
.btn-icon { background: none; border: none; cursor: pointer; color: var(--muted-foreground); border-radius: 6px; padding: 4px; }
.btn-icon:hover { background: var(--muted); color: var(--foreground); }

@media (max-width: 1024px) {
    .sidebar { display: none; }
    .main-col { margin-left: 0; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr; }
    .card-kanban, .card-feed, .card-kanban-wide, .card-zeus-wide { grid-column: span 1; }
}

/* ══ v5.9.17: dynamic-view defensive sizing (hardened) ═══════
   Chart.js with `responsive: true, maintainAspectRatio: false` resizes its
   canvas to fill the parent. If the parent has no fixed height, the canvas
   keeps growing on every resize tick and the page expands forever. The CSS
   alone can't fix this when the LLM-generated parent has no height — JS in
   dynamic/show.blade.php and dashboard.blade.php walks each canvas and forces
   its parent to a fixed height. This CSS is the secondary safety net.        */
.dynamic-container canvas {
    max-height: 420px !important;
    max-width: 100% !important;
    display: block;
}
/* v5.9.27: only cap CHART wrapper divs (those containing a canvas) — NOT table
   or text views. The old rule capped every direct child at 480px, which clipped
   tall table views and made them spill over the cards below. Scoping to
   :has(canvas) frees tables/lists to render at full height. */
.dynamic-container > div:has(canvas) {
    max-height: 480px;
    overflow: hidden;
}
/* If the canvas is the *direct* child (no LLM wrapper), give it a normal box. */
.dynamic-container > canvas {
    height: 380px !important;
    width: 100% !important;
}
/* v5.9.27: let wide tables scroll horizontally instead of overflowing the card. */
.dynamic-container { overflow-x: auto; }
.dynamic-container table { max-width: 100%; border-collapse: collapse; }
