/* style.css - Luxury Light Theme Design System for School Cooperative System */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Kanit:wght@300;400;500;600&family=Inter:wght@300;400;500;600;700&family=Sarabun:wght@300;400;500;600;700&display=swap');

:root {
    --bg-primary: #f8fafc;      /* Warm light slate-50 background */
    --bg-secondary: #ffffff;    /* Pure white panels */
    --bg-card: #ffffff;         /* White card backdrops */
    --bg-card-hover: #f1f5f9;   /* Slate-100 on hover */
    --border-color: #e2e8f0;    /* Slate-200 for clean subtle lines */
    --border-hover: #a5b4fc;    /* Indigo-300 on focus/hover */
    
    --primary: #4f46e5;         /* Indigo-600 for rich contrast */
    --primary-hover: #4338ca;   /* Indigo-700 */
    --primary-glow: rgba(79, 70, 229, 0.12);
    
    --success: #059669;         /* Emerald-600 */
    --success-hover: #047857;
    --success-glow: rgba(5, 150, 105, 0.1);
    
    --warning: #d97706;         /* Amber-600 */
    --warning-glow: rgba(217, 119, 6, 0.1);
    
    --danger: #e11d48;          /* Rose-600 */
    --danger-hover: #be123c;
    
    --gold: #b45309;            /* Bronze/Gold accent for text */
    --text-primary: #1e293b;    /* Slate-800 main body text */
    --text-muted: #64748b;      /* Slate-500 secondary labels */
    --text-dark: #0f172a;       /* Slate-900 titles */
    
    --font-heading: 'Outfit', 'Kanit', sans-serif;
    --font-body: 'Inter', 'Sarabun', sans-serif;
    --sidebar-width: 280px;
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.03);
    --shadow-md: 0 4px 20px -2px rgba(15, 23, 42, 0.08), 0 2px 8px -1px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 20px 25px -5px rgba(15, 23, 42, 0.08), 0 10px 10px -5px rgba(15, 23, 42, 0.03);
}

/* Global Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--text-dark);
    letter-spacing: -0.010em;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-sm);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Layout Grid */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    padding: 1.5rem;
    box-shadow: 2px 0 10px rgba(15, 23, 42, 0.02);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 2rem;
}

.brand-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--warning) 100%);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px var(--primary-glow);
    color: #fff;
}

.brand-name {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-dark) 50%, var(--text-muted) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.2;
}

.brand-name span {
    font-size: 0.75rem;
    display: block;
    color: var(--gold);
    -webkit-text-fill-color: var(--gold);
    font-weight: 500;
    letter-spacing: 0.5px;
}

.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex-grow: 1;
    overflow-y: auto;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.8rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
    border: 1px solid transparent;
}

.nav-item a:hover {
    color: var(--primary);
    background-color: var(--bg-primary);
}

.nav-item.active a {
    color: var(--primary);
    background: linear-gradient(90deg, rgba(79, 70, 229, 0.06) 0%, rgba(79, 70, 229, 0.01) 100%);
    border-left: 3px solid var(--primary);
    border-color: transparent transparent transparent var(--primary);
    font-weight: 600;
}

.nav-item i {
    width: 20px;
    height: 20px;
    transition: var(--transition-fast);
}

.nav-item.active i {
    color: var(--primary);
}

.sidebar-user {
    border-top: 1px solid var(--border-color);
    padding-top: 1.25rem;
    margin-top: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    flex-direction: column;
    max-width: 170px;
}

.user-name {
    font-weight: 600;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.9rem;
}

.user-role {
    font-size: 0.75rem;
    color: var(--gold);
    font-weight: 500;
}

.btn-logout {
    color: var(--text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: var(--transition-fast);
    padding: 0.4rem;
    border-radius: var(--radius-sm);
}

.btn-logout:hover {
    color: var(--danger);
    background-color: rgba(225, 29, 72, 0.06);
}

/* Main Content Area */
.main-content {
    margin-left: var(--sidebar-width);
    flex-grow: 1;
    min-height: 100vh;
    padding: 2.5rem;
    background-color: var(--bg-primary);
    min-width: 0;
}

/* Header Action Section */
.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
}

.header-title h1 {
    font-size: 1.75rem;
    color: var(--text-dark);
    font-weight: 700;
}

.header-title p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

/* Beautiful Cards */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.8rem 1.15rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    text-decoration: none !important;
}

.stat-card:hover {
    transform: translateY(-3px);
    border-color: var(--primary);
    box-shadow: 0 8px 16px rgba(79, 70, 229, 0.08), 0 4px 4px rgba(79, 70, 229, 0.06);
}

.stat-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-grow: 1;
    margin-right: 0.5rem;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-value {
    font-size: 1.35rem;
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--text-dark);
    margin-top: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-desc {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-desc.up { color: var(--success); font-weight: 500; }
.stat-desc.down { color: var(--danger); font-weight: 500; }

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

.stat-icon.primary { background: rgba(79, 70, 229, 0.08); color: var(--primary); }
.stat-icon.success { background: rgba(5, 150, 105, 0.08); color: var(--success); }
.stat-icon.warning { background: rgba(217, 119, 6, 0.08); color: var(--warning); }
.stat-icon.danger { background: rgba(225, 29, 72, 0.08); color: var(--danger); }

/* Main layouts (Grid dashboard) */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.panel {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    box-shadow: var(--shadow-sm);
    position: relative;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}

.panel-title {
    font-size: 1.1rem;
    color: var(--text-dark);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.panel-title i {
    color: var(--primary);
}

/* Beautiful Inputs & Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 1rem;
    color: var(--text-muted);
    pointer-events: none;
    width: 18px;
    height: 18px;
}

.form-control {
    width: 100%;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-dark);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.form-control[readonly] {
    background-color: #f1f5f9;
    color: var(--text-muted);
    cursor: not-allowed;
}

.input-with-icon {
    padding-left: 2.75rem;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.1rem;
}

/* Modern Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: var(--font-heading);
    font-weight: 600;
    padding: 0.7rem 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition-fast);
    font-size: 0.9rem;
    text-decoration: none;
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.15);
}
.btn-primary:hover {
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
    filter: brightness(1.05);
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, var(--success-hover) 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.15);
}
.btn-success:hover {
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
    filter: brightness(1.05);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, var(--danger-hover) 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(225, 29, 72, 0.15);
}
.btn-danger:hover {
    box-shadow: 0 4px 12px rgba(225, 29, 72, 0.3);
    filter: brightness(1.05);
}

.btn-secondary {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}
.btn-secondary:hover {
    background-color: #f8fafc;
    color: var(--text-dark);
    border-color: var(--text-muted);
}

.btn-icon-only {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-md);
}

/* Beautiful Tables */
.table-responsive {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.table th {
    background-color: #f8fafc;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: middle;
    font-size: 0.85rem;
    white-space: nowrap;
}

.table td.wrap-text, .table th.wrap-text {
    white-space: normal;
}

.table tr:last-child td {
    border-bottom: none;
}

.table tbody tr {
    transition: var(--transition-fast);
}

.table tbody tr:hover {
    background-color: #f8fafc;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
    line-height: 1;
}

.badge-primary { background-color: rgba(79, 70, 229, 0.08); color: var(--primary); }
.badge-success { background-color: rgba(5, 150, 105, 0.08); color: var(--success); }
.badge-warning { background-color: rgba(217, 119, 6, 0.08); color: var(--warning); }
.badge-danger { background-color: rgba(225, 29, 72, 0.08); color: var(--danger); }

/* Custom POS Styling */
.pos-top-bar {
    display: grid;
    grid-template-columns: 1fr 1.25fr 1.25fr;
    gap: 1rem;
    margin-bottom: 1rem;
    height: 80px;
}

@media screen and (max-width: 992px) {
    .pos-top-bar {
        grid-template-columns: 1fr !important;
        margin-bottom: 0.5rem !important;
        gap: 0.5rem !important;
    }
}

.pos-container {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 1.5rem;
    height: calc(100vh - 225px);
    overflow: hidden;
}

.pos-cart-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.pos-checkout-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 0.85rem;
    overflow-y: auto;
    box-shadow: var(--shadow-sm);
}

.pos-checkout-panel .panel {
    flex-shrink: 0;
}

.pos-scanner-header {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.pos-cart-items {
    flex-grow: 1;
    overflow-y: auto;
    margin-top: 1rem;
}

.qty-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.qty-btn {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    background-color: #f1f5f9;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.qty-btn:hover {
    background-color: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.qty-input {
    width: 40px;
    text-align: center;
    border: none;
    background: transparent;
    color: var(--text-dark);
    font-weight: 600;
}

/* POS Payment and Summary */
.checkout-summary {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    border-top: 1px solid var(--border-color);
    padding-top: 1.25rem;
    margin-top: auto;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.summary-row.grand-total {
    font-size: 1.5rem;
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--text-dark);
    border-top: 1px dashed var(--border-color);
    padding-top: 0.75rem;
    margin-top: 0.5rem;
}

.payment-numpad {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.4rem;
    margin: 0.5rem 0;
}

.numpad-btn {
    background-color: #f1f5f9;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 0.45rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
}

.numpad-btn:hover {
    background-color: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* Dialog Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 200000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    box-sizing: border-box;
}

.swal2-container {
    z-index: 300000 !important;
}

@keyframes rowHighlight {
    0% { background-color: rgba(59, 130, 246, 0.35); }
    50% { background-color: rgba(59, 130, 246, 0.15); }
    100% { background-color: transparent; }
}
.row-flash {
    animation: rowHighlight 1.5s ease-in-out;
}

.modal-content {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    max-height: calc(100vh - 4rem);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    position: relative;
    animation: modalFadeIn 0.2s ease-out;
    overflow-y: auto;
    box-sizing: border-box;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.modal-close:hover {
    color: var(--danger);
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Receipt Print layout */
.receipt-wrapper {
    background: #fff;
    color: #000;
    padding: 20px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px;
    max-width: 320px;
    margin: 0 auto;
    border: 1px solid #ccc;
}

.receipt-header {
    text-align: center;
    margin-bottom: 15px;
}

.receipt-logo {
    font-size: 16px;
    font-weight: bold;
}

.receipt-divider {
    border-top: 1px dashed #000;
    margin: 10px 0;
}

.receipt-item-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

/* Chart Container styling */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* Barcode print layout styles */
.barcode-svg-container {
    background-color: #fff;
    padding: 10px;
    border-radius: var(--radius-sm);
    display: inline-block;
}

/* PDF Print Page Style */
@media print {
    body {
        background-color: #fff !important;
        color: #000 !important;
    }
    .sidebar, .header-actions, .btn, .no-print {
        display: none !important;
    }
    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }
    .panel {
        border: none !important;
        box-shadow: none !important;
        background: transparent !important;
    }
    .table th {
        background-color: #eee !important;
        color: #000 !important;
    }
    .table td {
        color: #000 !important;
    }
}

/* Utility alert boxes */
.alert {
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    border: 1px solid transparent;
}

.alert-success {
    background-color: rgba(5, 150, 105, 0.06);
    color: var(--success);
    border-color: rgba(5, 150, 105, 0.15);
}

.alert-danger {
    background-color: rgba(225, 29, 72, 0.06);
    color: var(--danger);
    border-color: rgba(225, 29, 72, 0.15);
}

/* Camera Scanner Area */
#interactive-scanner {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    background-color: #000;
    border-radius: var(--radius-md);
    overflow: hidden;
}

/* User Login View */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(circle at 10% 20%, #f1f5f9 0%, #cbd5e1 90%);
}

.login-card {
    background-color: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header .logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--warning) 100%);
    border-radius: var(--radius-lg);
    color: white;
    font-size: 2rem;
    margin-bottom: 1rem;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.2);
}

.login-header h2 {
    font-size: 1.5rem;
    color: var(--text-dark);
    margin-bottom: 0.25rem;
}

.login-header p {
    color: var(--text-muted);
}

/* ==========================================
   RESPONSIVE DESIGN & MOBILE OPTIMIZATION
   ========================================== */


/* หน้าจอแท็บเล็ตและมือถือขนาดกลาง (Tablet Landscape/Portrait) */
@media screen and (max-width: 1024px) {
    :root {
        --sidebar-width: 260px;
    }
    
    .sidebar {
        left: calc(-1 * var(--sidebar-width)) !important;
        transition: left var(--transition-normal);
        z-index: 1001 !important;
        box-shadow: var(--shadow-lg);
    }
    
    .sidebar.active {
        left: 0 !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        padding: 1.5rem !important;
    }
    
    /* ปุ่มเมนู Hamburger ลอยตัว */
    .mobile-menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        background-color: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        color: var(--primary);
        cursor: pointer;
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 1000;
        box-shadow: var(--shadow-md);
        transition: var(--transition-fast);
    }
    
    .mobile-menu-toggle:hover {
        background-color: var(--primary-glow);
        border-color: var(--primary);
    }
    
    /* ปรับแต่งเว้นระยะเผื่อหัวปุ่ม Hamburger */
    .content-header {
        margin-top: 3.5rem;
        flex-direction: row;
    }
}

/* จุดตัดปรับเลย์เอาต์ POS (Tablet Portrait / Large Mobile) */
@media screen and (max-width: 992px) {
    .pos-container {
        grid-template-columns: 1fr !important;
        height: auto !important;
        overflow: visible !important;
        gap: 1.25rem !important;
    }
    
    .pos-cart-panel {
        height: auto !important;
        min-height: 400px !important;
    }
    
    .pos-checkout-panel {
        height: auto !important;
        min-height: 450px !important;
        overflow: visible !important;
    }
    
    /* ปรับแก้ให้ความกว้าง 100% เสมอ */
    .pos-cart-items {
        overflow-x: auto !important;
        width: 100% !important;
    }
}

/* อุปกรณ์มือถือขนาดเล็ก (Small Mobile Phones) */
@media screen and (max-width: 640px) {
    .content-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1rem !important;
        margin-top: 4rem;
    }
    
    .header-actions {
        width: 100% !important;
        flex-wrap: wrap;
    }
    
    .header-actions .btn {
        flex: 1 1 auto;
        justify-content: center;
    }
    
    /* ส่วนหัวค้นหาของบาร์โค้ด */
    .pos-scanner-header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem !important;
    }
    
    .pos-scanner-header .btn {
        width: 100% !important;
        justify-content: center;
    }
    
    /* สเกลความกว้างตารางในใบรับของ/ตะกร้าบนจอมือถือเล็ก */
    .pos-cart-items table {
        min-width: 500px !important;
    }
    
    /* กล่องข้อความเงินทอน ยอดชำระสุทธิในใบเสร็จ */
    .summary-row.grand-total {
        font-size: 1.2rem !important;
    }
}

/* ==========================================================================
   Official PDF Document Styles (Thai Government / Formal Format)
   ========================================================================== */
body.printing-pdf-active {
    font-family: 'Sarabun', 'TH Sarabun New', 'TH Sarabun PSK', sans-serif !important;
    font-size: 13px !important;
    background: #ffffff !important;
    color: #000000 !important;
}

body.printing-pdf-active * {
    letter-spacing: normal !important;
    text-shadow: none !important;
    box-shadow: none !important;
    font-feature-settings: "kern" 0 !important;
    font-weight: normal !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
}

body.printing-pdf-active .main-content {
    padding: 0 !important;
    margin: 0 !important;
    background: #ffffff !important;
}

/* Hide sidebars and other non-print elements */
body.printing-pdf-active .sidebar,
body.printing-pdf-active .no-print,
body.printing-pdf-active button,
body.printing-pdf-active .btn,
body.printing-pdf-active .mobile-menu-toggle {
    display: none !important;
}

/* Format the print container */
body.printing-pdf-active #sales-report-print,
body.printing-pdf-active #stock-report-print,
body.printing-pdf-active #dividend-report-print,
body.printing-pdf-active #restock-report-print {
    background: #ffffff !important;
    color: #000000 !important;
    padding: 8px 12px !important;
    font-family: 'Sarabun', 'TH Sarabun New', sans-serif !important;
    width: 100% !important;
}

/* Custom styling for official document look */
body.printing-pdf-active .print-header {
    display: block !important;
    text-align: center;
    margin-bottom: 18px;
    font-family: 'Sarabun', 'TH Sarabun New', sans-serif !important;
}

body.printing-pdf-active .print-header h2 {
    font-size: 16px !important;
    font-weight: bold !important;
    color: #000000 !important;
    margin-bottom: 4px;
    letter-spacing: normal !important;
}

body.printing-pdf-active .print-header div {
    font-size: 14px !important;
    font-weight: normal !important;
    color: #000000 !important;
    margin-bottom: 3px;
    letter-spacing: normal !important;
}

/* Style cards for printing */
body.printing-pdf-active .card-grid {
    display: flex !important;
    gap: 10px !important;
    margin-bottom: 15px !important;
    grid-template-columns: repeat(3, 1fr) !important;
}

body.printing-pdf-active .stat-card {
    background: #ffffff !important;
    border: 1px solid #000000 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 8px 10px !important;
    color: #000000 !important;
    flex: 1;
}

body.printing-pdf-active .stat-card .stat-label {
    color: #000000 !important;
    font-size: 12px !important;
    font-weight: normal !important;
    display: block !important;
}

body.printing-pdf-active .stat-card .stat-value {
    color: #000000 !important;
    font-size: 15px !important;
    font-weight: bold !important;
    display: block !important;
    margin: 2px 0 !important;
}

body.printing-pdf-active .stat-card .stat-desc {
    color: #444444 !important;
    font-size: 11px !important;
    font-weight: normal !important;
    display: block !important;
}

body.printing-pdf-active .stat-icon {
    display: none !important;
}

/* Style tables for official look */
body.printing-pdf-active .panel {
    background: #ffffff !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
}

body.printing-pdf-active .panel-header {
    display: none !important;
}

body.printing-pdf-active table.table {
    width: 100% !important;
    table-layout: fixed !important;
    border-collapse: collapse !important;
    font-size: 12px !important;
    font-family: 'Sarabun', 'TH Sarabun New', sans-serif !important;
    color: #000000 !important;
    margin-top: 10px !important;
    word-wrap: break-word !important;
}

body.printing-pdf-active table.table th,
body.printing-pdf-active table.table td {
    border: 1px solid #333333 !important;
    padding: 5px 6px !important;
    color: #000000 !important;
    background: transparent !important;
    font-family: 'Sarabun', 'TH Sarabun New', sans-serif !important;
    font-size: 12px !important;
    font-weight: normal !important;
    text-align: left;
    letter-spacing: normal !important;
    vertical-align: middle !important;
    word-break: break-word !important;
    overflow: hidden !important;
}

body.printing-pdf-active table.table th {
    background-color: #e8ecf0 !important;
    font-weight: bold !important;
    font-size: 12px !important;
    text-align: center !important;
}

/* Only bold important numeric values in table cells */
body.printing-pdf-active table.table td strong,
body.printing-pdf-active table.table td b {
    font-weight: bold !important;
}

body.printing-pdf-active table.table td code {
    font-family: 'Sarabun', 'TH Sarabun New', sans-serif !important;
    font-size: 11px !important;
    font-weight: normal !important;
    background: transparent !important;
    padding: 0 !important;
    border: none !important;
    word-break: break-all !important;
}

/* Inline color overrides: reset colored text in table to black */
body.printing-pdf-active table.table td [style*="color"] {
    color: #000000 !important;
}

/* Remove table-responsive overflow */
body.printing-pdf-active .table-responsive {
    overflow: visible !important;
    overflow-x: visible !important;
}

/* Add a signature/approval block at the bottom */
body.printing-pdf-active .print-signature-block {
    display: flex !important;
    justify-content: space-between;
    margin-top: 40px !important;
    font-family: 'Sarabun', 'TH Sarabun New', sans-serif !important;
    font-size: 13px !important;
    font-weight: normal !important;
    color: #000000 !important;
    border: none !important;
    padding: 0 !important;
    background: transparent !important;
}

body.printing-pdf-active .print-signature-block .sig-col {
    width: 240px;
    text-align: center;
    font-size: 13px !important;
    font-weight: normal !important;
    line-height: 1.6 !important;
}

/* Compact styling for POS checkout sidebar on low-height screens or tablets in landscape */
@media screen and (min-width: 993px) and (max-height: 850px) {
    .pos-checkout-panel {
        padding: 0.4rem !important;
    }
    .pos-checkout-panel .panel {
        padding: 0.35rem 0.5rem !important;
        margin-bottom: 0.25rem !important;
    }
    .pos-checkout-panel h4 {
        font-size: 0.75rem !important;
        margin-bottom: 0.25rem !important;
    }
    .pos-checkout-panel .form-control {
        height: 28px !important;
        font-size: 0.75rem !important;
        padding: 0.2rem 0.4rem !important;
    }
    .pos-checkout-panel .btn {
        height: 28px !important;
        font-size: 0.75rem !important;
        padding: 0.2rem 0.6rem !important;
    }
    .pos-checkout-panel #linked-member-info, 
    .pos-checkout-panel #linked-student-info,
    .pos-checkout-panel #seller-info-box {
        padding: 0.35rem !important;
        margin-top: 0.2rem !important;
    }
    .pos-checkout-panel #linked-member-info div,
    .pos-checkout-panel #linked-student-info div,
    .pos-checkout-panel #seller-info-box div {
        font-size: 0.72rem !important;
    }
    .pos-checkout-panel #linked-member-info span,
    .pos-checkout-panel #linked-student-info span {
        font-size: 0.68rem !important;
    }
    .pos-checkout-panel #student-points-redemption {
        margin-top: 0.2rem !important;
        padding-top: 0.2rem !important;
        gap: 0.2rem !important;
    }
    .pos-checkout-panel #student-points-redemption input {
        height: 20px !important;
        font-size: 0.65rem !important;
        width: 50px !important;
    }
    .pos-checkout-panel #student-points-redemption button {
        height: 20px !important;
        font-size: 0.6rem !important;
    }
    
    /* Payment Summary compact rules */
    .pos-checkout-panel .summary-row {
        font-size: 0.75rem !important;
        margin-bottom: 0.2rem !important;
    }
    .pos-checkout-panel .summary-row input#calc-discount {
        width: 70px !important;
        height: 24px !important;
        font-size: 0.75rem !important;
    }
    .pos-checkout-panel .summary-row.grand-total {
        font-size: 1.1rem !important;
        padding-top: 0.35rem !important;
        margin-top: 0.2rem !important;
    }
    .pos-checkout-panel #cash-received {
        font-size: 1.1rem !important;
        height: 32px !important;
        padding: 0.2rem 0.4rem !important;
    }
    .pos-checkout-panel #change-amount {
        font-size: 0.95rem !important;
    }
    .pos-checkout-panel .payment-numpad {
        gap: 0.25rem !important;
        margin: 0.25rem 0 !important;
    }
    .pos-checkout-panel .numpad-btn {
        padding: 0.25rem !important;
        font-size: 0.75rem !important;
    }
    .pos-checkout-panel .btn-success {
        padding: 0.45rem !important;
        font-size: 0.9rem !important;
    }
}

/* Even more compact for very low heights (e.g. smaller landscape screens or tablets) */
@media screen and (min-width: 993px) and (max-height: 700px) {
    .pos-checkout-panel {
        padding: 0.25rem !important;
    }
    .pos-checkout-panel .panel {
        padding: 0.25rem 0.4rem !important;
        margin-bottom: 0.15rem !important;
    }
    .pos-checkout-panel h4 {
        font-size: 0.7rem !important;
        margin-bottom: 0.15rem !important;
    }
    .pos-checkout-panel .form-control {
        height: 24px !important;
        font-size: 0.7rem !important;
    }
    .pos-checkout-panel .btn {
        height: 24px !important;
        font-size: 0.7rem !important;
    }
    .pos-checkout-panel #linked-member-info, 
    .pos-checkout-panel #linked-student-info,
    .pos-checkout-panel #seller-info-box {
        padding: 0.25rem !important;
        margin-top: 0.15rem !important;
    }
    .pos-checkout-panel #linked-member-info div,
    .pos-checkout-panel #linked-student-info div,
    .pos-checkout-panel #seller-info-box div {
        font-size: 0.7rem !important;
    }
    .pos-checkout-panel #student-points-redemption input {
        height: 18px !important;
        font-size: 0.6rem !important;
    }
    .pos-checkout-panel #student-points-redemption button {
        height: 18px !important;
        font-size: 0.55rem !important;
    }
    .pos-checkout-panel .summary-row {
        font-size: 0.7rem !important;
        margin-bottom: 0.15rem !important;
    }
    .pos-checkout-panel .summary-row.grand-total {
        font-size: 1rem !important;
        padding-top: 0.25rem !important;
        margin-top: 0.15rem !important;
    }
    .pos-checkout-panel #cash-received {
        font-size: 1rem !important;
        height: 28px !important;
    }
    .pos-checkout-panel #change-amount {
        font-size: 0.85rem !important;
    }
    .pos-checkout-panel .numpad-btn {
        padding: 0.2rem !important;
        font-size: 0.7rem !important;
    }
    .pos-checkout-panel .btn-success {
        padding: 0.35rem !important;
        font-size: 0.8rem !important;
    }
}

@media screen and (max-width: 768px) {
    #user-editor-form-col {
        border-left: none !important;
        padding-left: 0 !important;
        border-top: 1px solid var(--border-color);
        padding-top: 1.5rem;
        margin-top: 1rem;
}
}

/* Bulk actions bar styling */
.bulk-action-bar {
    position: fixed;
    bottom: 2rem;
    left: 55%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #fff;
    padding: 0.85rem 1.75rem;
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.bulk-action-content {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    font-weight: 500;
}
.bulk-action-content span {
    font-size: 0.95rem;
}
@keyframes slideUp {
    from { transform: translate(-50%, 100%); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

@media screen and (max-width: 1024px) {
    .bulk-action-bar {
        left: 50%;
        width: 90%;
        bottom: 1rem;
    }
}

/* PWA Installation Toast Banner & UI */
.pwa-toast-banner {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 40px;
    padding: 6px 10px 6px 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 16px -6px rgba(0, 0, 0, 0.3);
    z-index: 999999;
    width: auto;
    max-width: 90%;
    min-width: 290px;
    animation: pwaSlideUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pwa-toast-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pwa-toast-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pwa-toast-icon img {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    object-fit: contain;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.pwa-toast-text {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    text-align: left;
    margin-right: 12px;
}

.pwa-toast-text h4 {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 600;
    color: #ffffff;
    line-height: 1.2;
}

.pwa-toast-text p {
    margin: 1px 0 0;
    font-size: 0.68rem;
    color: #94a3b8;
    line-height: 1.2;
}

.pwa-toast-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pwa-toast-btn-install {
    background: #4f46e5;
    color: #ffffff;
    border: none;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.pwa-toast-btn-install:hover {
    background: #6366f1;
}

.pwa-toast-btn-install:active {
    transform: scale(0.95);
}

.pwa-toast-btn-later {
    background: transparent;
    color: #94a3b8;
    border: none;
    padding: 6px 10px;
    font-size: 0.72rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s;
}

.pwa-toast-btn-later:hover {
    color: #ffffff;
}

@keyframes pwaSlideUp {
    from {
        transform: translate(-50%, 120%);
        opacity: 0;
    }
    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

@media screen and (max-width: 576px) {
    .pwa-toast-banner {
        bottom: 16px;
        min-width: 270px;
        padding: 5px 8px 5px 10px;
    }
    .pwa-toast-text h4 {
        font-size: 0.75rem;
    }
    .pwa-toast-text p {
        font-size: 0.62rem;
    }
    .pwa-toast-btn-install {
        padding: 5px 10px;
        font-size: 0.7rem;
    }
    .pwa-toast-btn-later {
        padding: 5px 6px;
        font-size: 0.68rem;
    }
}

/* Global Notification Bell */
.global-notification-bell {
    position: fixed;
    top: 1.5rem;
    right: 2.5rem;
    z-index: 1000;
}

.notif-bell-btn {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-dark);
    width: 2.75rem;
    height: 2.75rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.notif-bell-btn:hover {
    background: var(--bg-card-hover);
    color: var(--primary);
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.notif-bell-btn svg {
    width: 1.25rem;
    height: 1.25rem;
}

.notif-bell-btn .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: var(--danger);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 1.1rem;
    height: 1.1rem;
    padding: 0 0.2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-secondary);
}

/* Dropdown */
.notif-dropdown {
    position: absolute;
    top: 3.25rem;
    right: 0;
    width: 320px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideDown 0.2s ease-out;
}

.notif-dropdown.active {
    display: flex;
}

.notif-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.notif-header h3 {
    font-size: 0.9rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-dark);
}

.clear-all-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.clear-all-btn:hover {
    color: var(--danger);
}

.notif-list {
    max-height: 280px;
    overflow-y: auto;
}

.notif-item {
    display: flex;
    flex-direction: column;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition-fast);
    cursor: pointer;
    text-align: left;
}

.notif-item:hover {
    background-color: var(--bg-card-hover);
}

.notif-item.unread {
    background-color: rgba(79, 70, 229, 0.04);
}

.notif-item-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.2rem;
}

.notif-item-body {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.3;
}

.notif-item-time {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
    text-align: right;
}

.notif-empty {
    padding: 1.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media screen and (max-width: 1024px) {
    .global-notification-bell {
        top: 15px;
        right: 15px;
    }
}


