/* ClickR — Admin Dashboard
   Design System: Linear.app adapted for ClickR
   All colors reference design-system.css tokens */

/* === Status Badges === */
.status-badge {
    font-size: 0.8rem;
}

/* === Stat Cards (base transition) === */
.stat-card {
    transition: box-shadow var(--transition-fast);
}

/* === Flash Messages === */
.flash-message {
    animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* === Tables === */
.table th {
    white-space: nowrap;
}

/* === Order History === */
.sort-link { text-decoration: none; color: inherit; }
.sort-link:hover { color: var(--accent); }
.sort-indicator { font-size: 0.7rem; }

/* === Error Trace === */
.error-trace {
    max-height: 400px;
    overflow-y: auto;
    font-size: 0.85rem;
}

/* === Sidebar === */
.sidebar {
    width: 240px;
    background-color: var(--bg-sidebar) !important;
    background: var(--bg-sidebar) !important;
    --bs-offcanvas-bg: var(--bg-sidebar);
    z-index: 1045;
    overflow-y: auto;
    padding: 0;
    border-right: none !important;
    box-shadow: 1px 0 4px rgba(0, 0, 0, 0.08);
}

.sidebar.offcanvas-lg,
.sidebar.offcanvas {
    background-color: var(--bg-sidebar) !important;
    --bs-offcanvas-bg: var(--bg-sidebar);
}

.sidebar-brand {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--border-default);
    margin-bottom: 0.5rem;
    color: var(--text-primary) !important;
}

.sidebar-brand a,
.sidebar-brand span,
.sidebar-brand p,
.sidebar-brand small,
.sidebar-brand .navbar-brand-subtitle {
    color: var(--text-tertiary) !important;
}

.sidebar-brand .fw-semibold,
.sidebar-brand strong {
    color: var(--text-primary) !important;
}

.sidebar-nav {
    list-style: none;
    padding: 0 0.5rem;
    margin: 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.6rem 0.875rem;
    border-radius: var(--radius-lg);
    color: var(--text-secondary) !important;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: var(--fw-medium);
    margin-bottom: 2px;
    transition: all var(--transition-fast);
}

.sidebar-link i {
    font-size: 1rem;
    opacity: 0.85;
}

.sidebar-link:hover {
    background: var(--bg-hover) !important;
    color: var(--text-primary) !important;
}

.sidebar-link.active {
    background: var(--accent) !important;
    color: #ffffff !important;
    font-weight: var(--fw-semibold);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-default);
    font-size: 0.8rem;
    color: var(--text-quaternary) !important;
}

.sidebar-footer a {
    color: var(--text-tertiary) !important;
}

.sidebar-footer a:hover {
    color: var(--text-primary) !important;
}

/* Main content layout */
.main-content {
    margin-left: 240px;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-content .container-fluid {
    flex: 1;
}

.clickr-mobile-header {
    background: var(--bg-sidebar);
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

@media (max-width: 991.98px) {
    .sidebar {
        width: 280px;
    }
    .main-content {
        margin-left: 0;
    }
}

@media (min-width: 992px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        display: flex;
        flex-direction: column;
    }
}

/* === Login === */
.login-page .main-content {
    margin-left: 0 !important;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-page .main-content .container-fluid {
    flex: unset;
    padding: 0;
}

.login-container {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    padding: 1rem;
}

/* === Onboarding Wizard === */
.wizard-progress { margin-bottom: 1.5rem; }
.wizard-step-label { font-size: 0.75rem; text-align: center; flex: 1; }
.wizard-step-label.active { font-weight: var(--fw-bold); color: var(--accent); }
.wizard-step-label.completed { color: var(--color-success); }
.connection-status {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
}
.connection-status.success { background-color: var(--color-success-muted); color: var(--color-success); }
.connection-status.error { background-color: var(--color-danger-muted); color: var(--color-danger); }

/* === ClickR Branding === */
.clickr-logo-login {
    max-height: 80px;
    width: auto;
}

/* Footer */
footer.clickr-footer,
.clickr-footer {
    background: transparent;
    text-align: center;
    padding: 1rem;
    color: var(--text-quaternary);
    font-size: 0.8rem;
}

.clickr-footer a {
    color: var(--text-quaternary);
    text-decoration: none;
}

.clickr-footer a:hover {
    color: var(--accent);
}

/* === Page Titles === */
.page-header {
    padding: 1.5rem 0 1rem;
    margin-bottom: 1.5rem;
}

.main-content h1 {
    font-size: 1.5rem;
    font-weight: var(--fw-bold);
    color: var(--text-primary);
    margin-bottom: 0;
}

h1.page-title, .page-title {
    font-size: 1.5rem;
    font-weight: var(--fw-bold);
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-solid);
    padding-bottom: 0.75rem;
    margin-bottom: 1.5rem;
}

/* === Stat Cards (Dashboard) === */
.stat-card {
    position: relative;
    overflow: hidden;
}

.stat-card--orders  { border-left: 3px solid var(--accent) !important; }
.stat-card--success { border-left: 3px solid var(--color-success) !important; }
.stat-card--failed  { border-left: 3px solid var(--color-danger) !important; }
.stat-card--errors  { border-left: 3px solid var(--color-warning) !important; }

.stat-card .stat-icon {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    font-size: 2rem;
    opacity: 0.2;
}

.stat-card--orders .stat-icon  { color: var(--accent); }
.stat-card--success .stat-icon { color: var(--color-success); }
.stat-card--failed .stat-icon  { color: var(--color-danger); }
.stat-card--errors .stat-icon  { color: var(--color-warning); }

.stat-card .stat-label {
    font-size: 0.8rem;
    font-weight: var(--fw-medium);
    color: var(--text-tertiary);
    margin-bottom: 0.25rem;
}

.stat-card .stat-value {
    font-size: 2.5rem;
    font-weight: var(--fw-bold);
    line-height: 1.2;
    color: var(--text-primary);
}

.stat-card .stat-subtitle {
    font-size: 0.75rem;
    color: var(--text-quaternary);
    margin-top: 0.125rem;
}

.stat-card:hover {
    box-shadow: var(--shadow-elevated) !important;
}

/* === Success Rate Card === */
.success-rate-card {
    background: var(--bg-surface);
}

.success-rate-card .store-pill {
    display: inline-block;
    font-size: 0.8rem;
    color: var(--text-tertiary);
    background: var(--bg-surface-elevated);
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-md);
}

/* === Manage Stores Button === */
.btn-manage-stores {
    background-color: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn-manage-stores:hover {
    background-color: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #fff;
}

/* === Empty State (tables) === */
.dashboard-empty-state {
    padding: 2.5rem 1rem;
    text-align: center;
}

.dashboard-empty-state .empty-icon {
    font-size: 2rem;
    color: var(--text-quaternary);
    margin-bottom: 0.5rem;
}

.dashboard-empty-state .empty-title {
    font-size: 0.95rem;
    font-weight: var(--fw-semibold);
    color: var(--text-tertiary);
}

.dashboard-empty-state .empty-subtitle {
    font-size: 0.8rem;
    color: var(--text-quaternary);
}

/* =============================================
   Codex5 Global Overrides
   ============================================= */

/* Border-radius: cap at 8px globally */
.card,
.btn,
.form-control,
.form-select,
.badge,
.alert,
.modal-content,
.dropdown-menu {
    border-radius: var(--radius-lg) !important;
}

.btn-group > .btn:not(:first-child):not(:last-child) { border-radius: 0 !important; }
.btn-group > .btn:first-child:not(:last-child) { border-radius: var(--radius-lg) 0 0 var(--radius-lg) !important; }
.btn-group > .btn:last-child:not(:first-child) { border-radius: 0 var(--radius-lg) var(--radius-lg) 0 !important; }
.btn-group > .btn:only-child { border-radius: var(--radius-lg) !important; }
.input-group > .form-control:first-child { border-radius: var(--radius-lg) 0 0 var(--radius-lg) !important; }
.input-group > .btn:last-child { border-radius: 0 var(--radius-lg) var(--radius-lg) 0 !important; }

/* Shadows: subtle only */
.card,
.shadow,
.dropdown-menu {
    box-shadow: var(--shadow-card) !important;
}

/* Transitions: 150ms, color/opacity only */
.btn,
.badge,
.nav-link,
a,
.form-control,
.form-select {
    transition: color var(--transition-fast), background-color var(--transition-fast),
                border-color var(--transition-fast), opacity var(--transition-fast) !important;
}

/* Table thead */
.table thead th {
    background-color: transparent !important;
    border-bottom: 2px solid var(--border-solid-light) !important;
    font-weight: var(--fw-semibold);
    font-size: 0.8rem;
    text-transform: none;
    letter-spacing: 0;
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
    color: var(--text-tertiary);
}

/* Override table-light & table-dark on thead */
.table thead.table-light,
.table thead.table-dark {
    --bs-table-bg: transparent !important;
    --bs-table-color: inherit !important;
    background-color: transparent !important;
    color: inherit !important;
}

.table thead.table-light th,
.table thead.table-dark th {
    background-color: transparent !important;
    color: inherit !important;
}

/* Disable zebra stripes */
.table-striped > tbody > tr:nth-of-type(odd) > * {
    --bs-table-bg-type: transparent !important;
}

/* Table rows: subtle hover (dark mode) */
[data-bs-theme="dark"] .table-hover > tbody > tr:hover > * {
    --bs-table-bg-state: rgba(255, 255, 255, 0.02) !important;
}

/* Badges: clean, small, no uppercase */
.badge {
    border-radius: var(--radius-md) !important;
    font-weight: var(--fw-medium);
    font-size: 0.75rem;
    text-transform: none;
    letter-spacing: 0;
    padding: 0.25em 0.55em;
}

/* Neutralize colored card borders */
.card.border-primary:not(.stat-card),
.card.border-success:not(.stat-card),
.card.border-danger:not(.stat-card),
.card.border-warning:not(.stat-card),
.card.border-info:not(.stat-card),
.card.border-secondary:not(.stat-card) {
    border-color: var(--border-default) !important;
}

/* Cards: clean border */
.card {
    border: 1px solid var(--border-default);
}

/* Card headers */
.card-header {
    background-color: var(--bg-card-header);
    border-bottom: 1px solid var(--border-subtle);
    font-weight: var(--fw-semibold);
    font-size: 0.875rem;
    color: var(--text-primary);
}

/* Cap oversized icons in card bodies */
.card-body .fs-1 { font-size: 1.25rem !important; }
.card-body .fs-2 { font-size: 1.125rem !important; }

/* Cap oversized badges */
.badge.fs-6 { font-size: 0.75rem !important; }

/* btn-lg: normalize */
.btn-lg {
    padding: 0.375rem 0.75rem !important;
    font-size: 1rem !important;
    border-radius: var(--radius-lg) !important;
}

/* Login card */
.login-container .card {
    box-shadow: none !important;
    border: 1px solid var(--border-default);
}

/* === Reports === */
.kpi-delta-positive { color: var(--color-success); font-size: 0.8rem; }
.kpi-delta-negative { color: var(--color-danger); font-size: 0.8rem; }
.kpi-delta-neutral { color: var(--text-tertiary); font-size: 0.8rem; }
.period-btn.active { font-weight: var(--fw-semibold); }
.heatmap-grid { display: grid; grid-template-columns: auto repeat(24, 1fr); gap: 2px; font-size: 0.7rem; }
.heatmap-cell { width: 100%; aspect-ratio: 1; border-radius: 3px; display: flex; align-items: center; justify-content: center; }
.heatmap-label { font-weight: var(--fw-medium); display: flex; align-items: center; padding-right: 0.25rem; }
.loading-spinner { text-align: center; padding: 2rem; color: var(--text-tertiary); }
.empty-state { text-align: center; color: var(--text-tertiary); padding: 2rem; }
.kpi-value { font-size: 1.5rem; font-weight: var(--fw-bold); margin-bottom: 0.25rem; color: var(--text-primary); }

/* === CSS Donut Ring (Success Rate) === */
.donut-ring {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    display: inline-block;
}

.donut-ring-inner {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--bg-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px;
}

.donut-ring-inner .donut-value {
    font-size: 1.5rem;
    font-weight: var(--fw-bold);
    line-height: 1;
    color: var(--text-primary);
}

.donut-ring-inner .donut-label {
    font-size: 0.7rem;
    color: var(--text-quaternary);
}

/* === Rich Empty State === */
.rich-empty-state {
    padding: 3rem 1.5rem;
    text-align: center;
}

.rich-empty-state .empty-icon-lg {
    font-size: 3rem;
    color: var(--text-quaternary);
    margin-bottom: 0.75rem;
}

.rich-empty-state .empty-title-lg {
    font-size: 1.1rem;
    font-weight: var(--fw-semibold);
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.rich-empty-state .empty-subtitle-lg {
    font-size: 0.875rem;
    color: var(--text-quaternary);
    margin-bottom: 1rem;
}

/* === Clickable Table Rows === */
.table-clickable tbody tr {
    cursor: pointer;
}

/* === Skeleton Shimmer === */
@keyframes shimmer {
    0% { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}

.skeleton-row {
    height: 1.5rem;
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-surface-elevated) 50%, var(--bg-surface) 75%);
    background-size: 800px 100%;
    animation: shimmer 1.5s infinite linear;
    margin-bottom: 0.5rem;
}

.skeleton-row:last-child {
    margin-bottom: 0;
}

/* === Chart Placeholder === */
.chart-placeholder {
    border: 2px dashed var(--border-solid-light);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
    color: var(--text-quaternary);
}

.chart-placeholder svg {
    display: block;
    margin: 0 auto 0.75rem;
}

/* === Status Dots (Live Status) === */
.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-dot--ok      { background-color: var(--color-success); }
.status-dot--down    { background-color: var(--color-danger); }
.status-dot--warning { background-color: var(--color-warning); }

/* === Overall Status Banner === */
.status-banner-ok {
    background-color: var(--color-success-muted);
    color: var(--color-success);
}

/* === Monitoring Timestamp === */
.monitoring-timestamp {
    font-size: 0.8rem;
    color: var(--text-quaternary);
}

/* === Clickable Alert Badges === */
.alert-badge-clickable {
    cursor: pointer;
    transition: opacity var(--transition-fast);
}
.alert-badge-clickable:hover {
    opacity: 0.8;
}

/* === Wizard Step Counter === */
.wizard-step-counter {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    font-weight: var(--fw-medium);
}

/* Table overflow prevention */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
