/* =========================================================
   Masa Takip - Dondurma Dükkanı Sipariş & Stok Sistemi
   Tema: Pastel dondurma renkleri
   ========================================================= */

:root {
    --ice-pink: #ff6f9c;
    --ice-pink-dark: #e85586;
    --ice-mint: #3ec9b0;
    --ice-mint-dark: #2ba892;
    --ice-cream: #fff8f0;
    --ice-choco: #6b4226;
    --ice-vanilla: #fff1d6;
    --ice-sky: #6ec6ff;
    --gray-900: #2d2a2e;
    --gray-600: #6b6b70;
    --gray-200: #ececec;
    --danger: #e35d5d;
    --success: #3ec9b0;
    --warning: #f5a623;
    --radius: 14px;
    --shadow-sm: 0 2px 8px rgba(45, 42, 46, 0.06);
    --shadow-md: 0 8px 24px rgba(45, 42, 46, 0.10);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    background: var(--ice-cream);
    color: var(--gray-900);
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    min-height: 100vh;
}

a { text-decoration: none; }

/* ---------- Topbar ---------- */
.app-topbar {
    background: linear-gradient(135deg, var(--ice-pink) 0%, var(--ice-pink-dark) 100%);
    color: #fff;
    padding: 14px 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.app-topbar .brand {
    font-weight: 700;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-topbar .brand .emoji { font-size: 1.4rem; }

.app-topbar .user-chip {
    background: rgba(255,255,255,0.18);
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-topbar .user-chip a { color: #fff; opacity: 0.85; }
.app-topbar .user-chip a:hover { opacity: 1; text-decoration: underline; }

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

.app-sidebar {
    width: 230px;
    background: #fff;
    border-right: 1px solid var(--gray-200);
    padding: 18px 12px;
    flex-shrink: 0;
}

.app-sidebar .nav-link {
    color: var(--gray-900);
    padding: 10px 14px;
    border-radius: 10px;
    margin-bottom: 4px;
    font-weight: 500;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-sidebar .nav-link:hover { background: var(--ice-vanilla); }
.app-sidebar .nav-link.active { background: var(--ice-pink); color: #fff; }

.app-main { flex: 1; padding: 24px; max-width: 100%; }

@media (max-width: 768px) {
    .app-shell { flex-direction: column; }
    .app-sidebar {
        width: 100%;
        display: flex;
        overflow-x: auto;
        gap: 4px;
        padding: 10px;
    }
    .app-sidebar .nav-link { white-space: nowrap; margin-bottom: 0; }
    .app-main { padding: 14px; }
}

/* ---------- Cards ---------- */
.card-soft {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    padding: 18px;
}

.stat-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 18px 20px;
    border-left: 5px solid var(--ice-pink);
}
.stat-card.mint { border-left-color: var(--ice-mint); }
.stat-card.sky { border-left-color: var(--ice-sky); }
.stat-card.warning { border-left-color: var(--warning); }

.stat-card .label { color: var(--gray-600); font-size: 0.85rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.stat-card .value { font-size: 1.7rem; font-weight: 700; margin-top: 4px; }

/* ---------- Buttons ---------- */
.btn-ice {
    background: var(--ice-pink);
    border: none;
    color: #fff;
    padding: 9px 18px;
    border-radius: 10px;
    font-weight: 600;
    transition: background .15s ease;
}
.btn-ice:hover { background: var(--ice-pink-dark); color: #fff; }

.btn-ice-outline {
    background: #fff;
    border: 1.5px solid var(--ice-pink);
    color: var(--ice-pink-dark);
    padding: 8px 16px;
    border-radius: 10px;
    font-weight: 600;
}
.btn-ice-outline:hover { background: var(--ice-vanilla); color: var(--ice-pink-dark); }

.btn-mint {
    background: var(--ice-mint);
    border: none;
    color: #fff;
    padding: 9px 18px;
    border-radius: 10px;
    font-weight: 600;
}
.btn-mint:hover { background: var(--ice-mint-dark); color: #fff; }

/* ---------- Tables (masa grid) ---------- */
.table-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
}

.table-tile {
    border-radius: var(--radius);
    padding: 22px 14px;
    text-align: center;
    color: #fff;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
    position: relative;
    min-height: 110px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.table-tile.bos { background: linear-gradient(135deg, var(--ice-mint), var(--ice-mint-dark)); }
.table-tile.dolu { background: linear-gradient(135deg, var(--ice-pink), var(--ice-pink-dark)); }
.table-tile.rezerve { background: linear-gradient(135deg, var(--warning), #d98a12); }

.table-tile .table-name { font-size: 1.05rem; }
.table-tile .table-sub { font-size: 0.78rem; font-weight: 500; opacity: 0.9; }
.table-tile .table-amount { font-size: 0.95rem; font-weight: 700; background: rgba(255,255,255,0.22); padding: 2px 10px; border-radius: 999px; }

/* Yöneticinin masaya atadığı sabit renk (inline style ile uygulanır) durum
   gradyanının üzerine geçer; durum ise köşedeki rozet/nokta ile gösterilir. */
.table-tile .status-dot {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.95);
    box-shadow: 0 1px 4px rgba(45, 42, 46, 0.35);
}
.status-dot.bos { background: var(--ice-mint-dark); }
.status-dot.dolu { background: var(--ice-pink-dark); }
.status-dot.rezerve { background: #d98a12; }

.color-swatch {
    display: inline-block;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(45, 42, 46, 0.18);
    vertical-align: middle;
}

/* ---------- Salon planı (yerleşim canvas'ı) ---------- */
.layout-canvas {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    min-height: 360px;
    max-height: 640px;
    background:
        linear-gradient(0deg, rgba(45,42,46,0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(45,42,46,0.04) 1px, transparent 1px);
    background-size: 5% 5%;
    background-color: var(--ice-cream);
    border: 2px dashed var(--gray-200);
    border-radius: var(--radius);
    overflow-x: hidden;
    overflow-y: auto;
}

.table-tile.positioned {
    position: absolute;
    width: 96px;
    min-height: 96px;
    padding: 12px 8px;
    transform: translate(-50%, -50%);
    font-size: 0.85rem;
}
.table-tile.positioned .table-name { font-size: 0.85rem; }
.table-tile.positioned .table-sub { font-size: 0.68rem; }
.table-tile.positioned .table-amount { font-size: 0.72rem; padding: 1px 7px; }
.table-tile.positioned .status-dot { width: 11px; height: 11px; top: 6px; right: 6px; border-width: 1.5px; }

.table-tile.draggable {
    cursor: grab;
    touch-action: none;
    user-select: none;
    transition: box-shadow .15s ease;
}
.table-tile.draggable:active { cursor: grabbing; }
.table-tile.draggable.dragging {
    z-index: 20;
    box-shadow: 0 12px 28px rgba(45, 42, 46, 0.28);
    transform: translate(-50%, -50%) scale(1.06);
}

.layout-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--ice-vanilla);
    color: var(--ice-choco);
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.85rem;
    margin-bottom: 14px;
}

.layout-save-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--ice-mint-dark);
    color: #fff;
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: var(--shadow-md);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity .2s ease, transform .2s ease;
    pointer-events: none;
    z-index: 100;
}
.layout-save-toast.show { opacity: 1; transform: translateY(0); }

/* ---------- Product grid (order entry) ---------- */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.product-card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--gray-200);
    padding: 14px 10px;
    text-align: center;
    cursor: pointer;
    transition: transform .1s ease, box-shadow .1s ease;
}
.product-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.product-card:active { transform: translateY(0); }
.product-card .pname { font-weight: 600; font-size: 0.92rem; margin-top: 4px; }
.product-card .pprice { color: var(--ice-pink-dark); font-weight: 700; font-size: 0.9rem; }
.product-card .picon { font-size: 1.8rem; }
.product-card.low-stock { border-color: var(--warning); }
.product-card .stock-badge { font-size: 0.7rem; color: var(--gray-600); }

/* ---------- Cart ---------- */
.cart-panel {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 16px;
    position: sticky;
    top: 90px;
}

.cart-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--gray-200); }
.cart-item:last-child { border-bottom: none; }
.qty-btn { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--gray-200); background: #fff; font-weight: 700; line-height: 1; }

/* ---------- Badges / status ---------- */
.badge-status { padding: 4px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; }
.badge-status.acik { background: #e6f9f5; color: var(--ice-mint-dark); }
.badge-status.kapali { background: #eee; color: var(--gray-600); }
.badge-status.iptal { background: #fdeaea; color: var(--danger); }

/* ---------- Auth pages ---------- */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, var(--ice-pink) 0%, var(--ice-mint) 100%);
    padding: 20px;
}
.auth-card {
    background: #fff;
    border-radius: 20px;
    box-shadow: var(--shadow-md);
    padding: 40px 34px;
    width: 100%;
    max-width: 380px;
}
.auth-card .logo { text-align: center; font-size: 2.4rem; margin-bottom: 4px; }
.auth-card h1 { font-size: 1.3rem; text-align: center; margin-bottom: 24px; font-weight: 700; }

/* ---------- Misc ---------- */
/* overflow-x: auto + overflow-y: hidden -- geniş tablolar dar ekranlarda
   kesilmek yerine yatay olarak kaydırılabilir olsun (border-radius korunur). */
.table-responsive-soft { border-radius: var(--radius); overflow-x: auto; overflow-y: hidden; box-shadow: var(--shadow-sm); -webkit-overflow-scrolling: touch; }
.form-label { font-weight: 600; font-size: 0.88rem; }
.critical-row { background: #fff5f5 !important; }

/* ---------- Mobil / tablet uyumluluk ---------- */

/* Yatayda taşmayı güvenceye al: herhangi bir bileşen sayfa genişliğini
   aşarsa gövde kaydırma çubuğu yerine sadece o bileşen kaydırılabilir olsun. */
html { overflow-x: hidden; }
body { overflow-x: hidden; }

/* Filtre/dönem buton grupları (raporlar vb.) dar ekranlarda taşmasın,
   alt satıra sarsın ve her buton dokunmaya uygun boyutta kalsın. */
@media (max-width: 767.98px) {
    .btn-group { flex-wrap: wrap; }
    .btn-group > .btn {
        flex: 1 1 auto;
        border-radius: 8px !important;
        margin: 3px 2px !important;
    }
}

/* Tablet (≤ 991.98px): kenar çubuğu zaten yatay kaydırmalı menüye dönüşüyor
   (bkz. .app-shell kuralı yukarıda); burada dokunma hedeflerini büyüt. */
@media (max-width: 991.98px) {
    .app-sidebar .nav-link { padding: 12px 16px; font-size: 1rem; }
    .qty-btn { width: 34px; height: 34px; font-size: 1.05rem; }
    .cart-panel { position: static; top: auto; }
}

/* Telefon (≤ 575.98px) */
@media (max-width: 575.98px) {
    .app-topbar { flex-wrap: wrap; gap: 8px; padding: 12px 14px; }
    .app-topbar .brand { font-size: 1rem; }
    .app-topbar .user-chip { font-size: 0.8rem; gap: 8px; padding: 5px 10px; flex-wrap: wrap; }

    .app-main { padding: 12px; }

    .stat-card { padding: 14px 14px; }
    .stat-card .value { font-size: 1.35rem; }

    .product-grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
    .product-card { padding: 10px 6px; }
    .product-card .picon { font-size: 1.4rem; }
    .product-card .pname { font-size: 0.82rem; }

    .table-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
    .table-tile { min-height: 92px; padding: 16px 10px; }

    .auth-card { padding: 30px 22px; }

    .layout-canvas { min-height: 280px; }
    .table-tile.positioned { width: 74px; min-height: 74px; padding: 8px 5px; font-size: 0.7rem; }
    .table-tile.positioned .table-name { font-size: 0.7rem; }
    .table-tile.positioned .table-sub { font-size: 0.58rem; }
    .table-tile.positioned .table-amount { font-size: 0.62rem; padding: 1px 5px; }
    .table-tile.positioned .status-dot { width: 9px; height: 9px; top: 4px; right: 4px; border-width: 1px; }
}

/* Ürün kategorisi sekmeleri (personel sipariş ekranı): çok sayıda kategori
   varsa dar ekranlarda alt alta kaymak yerine yatayda kaydırılsın. */
#catTabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
}
#catTabs .nav-item { flex-shrink: 0; }

/* Sepetin altında sabit "mobil sepet çubuğu": küçük ekranlarda personel
   sepeti görmek için her seferinde aşağı kaydırmak zorunda kalmasın. */
.mobile-cart-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    background: #fff;
    border-top: 1px solid var(--gray-200);
    box-shadow: 0 -4px 16px rgba(45, 42, 46, 0.12);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.mobile-cart-bar .mcb-info { display: flex; flex-direction: column; line-height: 1.2; }
.mobile-cart-bar .mcb-count { font-size: 0.72rem; color: var(--gray-600); }
.mobile-cart-bar .mcb-total { font-size: 1.05rem; font-weight: 700; }
