/* ============================================================
   QUICK ERP B2B — Global base styles
   Reset, typography, shared primitives (buttons, forms, badges,
   cards, reveal animations). Page/feature specifics live in
   component-scoped .razor.css files.
   ============================================================ */

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

* {
    margin: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: var(--text-md);
    line-height: 1.55;
    color: var(--ink);
    background: var(--canvas);
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    transition: background-color var(--dur-med) var(--ease-out), color var(--dur-med) var(--ease-out);
}

img,
svg,
video {
    display: block;
    max-width: 100%;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
    text-wrap: balance;
}

::selection {
    background: var(--accent);
    color: var(--on-accent);
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-xs);
}

/* Headings receive programmatic focus after navigation (FocusOnNavigate) —
   never draw a focus ring on them */
h1:focus,
h1:focus-visible {
    outline: none;
}

/* Themed slim scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--line-strong);
    border-radius: var(--radius-pill);
    border: 2px solid var(--canvas);
}

/* ---- Layout primitives ---- */

.container {
    width: 100%;
    max-width: var(--container-max);
    margin-inline: auto;
    padding-inline: var(--container-pad);
}

.section {
    padding-block: clamp(2.5rem, 5vw, 4.5rem);
}

.section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
    flex-wrap: wrap;
}

.eyebrow {
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--accent-strong);
    display: block;
    margin-bottom: var(--space-2);
}

.section-title {
    font-size: var(--text-2xl);
    display: inline-block;
}

/* ---- Buttons ---- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 0.7rem 1.4rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: var(--text-sm);
    letter-spacing: 0.02em;
    cursor: pointer;
    background: transparent;
    transition: background-color var(--dur-fast) var(--ease-out),
                color var(--dur-fast) var(--ease-out),
                border-color var(--dur-fast) var(--ease-out),
                box-shadow var(--dur-fast) var(--ease-out),
                transform var(--dur-fast) var(--ease-out);
    user-select: none;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.btn--primary {
    background: var(--primary);
    color: var(--on-primary);
}

.btn--primary:hover:not(:disabled) {
    background: var(--primary-strong);
    box-shadow: var(--shadow-md);
}

.btn--accent {
    background: var(--accent);
    color: var(--on-accent);
}

.btn--accent:hover:not(:disabled) {
    background: var(--accent-strong);
    box-shadow: var(--shadow-md);
}

.btn--outline {
    border-color: var(--line-strong);
    color: var(--ink);
}

.btn--outline:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-soft);
}

.btn--ghost {
    color: var(--ink-soft);
}

.btn--ghost:hover:not(:disabled) {
    background: var(--surface-2);
    color: var(--ink);
}

.btn--danger {
    background: var(--danger);
    color: #fff;
}

.btn--danger:hover:not(:disabled) {
    filter: brightness(1.08);
}

.btn--sm {
    padding: 0.42rem 0.95rem;
    font-size: var(--text-xs);
}

.btn--lg {
    padding: 0.95rem 2rem;
    font-size: var(--text-md);
}

.btn--block {
    width: 100%;
}

/* Round icon button with optional count badge */
.icon-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.6rem;
    height: 2.6rem;
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--ink-soft);
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease-out),
                color var(--dur-fast) var(--ease-out),
                transform var(--dur-fast) var(--ease-spring);
}

.icon-btn:hover {
    background: var(--surface-2);
    color: var(--ink);
    transform: translateY(-1px);
}

.icon-btn:active {
    transform: scale(0.92);
}

.icon-btn__badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 1.15rem;
    height: 1.15rem;
    padding-inline: 0.25rem;
    border-radius: var(--radius-pill);
    background: var(--accent);
    color: var(--on-accent);
    font-size: 0.62rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 2px var(--surface);
}

/* ---- Forms ---- */

.field {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--ink-soft);
}

/* Alanın altındaki kısa açıklama (örn. telefon biçimi). */
.field__hint {
    font-size: var(--text-xs);
    line-height: 1.4;
    color: var(--ink-faint);
}

.input,
.select,
.textarea {
    width: 100%;
    padding: 0.68rem 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}

.input::placeholder,
.textarea::placeholder {
    color: var(--ink-faint);
}

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b969d' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.9rem center;
    padding-right: 2.4rem;
    cursor: pointer;
}

.textarea {
    resize: vertical;
    min-height: 90px;
}

/* ---- Badges, chips ---- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.22rem 0.65rem;
    border-radius: var(--radius-pill);
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.02em;
}

.badge--success { background: var(--success-soft); color: var(--success); }
.badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--danger  { background: var(--danger-soft);  color: var(--danger); }
.badge--info    { background: var(--primary-soft); color: var(--primary); }
.badge--neutral { background: var(--surface-2);    color: var(--ink-soft); }
.badge--accent  { background: var(--accent-soft);  color: var(--accent-strong); }

/* Solid chips (product-card stock states) */
.badge--solid-warning { background: var(--warning); color: #fff; }
.badge--solid-danger  { background: var(--danger);  color: #fff; }

.ping-dot {
    position: relative;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.ping-dot::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 1.5px solid currentColor;
    opacity: 0.6;
    animation: qerp-ping 1.6s var(--ease-out) infinite;
}

/* ---- Cards ---- */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--dur-med) var(--ease-out),
                transform var(--dur-med) var(--ease-out),
                border-color var(--dur-med) var(--ease-out),
                background-color var(--dur-med) var(--ease-out);
}

.card--hover:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-4px);
}

/* ---- Prices ---- */

.price {
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--primary);
}

.price--old {
    font-weight: 500;
    font-size: 0.86em;
    color: var(--ink-faint);
    text-decoration: line-through;
}

/* ---- Horizontal snap scroller (product rows) ---- */

.hscroll {
    display: flex;
    gap: var(--space-4);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    padding-block: var(--space-2) var(--space-4);
    scrollbar-width: none;
}

.hscroll::-webkit-scrollbar {
    display: none;
}

.hscroll > * {
    scroll-snap-align: start;
    flex-shrink: 0;
}

/* ---- Skeleton loading ---- */

.skeleton {
    position: relative;
    overflow: hidden;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
}

.skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, var(--glass), transparent);
    animation: qerp-shimmer 1.4s infinite;
}

/* ---- Scroll-reveal system (driven by js/app.js observer) ---- */

.reveal {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity var(--dur-slow) var(--ease-out) var(--reveal-delay, 0ms),
                transform var(--dur-slow) var(--ease-out) var(--reveal-delay, 0ms);
}

.reveal.is-visible {
    opacity: 1;
    transform: none;
}

.stagger > * {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out);
}

.stagger.is-visible > * {
    opacity: 1;
    transform: none;
}

.stagger.is-visible > *:nth-child(1)  { transition-delay: 0ms; }
.stagger.is-visible > *:nth-child(2)  { transition-delay: 60ms; }
.stagger.is-visible > *:nth-child(3)  { transition-delay: 120ms; }
.stagger.is-visible > *:nth-child(4)  { transition-delay: 180ms; }
.stagger.is-visible > *:nth-child(5)  { transition-delay: 240ms; }
.stagger.is-visible > *:nth-child(6)  { transition-delay: 300ms; }
.stagger.is-visible > *:nth-child(7)  { transition-delay: 360ms; }
.stagger.is-visible > *:nth-child(8)  { transition-delay: 420ms; }
.stagger.is-visible > *:nth-child(n+9) { transition-delay: 480ms; }

/* ---- Keyframes ---- */

@keyframes qerp-shimmer {
    from { transform: translateX(-100%); }
    to   { transform: translateX(100%); }
}

@keyframes qerp-ping {
    from { transform: scale(1); opacity: 0.6; }
    to   { transform: scale(2.1); opacity: 0; }
}

@keyframes qerp-fade-up {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: none; }
}

@keyframes qerp-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

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

/* ---- Page transition (applied by MainLayout on route change) ----
   fill-mode MUST be backwards: with "both"/"forwards" the retained
   transform makes .page-enter a containing block and breaks
   position:fixed overlays (lightbox, modals) on every page. */

.page-enter {
    animation: qerp-fade-up 420ms var(--ease-out) backwards;
}

/* ---- Boot splash ---- */

/* ---- Açılış ekranı "Sayfa iskeleti" (2026-11-07, kullanıcının seçtiği son sürüm) ----
   MARKASIZ, her kuruluma uyar: logo/ad yok, renkler brand.css token'larından.
   Uygulama yüklenirken sitenin kabaca kendisi gri iskelet olarak görünür (üst bar +
   ürün kartı ızgarası) ve hafif ışıkla parlar — "site açılıyor" hissi. En üstte
   ince ilerleme çizgisi Blazor'un --blazor-load-percentage değişkeniyle dolar;
   değer yoksa (önbellekten açılış) %30'da durur. Izgara 2 / 3 / 4 / 5 sütun. */
.boot-splash {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: var(--canvas);
    overflow: hidden;
}

.boot-splash__progress {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    height: 3px;
    width: var(--blazor-load-percentage, 30%);
    border-radius: 0 3px 3px 0;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    box-shadow: 0 0 10px color-mix(in srgb, var(--primary) 60%, transparent);
    transition: width 300ms var(--ease-out);
}

/* Parlayan gri blok: tüm iskelet parçaları aynı ışık dalgasını paylaşır
   (background-attachment: fixed → ekran boyunca tek bir süzülme). */
.boot-sk {
    border-radius: 10px;
    background: linear-gradient(100deg,
        var(--surface-3) 30%,
        var(--surface-2) 50%,
        var(--surface-3) 70%);
    background-size: 300% 100%;
    background-attachment: fixed;
    animation: qerp-sk-shine 1.6s ease-in-out infinite;
}

.boot-sk__header {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
    height: 64px;
    padding: 0 clamp(1rem, 3vw, 2rem);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.boot-sk__menu {
    display: none;
    width: 28px;
    height: 22px;
    border-radius: 6px;
}

.boot-sk__logo {
    width: 120px;
    height: 26px;
}

.boot-sk__search {
    flex: 1;
    max-width: 560px;
    height: 40px;
    margin: 0 auto;
    border-radius: 12px;
}

.boot-sk__icons {
    display: flex;
    gap: 0.6rem;
}

.boot-sk__icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
}

.boot-sk__body {
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: clamp(1rem, 3vw, 2rem);
}

.boot-sk__title {
    width: min(220px, 50%);
    height: 22px;
    margin-bottom: 1.2rem;
}

.boot-sk__grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: clamp(0.75rem, 1.6vw, 1.25rem);
}

.boot-sk__card {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 0.75rem;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
}

.boot-sk__img { aspect-ratio: 4 / 5; border-radius: 12px; }
.boot-sk__l1  { width: 40%; height: 10px; }
.boot-sk__l2  { width: 85%; height: 14px; }
.boot-sk__l3  { width: 55%; height: 18px; }

@media (max-width: 1200px) {
    .boot-sk__grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    .boot-sk__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Telefon: menü düğmesi + ortada logo, arama alt satırda (gerçek başlık gibi). */
@media (max-width: 640px) {
    .boot-sk__header {
        flex-wrap: wrap;
        height: auto;
        padding-top: 0.9rem;
        padding-bottom: 0.9rem;
        row-gap: 0.9rem;
    }

    .boot-sk__menu { display: block; }
    .boot-sk__logo { margin: 0 auto; }
    .boot-sk__icons { width: 28px; }
    .boot-sk__icon { display: none; }
    .boot-sk__search { flex: 1 0 100%; max-width: none; }
    .boot-sk__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@keyframes qerp-sk-shine {
    from { background-position: 100% 0; }
    to   { background-position: 0 0; }
}

@media (prefers-reduced-motion: reduce) {
    .boot-sk { animation: none; }
}

/* ---- Blazor error bar ---- */

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: var(--z-toast);
    padding: 0.8rem 1.4rem 0.8rem 1.2rem;
    background: var(--danger);
    color: #fff;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
}

#blazor-error-ui .reload {
    text-decoration: underline;
    margin-left: 0.5rem;
}

#blazor-error-ui .dismiss {
    position: absolute;
    right: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
}

/* ---- Sticky header with condensing effect ----
   The whole header sticks to the top; once the page is scrolled
   (html[data-scrolled], toggled by js/app.js) it condenses smoothly:
   smaller logo, frosted-glass background, elevation.
   Satır yükseklikleri bilinçli olarak SABİT — aşağıdaki nota bakın. */

.app-header {
    position: sticky;
    top: 0;
    z-index: var(--z-header);
}

/* ---- Header'ın iki satırı arasındaki çizim sırası ----
   Sayfa kaydırılınca .header__main'e backdrop-filter uygulanıyor (aşağıda) ve
   .header__navwrap'ta blur zaten kalıcı. backdrop-filter YENİ BİR STACKING
   CONTEXT açar; bu yüzden üst satırın içindeki .dropdown__panel'in
   z-index:200 değeri artık tüm header'a göre değil, yalnızca .header__main
   kutusunun İÇİNDE geçerli olur. İki satırın da z-index'i auto kalırsa sırayı
   DOM belirler ve sonra gelen nav şeridi üste çizilir — açılan dil / para
   birimi / hesap menüsünün ilk satırı nav şeridinin arkasında kaybolur.
   Sırayı bu yüzden açıkça sabitliyoruz.

   Not: kurallar bilinçli olarak base.css'te — header'ın katman düzeni tek
   yerde dursun ve scoped CSS bundle'ı (QuickERPB2B.Client.styles.css) yeniden
   derlenmeden de etkili olsun. Baştaki `html`, scoped stilleri geçebilmek
   için specificity kazandırır. */
html .app-header .header__main {
    position: relative;
    z-index: 2;
}

html .app-header .header__navwrap {
    position: relative;
    z-index: 1;
}

html[data-scrolled] .app-header {
    box-shadow: var(--shadow-md);
}

html[data-scrolled] .app-header .header__main {
    background: var(--glass);
    backdrop-filter: blur(14px);
}

/* Logo küçülür — satır yüksekliği min-height ile sabitlendiği için bu
   değişiklik header'ın kapladığı alanı ETKİLEMEZ, sadece görseldir. */
html[data-scrolled] .app-header .header__logo {
    font-size: 1.1rem;
}

/* ---- Satır yüksekliği neden artık değişmiyor? ----
   Burada eskiden şu iki kural vardı:

       html[data-scrolled] .app-header .header__main-inner { min-height: 3.1rem; }
       html[data-scrolled] .app-header .header__nav        { min-height: 2.5rem; }

   Header akışta yer kapladığı için bu, condense anında belgeyi ~21px
   kısaltıyordu. Tarayıcının scroll anchoring'i görünümü sabit tutmak için
   scrollY'yi telafi ediyor; üstelik min-height'ta 320ms'lik bir transition
   olduğundan belge yüksekliği o süre boyunca HER KAREDE değişiyor ve
   anchoring her karede müdahale ediyordu. Kullanıcı aynı anda yavaşça
   yukarı kaydırırken bu çekişme titreme olarak görünüyordu. (JS tarafındaki
   histerezis eşik geçişini tekilleştirdi ama transition süresince süren bu
   kare-kare çekişmeyi çözemez — sebep eşik değil, layout kaymasının kendisi.)

   Çözüm: condense'i tamamen görsel bırakmak. Satır yükseklikleri artık
   sabit, dolayısıyla scroll sırasında belge yüksekliği hiç değişmiyor ve
   titremenin fiziksel sebebi ortadan kalkıyor. Frosted-glass zemin, gölge
   ve logo küçülmesi korundu.

   Satırların incelmesi geri istenirse: header'ı akıştan çıkarmak gerekir
   (position: fixed + üstte sabit yükseklikte bir spacer); aksi hâlde
   yükseklik animasyonu bu titremeyi kaçınılmaz olarak geri getirir. */

/* ---- Accessibility helpers ---- */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* Printing an invoice (dashboard order detail) hides the app chrome */
@media print {
    .header,
    .footer,
    .toast-host,
    .app-navbar {
        display: none !important;
    }

    body {
        background: #fff;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .reveal,
    .stagger > * {
        opacity: 1;
        transform: none;
    }
}

/* ---- "Görsel yok" yer tutucusu (2026-11-20) ----
   app.js, yüklenemeyen / boş ürün görselini img/no-image.svg yapar ve bu
   sınıfı ekler. SVG'nin zemini şeffaf; zemin buradan (tema rengiyle) — tek
   dosya açık/koyu temada doğru görünür. Simgenin küçüklüğü SVG'nin kendi
   kenar boşluğundan (viewBox): padding % ebeveyn genişliğine göre hesaplandığı
   için 56px küçük resimlerde simgeyi yok ediyordu. */
img.img--missing {
    object-fit: contain !important;
    object-position: center !important;
    background: var(--surface-2);
    transform: none !important;   /* galerideki fareyle büyütme simgeyi büyütmesin */
}
