/* Modern UI — design tokens, tables, filters, command palette */

:root {
    --ui-bg: #f1f5f9;
    --ui-surface: #ffffff;
    --ui-surface-2: #f8fafc;
    --ui-border: #e2e8f0;
    --ui-border-soft: #eef2f6;
    --ui-text: #0f172a;
    --ui-text-muted: #64748b;
    --ui-text-subtle: #94a3b8;
    --ui-primary: #2563eb;
    --ui-success: #16a34a;
    --ui-warning: #ea580c;
    --ui-danger: #dc2626;
    --ui-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --ui-shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
    --ui-radius: 0.75rem;
}

.theme-dark {
    --ui-bg: #0b1120;
    --ui-surface: #1e293b;
    --ui-surface-2: #0f172a;
    --ui-border: #334155;
    --ui-border-soft: #1e293b;
    --ui-text: #f1f5f9;
    --ui-text-muted: #94a3b8;
    --ui-text-subtle: #64748b;
    --ui-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    --ui-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.app-body { background: var(--ui-bg); color: var(--ui-text); }

/* Breadcrumb + status bar */
.app-subheader {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    padding: 0.375rem 1rem;
    background: var(--ui-surface);
    border-bottom: 1px solid var(--ui-border);
    min-height: 2rem;
}
@media (min-width: 768px) { .app-subheader { padding: 0.375rem 1.25rem; } }
.app-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.6875rem;
    color: var(--ui-text-subtle);
    min-width: 0;
}
.app-breadcrumb__sep { opacity: 0.5; }
.app-breadcrumb__current { color: var(--ui-text-muted); font-weight: 600; }
.app-status-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.625rem;
    color: var(--ui-text-subtle);
}
.app-status-item {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}
.app-status-dot {
    width: 0.4375rem;
    height: 0.4375rem;
    border-radius: 9999px;
    background: #94a3b8;
}
.app-status-dot--ok { background: #22c55e; }
.app-status-dot--warn { background: #f59e0b; }
.app-status-dot--err { background: #ef4444; }

/* Collapsible sidebar */
.app-shell.sidebar-collapsed { --app-sidebar-w: 4.25rem; }
.app-shell.sidebar-collapsed .app-sidebar__title,
.app-shell.sidebar-collapsed .app-sidebar__tenant,
.app-shell.sidebar-collapsed .nav-group-label span:not(.nav-icon),
.app-shell.sidebar-collapsed .nav-item-inner,
.app-shell.sidebar-collapsed .nav-sub-item,
.app-shell.sidebar-collapsed .nav-chevron,
.app-shell.sidebar-collapsed .nav-section-label {
    opacity: 0;
    width: 0;
    overflow: hidden;
    white-space: nowrap;
}
.app-shell.sidebar-collapsed .nav-group-label,
.app-shell.sidebar-collapsed .nav-item-inner {
    justify-content: center;
}
.app-shell.sidebar-collapsed .nav-group-items { display: none !important; }
.app-sidebar__collapse-btn {
    margin-left: auto;
    width: 1.75rem;
    height: 1.75rem;
    border: none;
    background: rgba(255,255,255,0.08);
    border-radius: 0.375rem;
    color: #94a3b8;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
@media (min-width: 1024px) {
    .app-sidebar__collapse-btn { display: inline-flex; }
}

/* Search trigger */
.app-search-trigger {
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    min-width: 2.125rem;
    max-width: 12rem;
    flex: 0 1 10rem;
    font-size: 0.75rem;
    color: var(--ui-text-subtle);
    background: var(--ui-surface-2);
    border: 1px solid var(--ui-border);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    overflow: hidden;
    white-space: nowrap;
}
.app-search-trigger:hover { border-color: #cbd5e1; box-shadow: var(--ui-shadow); }
.app-search-trigger span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.app-search-trigger kbd {
    margin-left: auto;
    font-size: 0.625rem;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    background: var(--ui-surface);
    border: 1px solid var(--ui-border);
    font-family: inherit;
    flex-shrink: 0;
}
@media (min-width: 768px) { .app-search-trigger { display: inline-flex; } }
.app-search-trigger.hidden { display: none !important; }

/* Stat cards v2 */
.stat-card-v2 {
    position: relative;
    background: var(--ui-surface);
    border: 1px solid var(--ui-border-soft);
    border-radius: var(--ui-radius);
    padding: 1rem 1.125rem;
    box-shadow: var(--ui-shadow);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    cursor: pointer;
    text-align: left;
    overflow: hidden;
}
.stat-card-v2:hover {
    transform: translateY(-2px);
    box-shadow: var(--ui-shadow-md);
    border-color: #bfdbfe;
}
.stat-card-v2::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--stat-accent, #2563eb), transparent);
    opacity: 0.85;
}
.stat-card-v2--blue { --stat-accent: #2563eb; }
.stat-card-v2--orange { --stat-accent: #ea580c; }
.stat-card-v2--green { --stat-accent: #16a34a; }
.stat-card-v2--slate { --stat-accent: #64748b; }
.stat-card-v2--amber { --stat-accent: #d97706; }
.stat-card-v2--teal { --stat-accent: #0d9488; }
.stat-card-v2--red { --stat-accent: #dc2626; }
.stat-card-v2__row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}
.stat-card-v2__icon {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.625rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: color-mix(in srgb, var(--stat-accent) 12%, transparent);
    color: var(--stat-accent);
}
.stat-card-v2__icon svg { width: 1.125rem; height: 1.125rem; }
.stat-card-v2__label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ui-text-subtle);
}
.stat-card-v2__value {
    font-size: 1.625rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--ui-text);
    line-height: 1.2;
    margin-top: 0.125rem;
}
.stat-card-v2__sub {
    font-size: 0.6875rem;
    color: var(--ui-text-muted);
    margin-top: 0.25rem;
}

/* Canlı kuyruk — yüzde halkaları ve geçiş animasyonları */
.queue-live-hero {
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.04) 0%, rgba(16, 185, 129, 0.05) 100%);
}
.queue-live-hero__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1.25rem;
    align-items: center;
    opacity: 1;
}
.queue-live-ring {
    position: relative;
    width: 5.5rem;
    height: 5.5rem;
    margin: 0 auto;
}
.queue-live-ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}
.queue-live-ring__track {
    fill: none;
    stroke: var(--ui-border-soft, #e2e8f0);
    stroke-width: 6;
}
.queue-live-ring__fill {
    fill: none;
    stroke: var(--ring-color, #2563eb);
    stroke-width: 6;
    stroke-linecap: round;
    stroke-dasharray: 283;
    stroke-dashoffset: calc(283 - (283 * var(--pct, 0) / 100));
    transition: stroke-dashoffset 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}
.queue-live-ring__value {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--ui-text);
    line-height: 1.1;
}
.queue-live-ring__value small {
    font-size: 0.625rem;
    font-weight: 500;
    color: var(--ui-text-muted);
}
.queue-live-hero__label {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--ui-text-muted);
    margin-top: 0.5rem;
}
.queue-live-hero__sub {
    text-align: center;
    font-size: 0.6875rem;
    color: var(--ui-text-muted);
    margin-top: 0.125rem;
}
.queue-live-intro {
    animation: queueLiveFadeIn 0.5s ease-out forwards;
}
.queue-live-section {
    animation: queueLiveFadeIn 0.45s ease-out both;
}
.queue-live-section:nth-child(2) { animation-delay: 0.06s; }
.queue-live-section:nth-child(3) { animation-delay: 0.12s; }
.queue-live-section:nth-child(4) { animation-delay: 0.18s; }
@keyframes queueLiveFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.queue-progress {
    margin-top: 0.75rem;
}
.queue-progress__head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.375rem;
}
.queue-progress__pct {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--ui-text);
    font-variant-numeric: tabular-nums;
    transition: color 0.3s ease;
}
.queue-progress__pct--active { color: #059669; }
.queue-progress__meta {
    font-size: 0.75rem;
    color: var(--ui-text-muted);
}
.queue-progress__track {
    height: 0.625rem;
    background: var(--ui-border-soft, #f1f5f9);
    border-radius: 9999px;
    overflow: hidden;
}
.queue-progress__track--lg { height: 0.875rem; }
.queue-progress__fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #2563eb, #059669);
    width: 0%;
    transition: width 0.65s cubic-bezier(0.4, 0, 0.2, 1);
}
.queue-progress__fill--indeterminate {
    width: 40% !important;
    animation: queueProgressIndeterminate 1.4s ease-in-out infinite;
}
@keyframes queueProgressIndeterminate {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}
.queue-job-card {
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}
.queue-job-card--running {
    animation: queueJobPulse 2.5s ease-in-out infinite;
}
@keyframes queueJobPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.15); }
    50% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
}
.queue-live-ring--pulse .queue-live-ring__fill {
    animation: queueRingPulse 1.6s ease-in-out infinite;
}
@keyframes queueRingPulse {
    0%, 100% { stroke-dashoffset: 283; opacity: 0.35; }
    50% { stroke-dashoffset: 200; opacity: 1; }
}
.queue-live-panel--refresh .queue-progress__fill {
    transition-duration: 0.4s;
}
.queue-live-row--new td {
    animation: queueLiveRowIn 2s ease-out;
}
.queue-pipeline {
    padding: 0.5rem 0;
}
.queue-pipeline__item {
    display: grid;
    grid-template-columns: 2.5rem 1fr;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgb(241 245 249);
    align-items: start;
}
.queue-pipeline__item:last-child {
    border-bottom: none;
}
.queue-pipeline__item--running {
    background: linear-gradient(90deg, rgb(236 253 245 / 0.9), rgb(255 255 255));
    border-left: 3px solid rgb(16 185 129);
}
.queue-pipeline__item--pending {
    opacity: 0.85;
}
.queue-pipeline__item--done {
    background: rgb(248 250 252 / 0.6);
}
.queue-pipeline__item--error {
    background: rgb(254 242 242 / 0.5);
    border-left: 3px solid rgb(248 113 113);
}
.queue-pipeline__marker {
    width: 2rem;
    height: 2rem;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 0.125rem;
}
.queue-pipeline__item--done .queue-pipeline__marker {
    background: rgb(220 252 231);
    color: rgb(21 128 61);
}
.queue-pipeline__item--running .queue-pipeline__marker {
    background: rgb(16 185 129);
    color: white;
    animation: queuePipelinePulse 1.5s ease-in-out infinite;
}
.queue-pipeline__item--pending .queue-pipeline__marker {
    background: rgb(241 245 249);
    color: rgb(100 116 139);
    border: 2px dashed rgb(203 213 225);
}
.queue-pipeline__item--error .queue-pipeline__marker {
    background: rgb(254 226 226);
    color: rgb(185 28 28);
}
@keyframes queuePipelinePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
}
.queue-pipeline__title {
    font-weight: 600;
    font-size: 0.875rem;
    color: rgb(30 41 59);
}
.queue-pipeline__meta {
    font-size: 0.75rem;
    color: rgb(100 116 139);
    margin-top: 0.125rem;
}
.queue-pipeline__mukellef {
    font-size: 0.8125rem;
    font-weight: 600;
    color: rgb(4 120 87);
    margin-top: 0.375rem;
}
.queue-live-subtabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0.35rem;
    background: rgb(248 250 252);
    border: 1px solid rgb(226 232 240);
    border-radius: 0.75rem;
    position: sticky;
    top: 0;
    z-index: 20;
}
.queue-live-subtab {
    padding: 0.5rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: rgb(71 85 105);
    border-radius: 0.5rem;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.queue-live-subtab:hover {
    background: rgb(255 255 255);
    color: rgb(15 23 42);
}
.queue-live-subtab--active {
    background: rgb(255 255 255);
    color: rgb(15 23 42);
    border-color: rgb(203 213 225);
    box-shadow: 0 1px 2px rgb(15 23 42 / 0.06);
}
.queue-live-subtab__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.35rem;
    margin-left: 0.35rem;
    font-size: 0.6875rem;
    font-weight: 700;
    border-radius: 9999px;
    background: rgb(226 232 240);
    color: rgb(51 65 85);
    vertical-align: middle;
}
.queue-live-subtab--active .queue-live-subtab__badge {
    background: rgb(219 234 254);
    color: rgb(29 78 216);
}
.queue-live-subtab__badge--live {
    background: rgb(209 250 229);
    color: rgb(4 120 87);
    animation: queuePipelinePulse 1.5s ease-in-out infinite;
}
.queue-live-panel {
    animation: queueLivePanelIn 0.2s ease-out;
}
@keyframes queueLivePanelIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes queueLiveRowIn {
    0% { background-color: rgba(16, 185, 129, 0.28); }
    100% { background-color: transparent; }
}

/* Modern data table */
.ui-card {
    background: var(--ui-surface);
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    box-shadow: var(--ui-shadow);
    overflow: hidden;
}
.ui-card__head {
    padding: 0.875rem 1.125rem;
    border-bottom: 1px solid var(--ui-border-soft);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ui-text);
}
.ui-table-wrap { overflow-x: auto; }
.app-content table.w-full,
.ui-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}
.app-content table.w-full thead th,
.ui-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--ui-surface-2) !important;
    color: var(--ui-text-subtle) !important;
    font-size: 0.6875rem !important;
    font-weight: 600 !important;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.625rem 0.875rem !important;
    border-bottom: 1px solid var(--ui-border) !important;
    white-space: nowrap;
}
.app-content table.w-full tbody td,
.ui-table tbody td {
    padding: 0.625rem 0.875rem !important;
    border-bottom: 1px solid var(--ui-border-soft) !important;
    color: var(--ui-text);
    vertical-align: middle;
}
.app-content table.w-full tbody tr:hover td,
.ui-table tbody tr:hover td {
    background: color-mix(in srgb, var(--ui-primary) 4%, var(--ui-surface)) !important;
}

/* Filter panel */
.ui-filter {
    background: var(--ui-surface);
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    padding: 1rem 1.125rem;
    margin-bottom: 1rem;
    box-shadow: var(--ui-shadow);
}
.ui-filter__title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ui-text);
    margin-bottom: 0.25rem;
}
.ui-filter__desc {
    font-size: 0.75rem;
    color: var(--ui-text-muted);
    margin-bottom: 0.875rem;
}

/* Empty state */
.ui-empty {
    text-align: center;
    padding: 2.5rem 1.5rem;
    color: var(--ui-text-muted);
}
.ui-empty__icon {
    width: 3rem;
    height: 3rem;
    margin: 0 auto 0.75rem;
    border-radius: 9999px;
    background: var(--ui-surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ui-text-subtle);
}
.ui-empty__title { font-size: 0.875rem; font-weight: 600; color: var(--ui-text); }
.ui-empty__text { font-size: 0.75rem; margin-top: 0.25rem; }

/* Skeleton */
@keyframes ui-shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
.ui-skeleton {
    background: linear-gradient(90deg, var(--ui-surface-2) 25%, var(--ui-border-soft) 50%, var(--ui-surface-2) 75%);
    background-size: 200% 100%;
    animation: ui-shimmer 1.4s ease infinite;
    border-radius: 0.375rem;
}
.ui-skeleton-row { height: 2.5rem; margin-bottom: 0.5rem; }
.ui-table-busy { opacity: 0.65; pointer-events: none; }

/* Command palette */
.cmdk-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 12vh 1rem 1rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.18s, visibility 0.18s;
}
.cmdk-overlay.is-open { opacity: 1; visibility: visible; }
.cmdk-panel {
    width: 100%;
    max-width: 32rem;
    background: var(--ui-surface);
    border: 1px solid var(--ui-border);
    border-radius: 1rem;
    box-shadow: var(--ui-shadow-md);
    overflow: hidden;
    transform: translateY(-8px) scale(0.98);
    transition: transform 0.18s;
}
.cmdk-overlay.is-open .cmdk-panel { transform: translateY(0) scale(1); }
.cmdk-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--ui-border-soft);
}
.cmdk-input-wrap svg { width: 1.125rem; height: 1.125rem; color: var(--ui-text-subtle); flex-shrink: 0; }
.cmdk-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 0.9375rem;
    background: transparent;
    color: var(--ui-text);
}
.cmdk-list {
    max-height: 18rem;
    overflow-y: auto;
    padding: 0.375rem;
}
.cmdk-group-label {
    padding: 0.375rem 0.625rem;
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ui-text-subtle);
}
.cmdk-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    width: 100%;
    padding: 0.5rem 0.625rem;
    border: none;
    background: transparent;
    border-radius: 0.5rem;
    cursor: pointer;
    text-align: left;
    color: var(--ui-text);
    font-size: 0.8125rem;
}
.cmdk-item:hover,
.cmdk-item.is-active { background: color-mix(in srgb, var(--ui-primary) 10%, var(--ui-surface)); }
.cmdk-item__icon {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 0.375rem;
    background: var(--ui-surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.6875rem;
    color: var(--ui-text-muted);
}
.cmdk-item__meta { font-size: 0.6875rem; color: var(--ui-text-subtle); margin-left: auto; }
.cmdk-footer {
    padding: 0.5rem 1rem;
    border-top: 1px solid var(--ui-border-soft);
    font-size: 0.625rem;
    color: var(--ui-text-subtle);
    display: flex;
    gap: 1rem;
}

/* Dark: modals & toast */
.theme-dark .modern-dialog-panel,
.theme-dark .toast {
    background: var(--ui-surface) !important;
    border-color: var(--ui-border) !important;
    color: var(--ui-text) !important;
}
.theme-dark .modern-dialog-title { color: var(--ui-text) !important; }
.theme-dark .modern-dialog-message { color: var(--ui-text-muted) !important; }
