/* ExStok — Modern tema */
:root {
    --sidebar-width: 268px;
    --sidebar-bg: #0f172a;
    --sidebar-bg-hover: rgba(255, 255, 255, 0.06);
    --sidebar-active: rgba(99, 102, 241, 0.22);
    --sidebar-active-border: #818cf8;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #f8fafc;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --surface: #ffffff;
    --surface-muted: #f1f5f9;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-muted: #64748b;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
    --font: 'Inter', system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body.app-body {
    margin: 0;
    font-family: var(--font);
    font-size: 0.9375rem;
    color: var(--text);
    background: var(--surface-muted);
    -webkit-font-smoothing: antialiased;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

/* —— Sidebar —— */
.app-sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    transition: transform 0.25s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.sidebar-brand {
    flex-shrink: 0;
    padding: 1rem 1rem 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: inherit;
}

.brand-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--accent) 0%, #8b5cf6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: #fff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.brand-name {
    font-weight: 700;
    font-size: 1.125rem;
    color: #f8fafc;
    letter-spacing: -0.02em;
}

.brand-tagline {
    font-size: 0.7rem;
    color: var(--sidebar-text);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.sidebar-nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem 0.5rem 0.75rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.5) rgba(15, 23, 42, 0.3);
    -webkit-overflow-scrolling: touch;
}

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.35);
    border-radius: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.55);
}

.sidebar-section {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #475569;
    padding: 0.65rem 0.65rem 0.25rem;
    margin-top: 0.15rem;
}

.sidebar-section:first-child {
    margin-top: 0;
    padding-top: 0.25rem;
}

.sidebar-item {
    margin-bottom: 2px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.65rem;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
    border-left: 3px solid transparent;
}

.sidebar-link i {
    font-size: 1.1rem;
    width: 1.25rem;
    text-align: center;
    opacity: 0.85;
}

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

.sidebar-link.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
    border-left-color: var(--sidebar-active-border);
}

.sidebar-link.active i {
    color: #a5b4fc;
}

.sidebar-footer {
    flex-shrink: 0;
    padding: 0.75rem 0.65rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: var(--sidebar-bg);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0.25rem 0.75rem;
}

.sidebar-user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar-user-info .name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-info .role {
    font-size: 0.7rem;
    color: var(--sidebar-text);
}

.logout-link {
    margin-top: 0.25rem;
}

.logout-link:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}

/* —— Main area —— */
.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 1020;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.app-topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    text-decoration: none;
    color: inherit;
    flex-shrink: 0;
}

.topbar-brand .brand-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--accent) 0%, #8b5cf6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #fff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.topbar-brand .brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.topbar-brand .brand-name {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
    color: var(--text);
}

.topbar-brand .brand-tagline {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.app-topnav {
    padding: 0 1rem 0.5rem;
}

.app-topnav .nav-link {
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.45rem 0.75rem;
    border-radius: var(--radius-sm);
}

.app-topnav .nav-link:hover,
.app-topnav .nav-link.active {
    color: var(--accent);
    background: rgba(99, 102, 241, 0.08);
}

.app-topnav .dropdown-menu {
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    border-radius: var(--radius-sm);
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    letter-spacing: -0.02em;
    color: var(--text);
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem 0.35rem 0.35rem;
    background: var(--surface-muted);
    border-radius: 999px;
    border: 1px solid var(--border);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-avatar.sm {
    width: 36px;
    height: 36px;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.user-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.user-name {
    font-size: 0.8125rem;
    font-weight: 600;
}

.user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}

.btn-ghost {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
}

.btn-ghost:hover {
    background: var(--surface-muted);
    color: var(--text);
}

.app-content {
    padding: 1.5rem;
    flex: 1;
}

/* —— Global UI polish —— */
.app-content h2 {
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.app-content .table {
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.app-content .table thead th {
    background: var(--surface-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
}

.app-content .table tbody td {
    padding: 0.85rem 1rem;
    vertical-align: middle;
}

.app-content .bg-white,
.app-content form.bg-white {
    background: var(--surface) !important;
    border: 1px solid var(--border);
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow-sm);
}

.app-content .btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    font-weight: 500;
    border-radius: var(--radius-sm);
    padding: 0.45rem 1rem;
}

.app-content .btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.app-content .btn-outline-primary {
    border-color: var(--accent);
    color: var(--accent);
    border-radius: var(--radius-sm);
}

.app-content .btn-outline-primary:hover {
    background: var(--accent);
    border-color: var(--accent);
}

.app-content .card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.app-content .card-header {
    background: var(--surface-muted);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 0.875rem;
}

.app-content .card.border-primary {
    border-color: var(--accent) !important;
}

.app-content .card-header.bg-primary {
    background: var(--accent) !important;
    border: none;
}

.app-content .form-control,
.app-content .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border);
    font-size: 0.875rem;
}

.app-content .form-control:focus,
.app-content .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.app-content .alert {
    border-radius: var(--radius-sm);
    border: none;
    box-shadow: var(--shadow-sm);
}

.app-content .list-group-item {
    border-color: var(--border);
}

#serial-scan-list {
    max-height: 280px;
    overflow-y: auto;
}

.max-h-300 {
    max-height: 300px;
    overflow-y: auto;
}

/* —— Auth —— */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #312e81 100%);
    font-family: var(--font);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.auth-brand {
    text-align: center;
    margin-bottom: 1.75rem;
}

.auth-brand .brand-icon {
    margin: 0 auto 1rem;
}

.auth-brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.02em;
}

.auth-brand p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin: 0.25rem 0 0;
}

/* —— Dashboard —— */
.stat-card {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    box-shadow: var(--shadow-sm);
    height: 100%;
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}

.stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.dashboard-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.dashboard-card .card-header {
    background: var(--surface);
    font-weight: 600;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
}

.dashboard-table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-weight: 600;
}

.stat-card-alert {
    border-color: rgba(239, 68, 68, 0.35);
    background: linear-gradient(135deg, #fff 0%, #fef2f2 100%);
}

.stat-card-link {
    color: inherit;
    text-decoration: none;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.stat-card-link:hover {
    color: inherit;
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

#low-stock {
    scroll-margin-top: 5.5rem;
}

.dashboard-card-alert {
    border-color: rgba(239, 68, 68, 0.35);
}

.dashboard-card-alert .card-header {
    background: #fef2f2;
    color: #991b1b;
}

.dashboard-card-alert .card-footer {
    background: #fff;
    border-top: 1px solid var(--border);
}

.dashboard-page canvas {
    max-height: 260px;
}

/* —— Topbar search —— */
.topbar-search {
    flex: 1;
    max-width: 320px;
    min-width: 160px;
}

.topbar-search .form-control {
    border-radius: 999px;
}

/* —— Serial timeline —— */
.serial-timeline {
    border-left: 2px solid var(--border);
    margin-left: 0.5rem;
    padding-left: 1.25rem;
}

.serial-timeline-item {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    position: relative;
}

.serial-timeline-item::before {
    content: '';
    position: absolute;
    left: -1.42rem;
    top: 0.35rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px var(--accent);
}

.serial-timeline-icon {
    display: none;
}

/* —— Print labels —— */
.label-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.serial-label {
    border: 1px dashed #333;
    padding: 8px 10px;
    min-height: 90px;
    page-break-inside: avoid;
}

.serial-label-product {
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
}

.serial-label-sku {
    font-size: 10px;
    color: #555;
}

.serial-label-code {
    font-size: 16px;
    font-weight: 700;
    font-family: monospace;
    margin: 6px 0 4px;
    letter-spacing: 0.05em;
}

.serial-label-meta {
    font-size: 9px;
    color: #777;
}

@media (max-width: 767.98px) {
    .label-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* —— Mobile scan mode —— */
@media (max-width: 991.98px) {
    body.has-scan-panel .scan-panel {
        position: sticky;
        top: 0;
        z-index: 100;
        box-shadow: var(--shadow);
    }

    body.has-scan-panel .scan-input {
        font-size: 1.25rem;
        min-height: 3rem;
    }

    body.has-scan-panel .app-content {
        padding-bottom: 2rem;
    }
}

.max-h-300 {
    max-height: 300px;
    overflow-y: auto;
}

/* —— Mobile —— */
.sidebar-backdrop {
    display: none;
}

/* —— Warehouse PWA mode —— */
body.warehouse-mode-body {
    background: #0f172a;
}

.warehouse-mode-header {
    position: sticky;
    top: 0;
    z-index: 200;
    background: linear-gradient(135deg, #0f172a, #1e293b);
    color: #f8fafc;
    padding: max(0.75rem, env(safe-area-inset-top)) 1rem 0.75rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.warehouse-brand {
    color: #f8fafc;
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.warehouse-page-title {
    font-size: 1.1rem;
    margin: 0.5rem 0 0;
    font-weight: 600;
}

.warehouse-mode-content {
    padding: 1rem;
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
    min-height: calc(100dvh - 72px);
}

.warehouse-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

@media (min-width: 576px) {
    .warehouse-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.warehouse-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 7.5rem;
    padding: 1rem;
    background: #fff;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.warehouse-tile:active {
    transform: scale(0.97);
}

.warehouse-tile-icon {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background: rgba(99, 102, 241, 0.12);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.warehouse-tile-label {
    font-weight: 600;
    font-size: 0.9rem;
    text-align: center;
}

.warehouse-fab {
    position: fixed;
    right: 1rem;
    bottom: max(1rem, env(safe-area-inset-bottom));
    z-index: 300;
    border-radius: 50%;
    width: 3rem;
    height: 3rem;
    padding: 0;
    box-shadow: var(--shadow);
}

body.warehouse-mode-body .scan-panel {
    border: none;
    box-shadow: var(--shadow);
}

body.warehouse-mode-body .scan-input {
    font-size: 1.35rem !important;
    min-height: 3.25rem !important;
}

body.warehouse-mode-body .scan-panel .btn-lg {
    min-height: 3.25rem;
    font-size: 1.1rem;
}

body.warehouse-mode-body .scan-panel {
    position: sticky;
    top: 0.5rem;
    z-index: 100;
}

.scan-flash-ok {
    animation: scanFlashOk 0.4s ease;
}

.scan-flash-err {
    animation: scanFlashErr 0.5s ease;
}

@keyframes scanFlashOk {
    0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); }
    100% { box-shadow: 0 0 0 12px rgba(34, 197, 94, 0); }
}

@keyframes scanFlashErr {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-4px); }
    40%, 80% { transform: translateX(4px); }
}

/* Ürün canlı arama (product-search.js) */
.product-search-wrap {
    width: 100%;
}

select.product-search-native {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.product-search-input::-webkit-search-cancel-button {
    cursor: pointer;
}

.product-search-dropdown {
    max-height: 280px;
    overflow-y: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface, #fff);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.product-search-dropdown--floating {
    position: fixed;
    z-index: 1060;
}

.product-search-dropdown .list-group-item {
    font-size: 0.875rem;
    border-left: 0;
    border-right: 0;
}

.product-search-dropdown .list-group-item:first-child {
    border-top: 0;
}

.product-search-dropdown .list-group-item-action.active {
    background-color: rgba(99, 102, 241, 0.12);
    color: var(--text);
}
