/*
 * app-theme.css — سیستەمی دیزاینی نوێ (ڕۆشن + سەوز) بۆ Slemani Fitness
 * Modern light + green design system. Layered on top of Bootstrap 5 RTL.
 * هیچ فەنکشنێک ناگۆڕێت — تەنها ڕووکار. (Visual only — no behavior change.)
 */

:root {
    --brand:        #198754;
    --brand-dark:   #146c43;
    --brand-darker: #0f5132;
    --brand-light:  #d1e7dd;
    --accent:       #0d9488;
    --bg:           #f3f6f9;
    --surface:      #ffffff;
    --text:         #1f2d3d;
    --muted:        #6b7a8d;
    --border:       #e7ecf2;
    --danger:       #dc3545;
    --warning:      #f59e0b;
    --radius:       14px;
    --radius-sm:    10px;
    --shadow:       0 1px 2px rgba(16,24,40,.04), 0 4px 16px rgba(16,24,40,.06);
    --shadow-lg:    0 10px 30px rgba(16,24,40,.10);
}

/* ---------- base ---------- */
body {
    /* بەبێ !important تاکو کیۆسک بتوانێت بە JS body سوور بکات بۆ بەسەرچوو */
    background: var(--bg);
    color: var(--text);
    font-family: 'NRT Reg', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
}
#app { min-height: 100vh; }
main.container { padding-top: 1rem; padding-bottom: 2rem; }
a { text-decoration: none; }
h1,h2,h3,h4,h5,h6 { color: var(--text); }

/* ---------- navbar ---------- */
.navbar {
    background: linear-gradient(90deg, var(--brand-darker), var(--brand)) !important;
    box-shadow: 0 2px 14px rgba(15,81,50,.25) !important;
    padding: .5rem 0;
}
.navbar .container { align-items: center; }
.navbar .navbar-brand,
.navbar .nav-link {
    color: rgba(255,255,255,.92) !important;
    font-weight: 600;
    font-size: 0.95rem;
}
.navbar .navbar-brand { display: inline-flex; align-items: center; gap: .4rem; border-radius: 10px; padding: .4rem .7rem; transition: background .15s ease; }
.navbar .navbar-brand:hover { background: rgba(255,255,255,.12); }
.navbar .navbar-brand.brand-logo { font-size: 1.05rem; font-weight: 800; letter-spacing: .2px; }
.navbar .navbar-brand.brand-logo .brand-badge {
    display: inline-grid; place-items: center; width: 30px; height: 30px;
    background: #fff; color: var(--brand-dark); border-radius: 10px; font-size: 0.9rem;
}
.navbar .nav-link { border-radius: 10px; padding: .4rem .7rem !important; transition: background .15s ease; }
.navbar .nav-link:hover { background: rgba(255,255,255,.14); }
.navbar .navbar-toggler { border-color: rgba(255,255,255,.4); padding: .4rem .6rem; }
.navbar .dropdown-menu { border: none; box-shadow: var(--shadow-lg); border-radius: var(--radius-sm); }
.navbar .dropdown-item { font-weight: 500; }

/* ---------- section switcher bar (owner / hall_type 0) ---------- */
.section-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 10px rgba(16,24,40,.05);
    padding: .5rem 0;
}
.section-bar-label {
    font-weight: 800; color: var(--text);
    display: inline-flex; align-items: center; gap: .45rem;
    font-size: 0.9rem;
}
.section-bar-label i { color: var(--brand); }

/* segmented toggle */
.section-switch {
    display: inline-flex; align-items: center;
    background: #eef2f7; border: 1px solid var(--border);
    border-radius: 999px; padding: 3px; gap: 3px;
}
.section-switch a {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .4rem 1rem; border-radius: 999px;
    font-weight: 700; color: #64748b; line-height: 1;
    font-size: 0.85rem;
    transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.section-switch a i { font-size: 0.95rem; }
.section-switch a:not(.active):hover { background: #fff; color: var(--text); }
.section-switch a.men.active   { background: linear-gradient(135deg,#2563eb,#38bdf8); color:#fff; box-shadow: 0 3px 10px rgba(37,99,235,.35); }
.section-switch a.women.active { background: linear-gradient(135deg,#db2777,#f472b6); color:#fff; box-shadow: 0 3px 10px rgba(219,39,119,.35); }

.section-hint {
    color: var(--muted); font-size: .8rem;
    display: inline-flex; align-items: center; gap: .35rem;
    margin-inline-start: auto;
}
.section-hint i { color: var(--brand); }
@media (max-width: 575px) { .section-hint { display: none; } }

/* ---------- cards ---------- */
.card,
.app-card {
    background: var(--surface);
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow);
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    padding: 0.9rem 1rem;
    border-radius: var(--radius) var(--radius) 0 0 !important;
    font-size: 0.95rem;
}
.card-body { padding: 1rem; }

.app-card { padding: 1rem; margin-bottom: 1rem; }

/* page title */
.page-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1rem;
}
.page-head h1, .page-head h2, .page-head .page-title {
    font-size: 1.2rem; font-weight: 800; margin: 0;
    display: inline-flex; align-items: center; gap: .5rem;
}
.page-head .page-title i { color: var(--brand); }

/* ---------- stat cards ---------- */
.stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1rem;
    box-shadow: var(--shadow); display: flex; align-items: center; gap: 0.75rem;
    transition: transform .15s ease, box-shadow .15s ease;
    height: 100%;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-card .stat-icon {
    width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
    font-size: 1.2rem; color: #fff; background: linear-gradient(135deg, var(--brand), var(--accent));
    flex: 0 0 auto;
}
.stat-card.is-male  .stat-icon { background: linear-gradient(135deg, #2563eb, #38bdf8); }
.stat-card.is-female .stat-icon { background: linear-gradient(135deg, #db2777, #f472b6); }
.stat-card .stat-value { font-size: 1.4rem; font-weight: 800; line-height: 1; }
.stat-card .stat-label { color: var(--muted); font-size: 0.8rem; margin-top: .15rem; }

/* ---------- buttons ---------- */
.btn {
    border-radius: 10px; font-weight: 600; padding: .5rem 1rem;
    transition: transform .08s ease, box-shadow .15s ease, background .15s ease, filter .15s ease;
    font-size: 0.9rem;
}
.btn:active { transform: translateY(1px); }
.btn-sm { border-radius: 8px; padding: .35rem .65rem; font-size: 0.8rem; }
.btn-success { background: var(--brand); border-color: var(--brand); }
.btn-success:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-primary { background: #2563eb; border-color: #2563eb; }
.btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }
.btn-outline-success { color: var(--brand-dark); border-color: var(--brand); }
.btn-outline-success:hover { background: var(--brand); border-color: var(--brand); }
.btn-warning { color: #fff; background: var(--warning); border-color: var(--warning); }
.btn-warning:hover { color: #fff; filter: brightness(.95); }
.btn-info { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-info:hover { filter: brightness(.95); color: #fff; }

/* ---------- forms ---------- */
.form-control, .form-select {
    border-radius: 10px; border: 1px solid var(--border);
    padding: .5rem .75rem; background: #fbfdff;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
    font-size: 0.9rem;
    min-height: 42px;
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand); background: #fff;
    box-shadow: 0 0 0 .2rem rgba(25,135,84,.15);
}
.form-label, label { font-weight: 600; color: #3a4a5d; margin-bottom: .3rem; font-size: 0.9rem; }

/* ---------- tables ---------- */
.table-responsive {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.table { margin: 0; vertical-align: middle; font-size: 0.9rem; }
.table thead th {
    background: #f1f5f9; color: #475569; font-weight: 700;
    border-bottom: 1px solid var(--border); padding: .75rem .85rem; white-space: nowrap;
    font-size: 0.85rem;
}
.table.table-dark thead th, .table thead.table-dark th {
    background: var(--brand-darker); color: #fff; border-color: var(--brand-dark);
}
.table tbody td { padding: .65rem .85rem; border-color: #f0f3f7; }
.table.table-striped > tbody > tr:nth-of-type(odd) > * { background: #fafcfe; }
.table tbody tr { transition: background .12s ease; }
.table tbody tr:hover > * { background: var(--brand-light) !important; }
.table img { border-radius: 10px; object-fit: cover; }

/* keep status row colors but soften them */
.table-success, .table > :not(caption) > * > .table-success { --bs-table-bg: #e8f6ef; }
.table-danger,  .table > :not(caption) > * > .table-danger  { --bs-table-bg: #fdecee; }

/* ---------- badges ---------- */
.badge {
    font-weight: 600; padding: .35em .65em; border-radius: 999px; font-size: .75rem;
}
.badge.bg-primary { background: #2563eb !important; }
.badge.bg-success { background: var(--brand) !important; }
.badge.bg-danger  { background: var(--danger) !important; }
.badge.bg-secondary { background: #94a3b8 !important; }

/* ---------- modals ---------- */
.modal-content { border: none; border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden; }
.modal-header {
    background: linear-gradient(90deg, var(--brand-darker), var(--brand));
    color: #fff; border: none; padding: 0.9rem 1rem;
}
.modal-header .btn-close { filter: invert(1) grayscale(1) brightness(1.6); }
.modal-body { padding: 1rem; }
.modal-footer { padding: 0.75rem 1rem; }

/* ---------- alerts ---------- */
.alert { border: none; border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.alert-success { background: var(--brand-light); color: var(--brand-darker); }

/* ---------- pagination ---------- */
.pagination { gap: .2rem; }
.page-link {
    border: 1px solid var(--border); border-radius: 10px !important; color: var(--brand-dark);
    margin: 0 1px; min-width: 36px; text-align: center; font-weight: 600;
    font-size: 0.85rem;
    padding: .4rem .65rem;
}
.page-item.active .page-link { background: var(--brand); border-color: var(--brand); }
.page-link:hover { background: var(--brand-light); color: var(--brand-darker); }

/* ---------- auth pages ---------- */
.auth-wrap { min-height: calc(100vh - 90px); display: grid; place-items: center; padding: 1.5rem 1rem; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .card-header {
    background: linear-gradient(90deg, var(--brand-darker), var(--brand));
    color: #fff; text-align: center; font-size: 1.1rem; border: none;
}
.auth-brand { text-align: center; margin-bottom: 1.1rem; }
.auth-brand .brand-badge {
    display: inline-grid; place-items: center; width: 52px; height: 52px;
    background: linear-gradient(135deg, var(--brand), var(--accent)); color: #fff;
    border-radius: 16px; font-size: 1.5rem; box-shadow: var(--shadow);
}
.auth-brand h1 { font-size: 1.2rem; font-weight: 800; margin-top: .5rem; }

/* ---------- kiosk idle (welcome) screen ---------- */
.kiosk-screen {
    display: flex; align-items: center; justify-content: center;
    min-height: calc(100vh - 130px); padding: 1rem;
}
.kiosk-idle {
    width: 100%; max-width: 1100px;
    height: calc(100vh - 150px); min-height: 420px;
    border-radius: 24px; overflow: hidden; box-shadow: var(--shadow-lg);
    display: flex; flex-direction: column; background: #fff;
}
/* ناوچەی ڕیکلام: وێنەکە بە تەواوی دیارە (contain)، بەبێ بڕین و بەبێ تاریککردن */
.kiosk-idle-media {
    flex: 1 1 auto; min-height: 0;
    display: grid; place-items: center; overflow: hidden;
    background: #f3f6f9;
}
.kiosk-idle-media img {
    max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain;
}
/* باری خوارەوە: لۆگۆ + کاتژمێر + هانی سکان — هیچ لە ڕیکلامەکە ناشارێتەوە */
.kiosk-idle-bar {
    flex: 0 0 auto;
    background: linear-gradient(90deg, var(--brand-darker), var(--brand));
    color: #fff; padding: .75rem 1.2rem;
    display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap;
}
.kiosk-idle-brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 900; font-size: 1.15rem; }
.kiosk-idle-badge {
    width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center;
    background: rgba(255,255,255,.18); font-size: 1rem;
}
.kiosk-idle-clock { font-size: 1.4rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: 1px; }
.kiosk-scan-hint {
    display: inline-flex; align-items: center; gap: .5rem;
    background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.35);
    padding: .5rem 1rem; border-radius: 999px; font-size: 1rem; font-weight: 800;
    animation: scanpulse 1.8s ease-in-out infinite;
}
@keyframes scanpulse {
    0%, 100% { transform: scale(1); opacity: .9; }
    50%      { transform: scale(1.05); opacity: 1; }
}
.kiosk-result { width: 100%; max-width: 560px; animation: zoomfade .2s ease; }
.kiosk-photo { max-height: 240px; border-radius: 16px; object-fit: cover; }
@media (max-width: 575px) {
    .kiosk-idle-brand { font-size: 0.95rem; }
    .kiosk-idle-clock { font-size: 1.2rem; }
    .kiosk-scan-hint { font-size: 0.9rem; padding: .4rem .8rem; }
}

/* ---------- PWA install button ---------- */
#pwa-install-btn {
    position: fixed; bottom: 12px; right: 12px; z-index: 9999;
    display: none; align-items: center; gap: .5rem;
    background: linear-gradient(135deg, var(--brand), var(--accent)); color: #fff;
    border: none; border-radius: 999px; padding: .6rem 1.2rem; font-weight: 700;
    box-shadow: var(--shadow-lg); cursor: pointer; font-family: inherit;
    font-size: 0.9rem;
}
#pwa-install-btn:hover { filter: brightness(1.05); }

/* ---------- kiosk (scan screen) ---------- */
.kiosk-stage { padding: 1rem 0 2rem; }
.kiosk-photo-wrap {
    background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
    box-shadow: var(--shadow-lg); padding: 1rem; display: grid; place-items: center;
}
.kiosk-photo-wrap img { border-radius: 16px; max-height: 520px; width: auto; }
.kiosk-card { border-radius: 20px !important; box-shadow: var(--shadow-lg); overflow: hidden; }
.kiosk-card .kiosk-card-top {
    background: linear-gradient(90deg, var(--brand-darker), var(--brand));
    color: #fff; padding: 1rem 1.2rem; font-weight: 800; font-size: 1.15rem;
    display: flex; align-items: center; justify-content: space-between; gap: .75rem;
}
.kiosk-card .kiosk-card-top .kiosk-name { display: inline-flex; align-items: center; gap: .45rem; min-width: 0; }
.kiosk-card .kiosk-card-top #nameText { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kiosk-card .kiosk-card-top .kiosk-order {
    flex: 0 0 auto; font-size: 0.95rem; font-weight: 800;
    background: rgba(255,255,255,.22); border-radius: 999px; padding: .25rem .75rem;
}
.kiosk-info .info-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: .75rem 0; border-bottom: 1px dashed var(--border);
}
.kiosk-info .info-row:last-child { border-bottom: none; }
.kiosk-info .info-label { color: var(--muted); font-weight: 600; display: inline-flex; align-items: center; gap: .45rem; font-size: 0.9rem; }
.kiosk-info .info-value { font-weight: 800; font-size: 1.05rem; }
.kiosk-info .info-value .btn { font-size: 1rem; font-weight: 800; }
#nameText { font-weight: 900; }
.kiosk-photo-side { border-radius: 0 0 20px 20px; object-fit: cover; }

/* body state for expired scans (the JS toggles backgroundColor; soften it) */
body[style*="red"] .kiosk-card-top { background: linear-gradient(90deg,#b02a37,#dc3545); }

/* ---------- image zoom / lightbox ---------- */
img.zoomable { cursor: zoom-in; transition: transform .15s ease, box-shadow .15s ease; }
img.zoomable:hover { transform: scale(1.05); box-shadow: var(--shadow-lg); }
#img-zoom-overlay {
    position: fixed; inset: 0; z-index: 20000;
    background: rgba(8,12,20,.88);
    display: none; align-items: center; justify-content: center;
    padding: 24px; cursor: zoom-out;
}
#img-zoom-overlay.show { display: flex; animation: zoomfade .15s ease; }
#img-zoom-overlay img {
    max-width: 92vw; max-height: 92vh; border-radius: 14px;
    box-shadow: 0 14px 50px rgba(0,0,0,.6); background: #fff;
}
#img-zoom-overlay .img-zoom-close {
    position: fixed; top: 14px; left: 20px; color: #fff; font-size: 2.4rem;
    line-height: 1; cursor: pointer; opacity: .85;
}
#img-zoom-overlay .img-zoom-close:hover { opacity: 1; }
@keyframes zoomfade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- misc ---------- */
.text-primary   { color: #2563eb !important; }
.text-success   { color: var(--brand) !important; }
hr { border-color: var(--border); opacity: 1; }
::-webkit-scrollbar { height: 10px; width: 10px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ============================================
   RESPONSIVE STYLES - MOBILE FIRST
   ============================================ */

/* ---------- Extra Small devices (320px - 575px) ---------- */
@media (max-width: 575px) {
    body {
        font-size: 15px;
    }
    
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    main.container {
        padding-top: 0.75rem;
        padding-bottom: 1.5rem;
    }
    
    /* Navbar */
    .navbar-brand.brand-logo {
        font-size: 0.95rem;
    }
    
    .navbar-brand.brand-logo .brand-badge {
        width: 28px;
        height: 28px;
        font-size: 0.8rem;
    }
    
    .navbar-nav {
        padding: 0.5rem 0;
    }
    
    .nav-link {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.9rem;
    }
    
    /* Section bar */
    .section-bar {
        padding: 0.4rem 0;
    }
    
    .section-bar .container {
        gap: 0.5rem;
    }
    
    .section-switch a {
        padding: 0.35rem 0.85rem;
        font-size: 0.8rem;
    }
    
    .section-switch a i {
        font-size: 0.85rem;
    }
    
    /* Page head */
    .page-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.6rem;
        margin-bottom: 0.9rem;
    }
    
    .page-head h1, .page-head h2, .page-head .page-title {
        font-size: 1.1rem;
    }
    
    .page-head .d-flex {
        width: 100%;
    }
    
    .page-head .btn {
        flex: 1;
        font-size: 0.85rem;
        padding: 0.45rem 0.75rem;
    }
    
    /* Stat cards */
    .stat-card {
        padding: 0.85rem;
        gap: 0.65rem;
    }
    
    .stat-card .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }
    
    .stat-card .stat-value {
        font-size: 1.25rem;
    }
    
    .stat-card .stat-label {
        font-size: 0.75rem;
    }
    
    /* Cards */
    .app-card {
        padding: 0.85rem;
        margin-bottom: 0.85rem;
    }
    
    .card-body {
        padding: 0.85rem;
    }
    
    .card-header {
        padding: 0.75rem 0.85rem;
        font-size: 0.9rem;
    }
    
    /* Forms */
    .form-control, .form-select {
        font-size: 0.85rem;
        padding: 0.5rem 0.7rem;
        min-height: 40px;
    }
    
    .form-label, label {
        font-size: 0.85rem;
        margin-bottom: 0.25rem;
    }
    
    /* Buttons */
    .btn {
        font-size: 0.85rem;
        padding: 0.45rem 0.85rem;
    }
    
    .btn-sm {
        font-size: 0.75rem;
        padding: 0.3rem 0.55rem;
    }
    
    /* Tables - Convert to card view on mobile */
    .table-responsive {
        border-radius: var(--radius-sm);
    }
    
    .table {
        font-size: 0.8rem;
    }
    
    .table thead th {
        padding: 0.6rem 0.65rem;
        font-size: 0.75rem;
    }
    
    .table tbody td {
        padding: 0.55rem 0.65rem;
        font-size: 0.8rem;
    }
    
    .table img {
        width: 60px !important;
        height: 60px !important;
    }
    
    /* Modals */
    .modal-dialog {
        margin: 0.5rem;
    }
    
    .modal-content {
        border-radius: var(--radius-sm);
    }
    
    .modal-header {
        padding: 0.75rem 0.9rem;
    }
    
    .modal-body {
        padding: 0.9rem;
    }
    
    .modal-footer {
        padding: 0.65rem 0.9rem;
    }
    
    /* Badges */
    .badge {
        font-size: 0.7rem;
        padding: 0.3em 0.55em;
    }
    
    /* Pagination */
    .page-link {
        min-width: 32px;
        padding: 0.35rem 0.5rem;
        font-size: 0.8rem;
    }
    
    /* Auth pages */
    .auth-wrap {
        padding: 1rem 0.75rem;
        min-height: calc(100vh - 70px);
    }
    
    .auth-card {
        max-width: 100%;
    }
    
    .auth-brand .brand-badge {
        width: 48px;
        height: 48px;
        font-size: 1.3rem;
    }
    
    .auth-brand h1 {
        font-size: 1.1rem;
    }
    
    .auth-card .card-body {
        padding: 1rem;
    }
    
    /* Kiosk */
    .kiosk-idle {
        min-height: 350px;
        border-radius: 16px;
    }
    
    .kiosk-idle-bar {
        padding: 0.6rem 0.9rem;
    }
    
    .kiosk-idle-brand {
        font-size: 0.95rem;
    }
    
    .kiosk-idle-clock {
        font-size: 1.1rem;
    }
    
    .kiosk-scan-hint {
        font-size: 0.85rem;
        padding: 0.4rem 0.75rem;
    }
    
    .kiosk-result {
        max-width: 100%;
    }
    
    .kiosk-card .kiosk-card-top {
        padding: 0.85rem 1rem;
        font-size: 1rem;
    }
    
    .kiosk-info .info-label {
        font-size: 0.8rem;
    }
    
    .kiosk-info .info-value {
        font-size: 0.95rem;
    }
    
    /* Action buttons in tables */
    .btn-group-sm > .btn, .btn-sm {
        padding: 0.25rem 0.45rem;
        font-size: 0.7rem;
    }
}

/* ---------- Small devices (576px - 767px) ---------- */
@media (min-width: 576px) and (max-width: 767px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    main.container {
        padding-top: 1rem;
        padding-bottom: 2rem;
    }
    
    .page-head {
        flex-direction: row;
        align-items: center;
    }
    
    .page-head h1, .page-head h2, .page-head .page-title {
        font-size: 1.2rem;
    }
    
    .stat-card .stat-icon {
        width: 46px;
        height: 46px;
    }
    
    .stat-card .stat-value {
        font-size: 1.4rem;
    }
    
    .modal-dialog {
        max-width: 500px;
        margin: 1rem auto;
    }
}

/* ---------- Medium devices (768px - 1023px) ---------- */
@media (min-width: 768px) and (max-width: 1023px) {
    .container {
        max-width: 720px;
    }
    
    .page-head h1, .page-head h2, .page-head .page-title {
        font-size: 1.3rem;
    }
    
    .stat-card .stat-icon {
        width: 48px;
        height: 48px;
    }
    
    .stat-card .stat-value {
        font-size: 1.5rem;
    }
    
    .modal-dialog {
        max-width: 600px;
    }
}

/* ---------- Large devices (1024px+) ---------- */
@media (min-width: 1024px) {
    .container {
        max-width: 960px;
    }
    
    .page-head h1, .page-head h2, .page-head .page-title {
        font-size: 1.4rem;
    }
    
    .stat-card .stat-icon {
        width: 52px;
        height: 52px;
    }
    
    .stat-card .stat-value {
        font-size: 1.7rem;
    }
    
    .modal-dialog.modal-lg {
        max-width: 800px;
    }
}

/* ---------- Extra large devices (1200px+) ---------- */
@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }
}

/* ---------- Touch device optimizations ---------- */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
        padding: 0.55rem 1.1rem;
    }
    
    .btn-sm {
        min-height: 36px;
        padding: 0.35rem 0.65rem;
    }
    
    .form-control, .form-select {
        min-height: 44px;
        padding: 0.55rem 0.85rem;
    }
    
    .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .dropdown-item {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .table tbody td {
        padding: 0.7rem 0.85rem;
    }
    
    .page-link {
        min-width: 40px;
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ---------- Landscape mode on mobile ---------- */
@media (max-height: 500px) and (orientation: landscape) {
    .kiosk-idle {
        min-height: 280px;
    }
    
    .kiosk-idle-bar {
        padding: 0.5rem 0.9rem;
    }
    
    .kiosk-idle-brand {
        font-size: 0.9rem;
    }
    
    .kiosk-idle-clock {
        font-size: 1.1rem;
    }
    
    .kiosk-scan-hint {
        font-size: 0.85rem;
        padding: 0.35rem 0.7rem;
    }
}

/* ---------- Print styles ---------- */
@media print {
    .navbar,
    .section-bar,
    .btn,
    .pagination,
    #pwa-install-btn {
        display: none !important;
    }
    
    body {
        background: #fff;
    }
    
    .card, .app-card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* ---------- High contrast mode ---------- */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor;
    }
    
    .form-control, .form-select {
        border-width: 2px;
    }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   ADDITIONAL MOBILE OPTIMIZATIONS
   ============================================ */

/* ---------- Very small screens (320px - 374px) ---------- */
@media (max-width: 374px) {
    body {
        font-size: 14px;
    }
    
    .container {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    main.container {
        padding-top: 0.5rem;
        padding-bottom: 1rem;
    }
    
    .navbar-brand.brand-logo {
        font-size: 0.85rem;
    }
    
    .navbar-brand.brand-logo .brand-badge {
        width: 26px;
        height: 26px;
        font-size: 0.75rem;
    }
    
    .page-head {
        margin-bottom: 0.75rem;
    }
    
    .page-head h1, .page-head h2, .page-head .page-title {
        font-size: 1rem;
    }
    
    .page-head .btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.65rem;
    }
    
    .stat-card {
        padding: 0.75rem;
        gap: 0.5rem;
    }
    
    .stat-card .stat-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
    
    .stat-card .stat-value {
        font-size: 1.1rem;
    }
    
    .stat-card .stat-label {
        font-size: 0.7rem;
    }
    
    .app-card {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    .card-body {
        padding: 0.75rem;
    }
    
    .card-header {
        padding: 0.65rem 0.75rem;
        font-size: 0.85rem;
    }
    
    .form-control, .form-select {
        font-size: 0.8rem;
        padding: 0.45rem 0.65rem;
        min-height: 38px;
    }
    
    .form-label, label {
        font-size: 0.8rem;
    }
    
    .btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.75rem;
    }
    
    .btn-sm {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }
    
    .table {
        font-size: 0.75rem;
    }
    
    .table thead th {
        padding: 0.5rem 0.55rem;
        font-size: 0.7rem;
    }
    
    .table tbody td {
        padding: 0.5rem 0.55rem;
        font-size: 0.75rem;
    }
    
    .table img {
        width: 50px !important;
        height: 50px !important;
    }
    
    .badge {
        font-size: 0.65rem;
        padding: 0.25em 0.5em;
    }
    
    .modal-dialog {
        margin: 0.4rem;
    }
    
    .modal-header {
        padding: 0.65rem 0.75rem;
    }
    
    .modal-body {
        padding: 0.75rem;
    }
    
    .modal-footer {
        padding: 0.55rem 0.75rem;
    }
    
    .auth-wrap {
        padding: 0.75rem 0.5rem;
    }
    
    .auth-brand .brand-badge {
        width: 44px;
        height: 44px;
        font-size: 1.2rem;
    }
    
    .auth-brand h1 {
        font-size: 1rem;
    }
    
    .kiosk-idle {
        min-height: 300px;
        border-radius: 12px;
    }
    
    .kiosk-idle-bar {
        padding: 0.5rem 0.75rem;
    }
    
    .kiosk-idle-brand {
        font-size: 0.85rem;
    }
    
    .kiosk-idle-clock {
        font-size: 1rem;
    }
    
    .kiosk-scan-hint {
        font-size: 0.8rem;
        padding: 0.35rem 0.65rem;
    }
}

/* ---------- Medium-small screens (375px - 414px) ---------- */
@media (min-width: 375px) and (max-width: 414px) {
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    .stat-card .stat-icon {
        width: 42px;
        height: 42px;
    }
    
    .stat-card .stat-value {
        font-size: 1.3rem;
    }
}

/* ---------- Large phones (415px - 767px) ---------- */
@media (min-width: 415px) and (max-width: 767px) {
    .stat-card .stat-icon {
        width: 46px;
        height: 46px;
    }
    
    .stat-card .stat-value {
        font-size: 1.4rem;
    }
}

/* ---------- Prevent horizontal scroll ---------- */
* {
    max-width: 100%;
    overflow-x: hidden;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ---------- Improve touch targets ---------- */
@media (max-width: 768px) {
    .btn,
    .form-control,
    .form-select,
    .nav-link,
    .dropdown-item,
    .page-link {
        min-height: 44px;
    }
    
    .btn-sm {
        min-height: 36px;
    }
    
    /* Increase spacing between touch targets */
    .btn-group-sm > .btn,
    .btn-sm {
        margin: 0.1rem;
    }
    
    .d-flex.gap-1,
    .d-flex.gap-2 {
        gap: 0.4rem !important;
    }
    
    .d-flex.gap-3 {
        gap: 0.6rem !important;
    }
}

/* ---------- Responsive images ---------- */
img {
    max-width: 100%;
    height: auto;
}

.table img {
    max-width: 80px;
    max-height: 80px;
}

@media (max-width: 575px) {
    .table img {
        max-width: 60px;
        max-height: 60px;
    }
}

/* ---------- Responsive typography ---------- */
@media (max-width: 575px) {
    h1 { font-size: 1.3rem; }
    h2 { font-size: 1.2rem; }
    h3 { font-size: 1.1rem; }
    h4 { font-size: 1rem; }
    h5 { font-size: 0.95rem; }
    h6 { font-size: 0.9rem; }
}

/* ---------- Responsive spacing ---------- */
@media (max-width: 575px) {
    .mb-2 { margin-bottom: 0.5rem !important; }
    .mb-3 { margin-bottom: 0.75rem !important; }
    .mb-4 { margin-bottom: 1rem !important; }
    .mt-2 { margin-top: 0.5rem !important; }
    .mt-3 { margin-top: 0.75rem !important; }
    .mt-4 { margin-top: 1rem !important; }
    .py-2 { padding-top: 0.5rem !important; padding-bottom: 0.5rem !important; }
    .py-3 { padding-top: 0.75rem !important; padding-bottom: 0.75rem !important; }
    .px-2 { padding-left: 0.5rem !important; padding-right: 0.5rem !important; }
    .px-3 { padding-left: 0.75rem !important; padding-right: 0.75rem !important; }
}

/* ---------- Responsive flex utilities ---------- */
@media (max-width: 575px) {
    .flex-wrap {
        flex-wrap: wrap !important;
    }
    
    .justify-content-center {
        justify-content: center !important;
    }
    
    .align-items-center {
        align-items: center !important;
    }
}

/* ---------- Responsive grid improvements ---------- */
@media (max-width: 575px) {
    .row {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
    }
    
    .row > * {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
}

/* ---------- Responsive dropdowns ---------- */
@media (max-width: 768px) {
    .dropdown-menu {
        font-size: 0.9rem;
    }
    
    .dropdown-item {
        padding: 0.5rem 1rem;
    }
}

/* ---------- Responsive pagination ---------- */
@media (max-width: 575px) {
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .page-item {
        margin: 0.1rem;
    }
}

/* ---------- Responsive alerts ---------- */
@media (max-width: 575px) {
    .alert {
        font-size: 0.85rem;
        padding: 0.75rem;
    }
    
    .alert i {
        font-size: 1rem;
    }
}

/* ---------- Responsive section bar ---------- */
@media (max-width: 767px) {
    .section-bar .container {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .section-switch {
        width: 100%;
        justify-content: center;
    }
    
    .section-hint {
        display: none;
    }
}

/* ---------- Responsive code blocks ---------- */
code {
    font-size: 0.85em;
    padding: 0.2em 0.4em;
    background: #f1f5f9;
    border-radius: 4px;
    word-break: break-all;
}

@media (max-width: 575px) {
    code {
        font-size: 0.8em;
        padding: 0.15em 0.3em;
    }
}

/* ---------- Responsive small text ---------- */
small, .small {
    font-size: 0.8rem;
}

@media (max-width: 575px) {
    small, .small {
        font-size: 0.75rem;
    }
}

/* ---------- Responsive text utilities ---------- */
@media (max-width: 575px) {
    .text-muted {
        font-size: 0.8rem;
    }
}

/* ---------- Responsive card actions ---------- */
@media (max-width: 768px) {
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .card-header .btn {
        width: 100%;
    }
}

/* ---------- Responsive form actions ---------- */
@media (max-width: 575px) {
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn {
        width: 100%;
    }
}

/* ---------- Responsive list groups ---------- */
.list-group-item {
    padding: 0.75rem 1rem;
}

@media (max-width: 575px) {
    .list-group-item {
        padding: 0.65rem 0.85rem;
        font-size: 0.9rem;
    }
}

/* ---------- Responsive nav tabs ---------- */
.nav-tabs {
    flex-wrap: wrap;
}

.nav-tabs .nav-link {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
}

@media (max-width: 575px) {
    .nav-tabs .nav-link {
        padding: 0.4rem 0.65rem;
        font-size: 0.85rem;
    }
}

/* ---------- Responsive progress bars ---------- */
.progress {
    height: 1rem;
}

@media (max-width: 575px) {
    .progress {
        height: 0.75rem;
    }
}

/* ---------- Responsive tooltips and popovers ---------- */
@media (max-width: 575px) {
    .tooltip-inner,
    .popover-header,
    .popover-body {
        font-size: 0.85rem;
        padding: 0.5rem 0.75rem;
    }
}

/* ---------- Responsive list items ---------- */
.list-group-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

@media (max-width: 575px) {
    .list-group-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

/* ---------- Responsive button groups ---------- */
.btn-group {
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .btn-group-sm > .btn,
    .btn-sm {
        padding: 0.3rem 0.5rem;
        font-size: 0.75rem;
    }
}

/* ---------- Responsive input groups ---------- */
.input-group {
    flex-wrap: wrap;
}

@media (max-width: 575px) {
    .input-group {
        flex-direction: column;
    }
    
    .input-group > * {
        width: 100%;
        margin-bottom: 0.25rem;
    }
    
    .input-group > *:last-child {
        margin-bottom: 0;
    }
}

/* ---------- Responsive breadcrumbs ---------- */
.breadcrumb {
    font-size: 0.9rem;
}

@media (max-width: 575px) {
    .breadcrumb {
        font-size: 0.8rem;
    }
    
    .breadcrumb-item + .breadcrumb-item {
        padding-left: 0.3rem;
    }
}

/* ---------- Responsive close buttons ---------- */
.btn-close {
    width: 1.2rem;
    height: 1.2rem;
}

@media (max-width: 575px) {
    .btn-close {
        width: 1rem;
        height: 1rem;
    }
}

/* ---------- Responsive focus styles ---------- */
@media (max-width: 768px) {
    .form-control:focus,
    .form-select:focus,
    .btn:focus {
        outline: 2px solid var(--brand);
        outline-offset: 2px;
    }
}

/* ---------- Responsive loading states ---------- */
.btn:disabled,
.btn.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

/* ---------- Responsive print improvements ---------- */
@media print {
    .table-responsive {
        overflow: visible;
    }
    
    .table {
        font-size: 0.8rem;
    }
    
    .btn,
    .badge {
        border: 1px solid #333;
    }
}
