/* =====================================================
   ICE SHOP POS — Stylesheet (Anzen-inspired design)
   ===================================================== */

:root {
    /* Ice cream themed palette */
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --primary-bg: rgba(99, 102, 241, 0.08);

    --success: #10b981;
    --success-light: #34d399;
    --success-bg: rgba(16, 185, 129, 0.08);

    --warning: #f59e0b;
    --warning-light: #fbbf24;
    --warning-bg: rgba(245, 158, 11, 0.08);

    --danger: #ef4444;
    --danger-light: #f87171;
    --danger-bg: rgba(239, 68, 68, 0.08);

    --info: #06b6d4;
    --info-light: #22d3ee;
    --info-bg: rgba(6, 182, 212, 0.08);

    /* Grays */
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    /* Sidebar */
    --sidebar-bg: #0f172a;
    --sidebar-hover: rgba(255, 255, 255, 0.06);
    --sidebar-active: rgba(99, 102, 241, 0.15);
    --sidebar-text: #cbd5e1;
    --sidebar-width: 260px;

    /* Layout */
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px rgba(0, 0, 0, 0.04);
    --transition: all 0.2s ease;
}

/* ==================== Reset ==================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Noto Sans Thai', 'Inter', -apple-system, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    font-size: 14px;
    line-height: 1.6;
    overflow-x: hidden;
}

a {
    color: var(--primary);
    text-decoration: none;
}

img {
    max-width: 100%;
}

/* ==================== Login ==================== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: 20px;
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.login-logo {
    text-align: center;
    margin-bottom: 36px;
}

.logo-icon {
    font-size: 56px;
    margin-bottom: 12px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

.login-logo h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
}

.login-subtitle {
    color: var(--gray-400);
    font-size: 14px;
    margin-top: 4px;
}

/* ==================== Forms ==================== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--gray-600);
}

.input-icon {
    position: relative;
}

.input-icon i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--gray-400);
    pointer-events: none;
}

.input-icon input,
.input-icon select {
    padding-left: 42px;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--gray-800);
    background: white;
    transition: var(--transition);
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

/* ==================== Buttons ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn i {
    width: 16px;
    height: 16px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-outline {
    background: white;
    border: 1.5px solid var(--gray-200);
    color: var(--gray-600);
}

.btn-outline:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn-icon {
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: var(--gray-500);
    border-radius: 6px;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
}

.btn-icon:hover {
    background: var(--gray-100);
}

.btn-icon i {
    width: 18px;
    height: 18px;
}

/* ==================== Sidebar ==================== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.shop-logo {
    font-size: 32px;
}

.shop-info h2 {
    font-size: 16px;
    font-weight: 700;
    color: white;
    line-height: 1.3;
}

.branch-badge {
    display: inline-block;
    padding: 2px 8px;
    background: var(--primary);
    color: white;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    color: var(--sidebar-text);
    cursor: pointer;
    transition: var(--transition);
    border-left: 3px solid transparent;
    font-size: 14px;
}

.nav-item:hover {
    background: var(--sidebar-hover);
}

.nav-item.active {
    background: var(--sidebar-active);
    color: white;
    border-left-color: var(--primary);
}

.nav-item i {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary-bg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-avatar i {
    width: 18px;
    height: 18px;
    color: var(--primary);
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    color: white;
}

.user-role {
    font-size: 11px;
    color: var(--gray-400);
}

.sidebar-footer .btn-icon {
    color: var(--gray-400);
}

.sidebar-footer .btn-icon:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

/* ==================== Main Content ==================== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    width: calc(100% - var(--sidebar-width));
    transition: margin 0.3s ease, width 0.3s ease;
}

.top-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 28px;
    background: white;
    border-bottom: 1px solid var(--gray-100);
    position: sticky;
    top: 0;
    z-index: 50;
}

.top-bar h1 {
    font-size: 18px;
    font-weight: 700;
    flex: 1;
}

.sidebar-toggle {
    display: none;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.staff-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--success-bg);
    color: var(--success);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.staff-badge i {
    width: 16px;
    height: 16px;
}

.branch-selector select {
    padding: 6px 12px;
    border-radius: 20px;
    border: 1.5px solid var(--gray-200);
    font-size: 13px;
    background: white;
    cursor: pointer;
}

.page-content {
    padding: 24px 28px;
    width: 100%;
    box-sizing: border-box;
}

.page-content>.card,
.page-content>.table-wrapper,
.page-content>div {
    width: 100%;
    box-sizing: border-box;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ==================== Cards ==================== */
.card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 15px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-label {
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
}

/* ==================== Table ==================== */
.table-wrapper {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--gray-100);
    font-size: 13px;
}

.table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-600);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table tr:hover td {
    background: rgba(99, 102, 241, 0.02);
}

/* ==================== Badge ==================== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-primary {
    background: var(--primary-bg);
    color: var(--primary);
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info);
}

/* ==================== Alert ==================== */
.alert {
    padding: 12px 16px;
    border-radius: var(--border-radius-sm);
    font-size: 13px;
    margin-top: 16px;
}

.alert-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.15);
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
}

.alert-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.alert-info {
    background: var(--info-bg);
    color: var(--info);
}

/* ==================== Toast ==================== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: white;
    padding: 14px 20px;
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 280px;
    animation: slideIn 0.3s ease;
    border-left: 4px solid var(--success);
    font-size: 13px;
}

.toast.error {
    border-left-color: var(--danger);
}

.toast.info {
    border-left-color: var(--info);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(40px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ==================== Modal ==================== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal {
    background: white;
    border-radius: var(--border-radius);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    animation: scaleIn 0.2s ease;
}

@keyframes scaleIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-body {
    padding: 24px;
}

/* ==================== POS Layout ==================== */
.pos-container {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 0;
    height: calc(100vh - 64px);
}

.pos-menu-area {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pos-tabs {
    display: flex;
    border-bottom: 2px solid var(--gray-100);
    background: white;
    padding: 0 16px;
}

.pos-tab {
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    color: var(--gray-500);
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}

.pos-tab:hover {
    color: var(--gray-700);
}

.pos-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.pos-categories {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    overflow-x: auto;
    background: white;
    border-bottom: 1px solid var(--gray-100);
}

.cat-chip {
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    background: var(--gray-100);
    color: var(--gray-600);
    transition: var(--transition);
    border: none;
}

.cat-chip.active {
    background: var(--primary);
    color: white;
}

.cat-chip:hover:not(.active) {
    background: var(--gray-200);
}

.pos-menu-grid {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    align-content: start;
}

.menu-card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: var(--transition);
    overflow: hidden;
}

.menu-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.menu-card-img {
    width: 100%;
    height: 110px;
    object-fit: cover;
    background: var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
}

.menu-card-body {
    padding: 10px 12px;
}

.menu-card-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-800);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.menu-card-price {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary);
    margin-top: 2px;
}

/* Barcode scan area */
.pos-scan-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    gap: 20px;
}

.scan-input-wrapper {
    width: 100%;
    max-width: 400px;
}

.scan-input-wrapper input {
    padding: 14px 20px;
    font-size: 18px;
    text-align: center;
    border: 2px solid var(--gray-200);
    border-radius: var(--border-radius);
}

.scan-input-wrapper input:focus {
    border-color: var(--info);
    box-shadow: 0 0 0 4px rgba(6, 182, 212, 0.15);
}

/* Cart */
.pos-cart {
    background: white;
    border-left: 1px solid var(--gray-100);
    display: flex;
    flex-direction: column;
}

.cart-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-100);
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.cart-item {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    gap: 12px;
    border-bottom: 1px solid var(--gray-50);
}

.cart-item-info {
    flex: 1;
}

.cart-item-name {
    font-size: 13px;
    font-weight: 500;
}

.cart-item-detail {
    font-size: 11px;
    color: var(--gray-400);
}

.cart-item-price {
    font-weight: 600;
    font-size: 14px;
    color: var(--primary);
    white-space: nowrap;
}

.cart-item-qty {
    display: flex;
    align-items: center;
    gap: 6px;
}

.qty-btn {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1.5px solid var(--gray-200);
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--gray-600);
    transition: var(--transition);
}

.qty-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.cart-footer {
    border-top: 2px solid var(--gray-100);
    padding: 16px 20px;
}

.cart-total {
    display: flex;
    justify-content: space-between;
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 16px;
}

.cart-total .amount {
    color: var(--primary);
}

.cart-actions {
    display: flex;
    gap: 8px;
}

.cart-actions .btn {
    flex: 1;
    justify-content: center;
    padding: 12px;
}

/* ==================== Menu Grid (Management) ==================== */
.menu-manage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

/* ==================== Empty State ==================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-400);
}

.empty-state i {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
}

.empty-state p {
    font-size: 14px;
}

/* ==================== Utilities ==================== */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--gray-400);
}

.text-sm {
    font-size: 12px;
}

.text-success {
    color: var(--success);
}

.text-danger {
    color: var(--danger);
}

.text-warning {
    color: var(--warning);
}

.text-primary {
    color: var(--primary);
}

.font-mono {
    font-family: 'Courier New', monospace;
}

.mt-1 {
    margin-top: 8px;
}

.mt-2 {
    margin-top: 16px;
}

.mt-3 {
    margin-top: 24px;
}

.mb-2 {
    margin-bottom: 16px;
}

.flex {
    display: flex;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ==================== Branch Selection ==================== */
.branch-select-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--border-radius);
    margin-bottom: 10px;
    cursor: pointer;
    transition: var(--transition);
}

.branch-select-item:hover {
    border-color: var(--primary);
    background: var(--primary-bg);
}

.branch-select-item .icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--primary-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.branch-select-item .name {
    font-weight: 600;
}

.branch-select-item .code {
    font-size: 12px;
    color: var(--gray-400);
}

/* ==================== Daily Staff Selection ==================== */
.staff-select-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.staff-select-card {
    text-align: center;
    padding: 20px 12px;
    border: 2px solid var(--gray-200);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.staff-select-card:hover {
    border-color: var(--primary);
    background: var(--primary-bg);
}

.staff-select-card .avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--gray-100);
    margin: 0 auto 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.staff-select-card .name {
    font-weight: 600;
    font-size: 14px;
}

.staff-select-card .nick {
    font-size: 12px;
    color: var(--gray-400);
}

/* ==================== Responsive ==================== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: flex;
    }

    .pos-container {
        grid-template-columns: 1fr;
    }

    .pos-cart {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 50vh;
        z-index: 90;
    }

    .page-content {
        padding: 16px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}