/* ===== GiftShop Stock Manager — Modern Dashboard UI ===== */
@import url('https://fonts.googleapis.com/css2?family=Prompt:wght@300;400;500;600;700&display=swap');

:root {
    --primary:      #6C63FF;
    --primary-light:#EEF0FF;
    --sidebar-w:    240px;
    --topbar-h:     68px;
    --bg:           #F4F6FB;
    --card-bg:      #FFFFFF;
    --text:         #1A1A2E;
    --text-muted:   #8A94A6;
    --border:       #EAEDF3;
    --shadow:       0 2px 12px rgba(108,99,255,.08);
    --shadow-hover: 0 6px 24px rgba(108,99,255,.16);
    --radius:       14px;
    --radius-sm:    8px;

    --c-pink:   #FF6B8A;
    --c-orange: #FF9F43;
    --c-green:  #00C9A7;
    --c-blue:   #4FACFE;
    --c-purple: #A78BFA;
}

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

body {
    font-family: 'Prompt', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 0.9rem;
    margin: 0;
    overflow-x: hidden;
}

/* ===== WRAPPER ===== */
.gs-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.gs-sidebar {
    width: var(--sidebar-w);
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 200;
    transition: transform .25s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

.gs-sidebar::-webkit-scrollbar { width: 4px; }
.gs-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.gs-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 22px 20px 18px;
    text-decoration: none;
    border-bottom: 1px solid var(--border);
}

.gs-logo-icon {
    width: 40px; height: 40px;
    background: var(--primary);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.gs-logo-text {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}
.gs-logo-text small {
    display: block;
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--text-muted);
}

.gs-nav {
    flex: 1;
    padding: 16px 12px;
}

.gs-nav-label {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 10px 10px 6px;
}

.gs-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 2px;
    transition: all .18s ease;
}

.gs-nav-link i {
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.gs-nav-link:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.gs-nav-link.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(108,99,255,.35);
}

.gs-nav-link.active i { color: #fff; }

/* ===== MAIN CONTENT ===== */
.gs-main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===== TOPBAR ===== */
.gs-topbar {
    height: var(--topbar-h);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.gs-topbar-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
    flex: 1;
}

.gs-topbar-title small {
    display: block;
    font-size: 0.72rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-top: 1px;
}

.gs-search {
    position: relative;
    flex: 0 0 260px;
}

.gs-search input {
    width: 100%;
    height: 38px;
    border: 1.5px solid var(--border);
    border-radius: 30px;
    padding: 0 14px 0 38px;
    font-family: 'Prompt', sans-serif;
    font-size: 0.82rem;
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: border-color .18s;
}

.gs-search input:focus { border-color: var(--primary); }

.gs-search i {
    position: absolute;
    left: 12px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
}

.gs-topbar-icon {
    width: 38px; height: 38px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 1rem;
    position: relative;
    transition: all .18s;
}

.gs-topbar-icon:hover { border-color: var(--primary); color: var(--primary); }

.gs-topbar-badge {
    position: absolute;
    top: -2px; right: -2px;
    width: 14px; height: 14px;
    background: var(--c-pink);
    border-radius: 50%;
    font-size: 0.55rem;
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
}

.gs-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 30px;
    border: 1.5px solid var(--border);
    cursor: pointer;
    transition: border-color .18s;
}

.gs-user:hover { border-color: var(--primary); }

.gs-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--primary);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 0.78rem;
    font-weight: 600;
}

.gs-user-name { font-size: 0.8rem; font-weight: 600; color: var(--text); }
.gs-user-role { font-size: 0.68rem; color: var(--text-muted); }

/* ===== PAGE CONTENT ===== */
.gs-content {
    flex: 1;
    padding: 28px;
}

/* ===== FLASH ALERT ===== */
.gs-flash {
    margin-bottom: 20px;
}

/* ===== CARDS ===== */
.gs-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}

.gs-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.gs-card-body { padding: 20px; }

/* ===== STAT CARDS ===== */
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 22px 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: box-shadow .2s, transform .2s;
    position: relative;
    overflow: hidden;
}

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

.stat-card::after {
    content: '';
    position: absolute;
    right: -20px; bottom: -20px;
    width: 80px; height: 80px;
    border-radius: 50%;
    opacity: .06;
}

.stat-icon {
    width: 52px; height: 52px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-icon.pink   { background: #FFF0F4; color: var(--c-pink); }
.stat-icon.orange { background: #FFF5EC; color: var(--c-orange); }
.stat-icon.green  { background: #E8FBF7; color: var(--c-green); }
.stat-icon.purple { background: #F0EEFF; color: var(--c-purple); }
.stat-icon.blue   { background: #EEF6FF; color: var(--c-blue); }

.stat-card::after { background: currentColor; }

.stat-body { flex: 1; min-width: 0; }
.stat-num  { font-size: 1.6rem; font-weight: 700; line-height: 1; color: var(--text); }
.stat-label{ font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }

.stat-trend {
    font-size: 0.72rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 7px;
    border-radius: 20px;
    margin-top: 6px;
}

.stat-trend.up   { color: var(--c-green); background: #E8FBF7; }
.stat-trend.down { color: var(--c-pink);  background: #FFF0F4; }
.stat-trend.warn { color: var(--c-orange); background: #FFF5EC; }

/* ===== LOW STOCK ALERTS ===== */
.low-stock-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.low-stock-item:last-child { border-bottom: none; }

.low-stock-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.low-stock-name { flex: 1; font-size: 0.85rem; font-weight: 500; }
.low-stock-qty  { font-size: 0.8rem; font-weight: 600; }

/* ===== TABLES ===== */
.gs-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.gs-table th {
    padding: 10px 14px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.gs-table td {
    padding: 12px 14px;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.gs-table tbody tr:last-child td { border-bottom: none; }
.gs-table tbody tr:hover td { background: var(--primary-light); }

/* ===== BADGES ===== */
.gs-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
}

.gs-badge.success { background: #E8FBF7; color: var(--c-green); }
.gs-badge.danger  { background: #FFF0F4; color: var(--c-pink); }
.gs-badge.warning { background: #FFF5EC; color: var(--c-orange); }
.gs-badge.info    { background: #EEF6FF; color: var(--c-blue); }
.gs-badge.primary { background: var(--primary-light); color: var(--primary); }
.gs-badge.muted   { background: #F0F2F5; color: var(--text-muted); }

/* ===== BUTTONS ===== */
.gs-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: 30px;
    font-family: 'Prompt', sans-serif;
    font-size: 0.82rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all .18s;
}

.gs-btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(108,99,255,.30);
}

.gs-btn-primary:hover {
    background: #5a52e0;
    color: #fff;
    box-shadow: 0 6px 18px rgba(108,99,255,.40);
    transform: translateY(-1px);
}

.gs-btn-outline {
    background: var(--card-bg);
    color: var(--text-muted);
    border: 1.5px solid var(--border);
}

.gs-btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.gs-btn-danger  { background: #FFF0F4; color: var(--c-pink); border: 1.5px solid #FFD6DE; }
.gs-btn-success { background: #E8FBF7; color: var(--c-green); border: 1.5px solid #B5F0E5; }
.gs-btn-sm { padding: 5px 12px; font-size: 0.78rem; }
.gs-btn-icon { padding: 7px 9px; border-radius: 10px; }

/* ===== FORMS ===== */
.gs-form-label { font-size: 0.8rem; font-weight: 600; color: var(--text); margin-bottom: 6px; display: block; }
.gs-form-label .req { color: var(--c-pink); }

.gs-input, .gs-select, .gs-textarea {
    width: 100%;
    padding: 9px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'Prompt', sans-serif;
    font-size: 0.85rem;
    color: var(--text);
    background: var(--card-bg);
    outline: none;
    transition: border-color .18s, box-shadow .18s;
}

.gs-input:focus, .gs-select:focus, .gs-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108,99,255,.12);
}

.gs-input-group { position: relative; }
.gs-input-group .gs-input { padding-left: 36px; }
.gs-input-group .gs-input-icon {
    position: absolute;
    left: 11px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ===== TABS ===== */
.gs-tabs {
    display: flex;
    background: var(--bg);
    border-radius: 10px;
    padding: 4px;
    gap: 2px;
}

.gs-tab {
    flex: 1;
    text-align: center;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border: none;
    background: transparent;
    transition: all .18s;
    font-family: 'Prompt', sans-serif;
}

.gs-tab.active {
    background: var(--card-bg);
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
    font-weight: 600;
}

/* ===== PROGRESS BARS ===== */
.gs-progress { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.gs-progress-bar { height: 100%; border-radius: 3px; }

/* ===== CHART AREA ===== */
.chart-container { position: relative; }

/* ===== TOAST ===== */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; }

.gs-toast {
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 32px rgba(0,0,0,.15);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 260px;
    margin-bottom: 8px;
    border-left: 4px solid var(--primary);
    font-size: 0.85rem;
    animation: slideIn .25s ease;
}

.gs-toast.success { border-color: var(--c-green); }
.gs-toast.danger  { border-color: var(--c-pink); }

@keyframes slideIn {
    from { transform: translateX(120%); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}

/* ===== PAGINATION ===== */
.gs-pagination {
    display: flex;
    gap: 4px;
    justify-content: center;
    padding: 16px 0 4px;
}

.gs-page-link {
    width: 34px; height: 34px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
    border: 1.5px solid var(--border);
    text-decoration: none;
    transition: all .15s;
}

.gs-page-link:hover { border-color: var(--primary); color: var(--primary); }
.gs-page-link.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== MOBILE OVERLAY ===== */
.gs-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 150;
}

/* ===== HAMBURGER ===== */
.gs-hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px;
}

/* ===== MOBILE ===== */
@media (max-width: 768px) {
    .gs-sidebar {
        transform: translateX(-100%);
    }
    .gs-sidebar.open {
        transform: translateX(0);
    }
    .gs-overlay.show { display: block; }
    .gs-hamburger { display: block; }
    .gs-main { margin-left: 0; }
    .gs-content { padding: 16px; }
    .gs-search { display: none; }
    .gs-topbar { padding: 0 16px; }
}

/* ===== UTILITY ===== */
.text-muted-sm { font-size: 0.75rem; color: var(--text-muted); }
.fw-600 { font-weight: 600; }
.gap-12 { gap: 12px; }
.rounded-full { border-radius: 50%; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.w-100 { width: 100%; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.ms-auto { margin-left: auto; }
.text-end { text-align: right; }
.text-center { text-align: center; }
.text-nowrap { white-space: nowrap; }

/* ===== DROPDOWN SEARCH ===== */
#searchDropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--card-bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(0,0,0,.1);
    z-index: 1000;
    max-height: 260px;
    overflow-y: auto;
}

.search-item {
    padding: 10px 14px;
    font-size: 0.84rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background .12s;
    text-decoration: none;
    color: var(--text);
}

.search-item:hover { background: var(--primary-light); }
.search-item-badge { margin-left: auto; font-size: 0.72rem; }

/* ===== SPINNER ===== */
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== PRINT OVERRIDE ===== */
@media print {
    .gs-sidebar, .gs-topbar { display: none !important; }
    .gs-main { margin-left: 0; }
    .gs-content { padding: 0; }
    .no-print { display: none !important; }
}

/* ===== PWA SAFE AREA (iOS notch / Dynamic Island) ===== */
@supports (padding: env(safe-area-inset-top)) {
    .gs-topbar {
        padding-top: env(safe-area-inset-top);
        height: calc(var(--topbar-h) + env(safe-area-inset-top));
    }
    .gs-sidebar {
        padding-top: env(safe-area-inset-top);
    }
    .gs-content {
        padding-bottom: max(28px, calc(env(safe-area-inset-bottom) + 16px));
    }
}

/* ===== MOBILE IMPROVEMENTS ===== */
@media (max-width: 768px) {
    /* ซ่อน user text ให้เหลือแค่ avatar */
    .gs-user-name,
    .gs-user-role { display: none; }
    .gs-user      { padding: 4px; border: none; gap: 0; }

    /* safe area bottom on mobile */
    @supports (padding: env(safe-area-inset-bottom)) {
        .gs-content {
            padding-bottom: max(16px, calc(env(safe-area-inset-bottom) + 8px));
        }
    }

    /* Topbar compact */
    .gs-topbar-title { font-size: 1rem; }

    /* Tables: horizontal scroll */
    .gs-table th, .gs-table td { white-space: nowrap; }
}

/* ===== MOBILE BOTTOM NAV ===== */
.gs-bottom-nav { display: none; }

@media (max-width: 768px) {
    .gs-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0; left: 0; right: 0;
        background: var(--card-bg);
        border-top: 1px solid var(--border);
        z-index: 150;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    .gs-bottom-nav a {
        flex: 1;
        display: flex; flex-direction: column;
        align-items: center; justify-content: center;
        padding: 8px 4px;
        font-size: 0.6rem; font-weight: 600;
        color: var(--text-muted); text-decoration: none;
        gap: 3px; transition: color .15s;
    }
    .gs-bottom-nav a i { font-size: 1.2rem; }
    .gs-bottom-nav a.active,
    .gs-bottom-nav a:hover { color: var(--primary); }
    .gs-content { padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
}
@media (min-width: 769px) {
    .gs-bottom-nav { display: none; }
}
