/* ===== Dashboard Enhanced Styles ===== */

/* Stats Row */
.dash-stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.dash-stat {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
}

.dash-stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm, 6px);
    flex-shrink: 0;
}

.dash-stat-revenue { background: #ecfdf5; color: #059669; }
.dash-stat-month { background: #eff6ff; color: #2563eb; }
.dash-stat-stock { background: #fefce8; color: #ca8a04; }
.dash-stat-ops { background: #faf5ff; color: #7c3aed; }

html[data-theme="dark"] .dash-stat-revenue { background: #064e3b33; }
html[data-theme="dark"] .dash-stat-month { background: #1e40af33; }
html[data-theme="dark"] .dash-stat-stock { background: #854d0e33; }
html[data-theme="dark"] .dash-stat-ops { background: #6d28d933; }

.dash-stat div {
    min-width: 0;
}

.dash-stat strong {
    display: block;
    font-size: 1.15rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dash-stat span {
    font-size: 0.78rem;
    color: var(--ink-muted, #64748b);
}

/* Quick Actions (enhanced) */
.dash-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.dash-action {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.92rem;
    text-decoration: none;
    transition: transform 0.15s, box-shadow 0.15s;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--ink);
}

.dash-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.dash-action-icon {
    font-size: 1.1rem;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-weight: 700;
}

.dash-action.sale .dash-action-icon { background: #dcfce7; color: #16a34a; }
.dash-action.trade .dash-action-icon { background: #dbeafe; color: #2563eb; }
.dash-action.stock .dash-action-icon { background: #fef9c3; color: #ca8a04; }
.dash-action.assembly .dash-action-icon { background: #f3e8ff; color: #7c3aed; }
.dash-action.regional .dash-action-icon { background: #e0f2fe; color: #0284c7; }

/* AI Quick Section */
.dash-ai-section {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.dash-ai-section > .panel-header {
    margin-bottom: 1rem;
}

.dash-ai-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}

.dash-ai-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
    padding: 1rem;
    background: var(--control-bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    text-decoration: none;
    color: var(--ink);
}

.dash-ai-card:hover {
    border-color: var(--pcb);
    box-shadow: 0 2px 8px rgba(33, 212, 239, 0.12);
}

.dash-ai-card svg {
    color: var(--pcb);
}

.dash-ai-card strong {
    font-size: 0.88rem;
}

.dash-ai-card span {
    font-size: 0.78rem;
    color: var(--ink-muted, #64748b);
}

/* Bottom Grid */
.dash-bottom-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.dash-ticker-panel {
    grid-column: 1 / -1;
}

@media (max-width: 768px) {
    .dash-bottom-grid { grid-template-columns: 1fr; }
    .dash-stats-row { grid-template-columns: 1fr 1fr; }
    .dash-ai-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
    .dash-stats-row { grid-template-columns: 1fr; }
    .dash-ai-grid { grid-template-columns: 1fr; }
}

/* Recent Transactions List */
.dash-tx-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.dash-tx-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--line, #e2e8f0);
}

.dash-tx-item:last-child { border-bottom: none; }

.dash-tx-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-sale { background: #dcfce7; color: #16a34a; }
.badge-trade { background: #dbeafe; color: #2563eb; }
html[data-theme="dark"] .badge-sale { background: #064e3b44; color: #4ade80; }
html[data-theme="dark"] .badge-trade { background: #1e40af44; color: #60a5fa; }

.dash-tx-info {
    flex: 1;
    min-width: 0;
}

.dash-tx-info strong {
    display: block;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dash-tx-info small {
    font-size: 0.75rem;
    color: var(--ink-muted, #64748b);
}

.dash-tx-amount {
    font-weight: 700;
    font-size: 0.88rem;
    white-space: nowrap;
}

/* Low Stock List */
.dash-low-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.dash-low-item a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--line, #e2e8f0);
    text-decoration: none;
    color: var(--ink, #0f172a);
}

.dash-low-item:last-child a { border-bottom: none; }
.dash-low-item a:hover { opacity: 0.8; }
.dash-low-item a strong { flex: 1; font-size: 0.88rem; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-low-item a small { color: var(--ink-muted, #64748b); }

/* AI Modal */
.dash-ai-modal {
    position: fixed;
    inset: 0;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dash-ai-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
}

.dash-ai-modal-dialog {
    position: relative;
    width: min(560px, calc(100vw - 32px));
    max-height: 85vh;
    overflow-y: auto;
    background: var(--panel);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.dash-ai-modal-body .field {
    margin-bottom: 1rem;
}

.dash-ai-result-box {
    background: var(--control-bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 1rem;
    white-space: pre-wrap;
    font-size: 0.9rem;
    line-height: 1.6;
    max-height: 300px;
    overflow-y: auto;
}

.dash-ai-loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 0;
    color: var(--ink-muted, #64748b);
}

.dash-ai-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--line);
    border-top-color: var(--pcb);
    border-radius: 50%;
    animation: dash-ai-spin 0.6s linear infinite;
}

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

/* AI inline actions in stock form */
.ai-inline-actions {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

/* Status pill */
.status-pill {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
}

.status-ok {
    background: var(--success-bg);
    color: var(--success-text);
}

.status-muted {
    background: var(--control-bg);
    color: var(--ink-muted);
}

html[data-theme="dark"] .status-ok { background: #064e3b44; color: #4ade80; }
html[data-theme="dark"] .status-muted { background: #1e293b; color: #64748b; }

/* Respect hidden attribute on modals */
[hidden] {
    display: none !important;
}

/* ===== Activity Ticker ===== */
.dash-ticker-panel .panel-header {
    margin-bottom: 0.5rem;
}

.dash-ticker {
    position: relative;
    min-height: 46px;
}

.dash-ticker-stage {
    position: relative;
    height: 40px;
    overflow: hidden;
}

.dash-ticker-item {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 1rem;
    border-radius: var(--radius-sm, 6px);
    background: var(--control-bg);
    border: 1px solid var(--line, #e2e8f0);
    text-decoration: none;
    color: var(--ink, #0f172a);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.4s ease, transform 0.4s ease;
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
}

.dash-ticker-item.active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.dash-ticker-text {
    flex: 1;
    font-size: 0.88rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.dash-ticker-amount {
    font-weight: 700;
    font-size: 0.88rem;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.dash-ticker-date {
    font-size: 0.75rem;
    color: var(--ink-muted, #64748b);
    white-space: nowrap;
}

.dash-ticker-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 0.6rem;
}

.dash-ticker-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    border: none;
    background: var(--line, #cbd5e1);
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    padding: 0;
}

.dash-ticker-dot.active {
    background: var(--pcb);
    transform: scale(1.4);
}

.dash-ticker-dot:hover {
    background: var(--pcb);
}
