/* =============================================
   RestroMaster POS - Main Stylesheet
   Glassmorphism Design System
   ============================================= */

/* ==========================================
   IMPORTS & FONTS
   ========================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Noto+Sans+Arabic:wght@300;400;500;600;700;800&display=swap');

/* ==========================================
   CSS VARIABLES (Light Mode)
   ========================================== */
:root {
    /* Primary Colors */
    --primary: #6C5CE7;
    --primary-light: #A78BFA;
    --primary-dark: #5B4BD5;
    --primary-rgb: 108, 92, 231;
    --primary-gradient: linear-gradient(135deg, #6C5CE7 0%, #A78BFA 100%);

    /* Accent */
    --accent: #F59E0B;
    --accent-light: #FBBF24;
    --accent-rgb: 245, 158, 11;

    /* Backgrounds */
    --bg-primary: #F8F9FE;
    --bg-secondary: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-sidebar: #FFFFFF;
    --bg-input: #F1F3F8;
    --bg-hover: #F0EDFF;
    --bg-glass: rgba(255, 255, 255, 0.75);
    --bg-glass-strong: rgba(255, 255, 255, 0.9);

    /* Text */
    --text-primary: #1A1A2E;
    --text-secondary: #64748B;
    --text-muted: #94A3B8;
    --text-inverse: #FFFFFF;

    /* Borders */
    --border: #E2E8F0;
    --border-light: #F1F5F9;
    --border-glass: rgba(255, 255, 255, 0.3);

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 15px 50px rgba(0, 0, 0, 0.15);
    --shadow-glass: 0 8px 32px rgba(108, 92, 231, 0.1);
    --shadow-primary: 0 4px 15px rgba(108, 92, 231, 0.3);

    /* Status Colors */
    --success: #10B981;
    --success-bg: #ECFDF5;
    --warning: #F59E0B;
    --warning-bg: #FFFBEB;
    --danger: #EF4444;
    --danger-bg: #FEF2F2;
    --info: #3B82F6;
    --info-bg: #EFF6FF;

    /* Sizes */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 88px;
    --header-height: 65px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 50%;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition: 0.3s ease;
    --transition-slow: 0.5s ease;

    /* Glass */
    --glass-blur: 20px;
    --glass-border: 1px solid rgba(255, 255, 255, 0.3);
}

/* ==========================================
   DARK MODE
   ========================================== */
[data-theme="dark"] {
    --bg-primary: #0F0F1A;
    --bg-secondary: #1A1A2E;
    --bg-card: #1E1E35;
    --bg-sidebar: #16162B;
    --bg-input: #252545;
    --bg-hover: #2A2A4A;
    --bg-glass: rgba(30, 30, 53, 0.8);
    --bg-glass-strong: rgba(30, 30, 53, 0.95);

    --text-primary: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;

    --border: #2D2D50;
    --border-light: #252545;
    --border-glass: rgba(255, 255, 255, 0.08);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 15px 50px rgba(0, 0, 0, 0.5);
    --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.3);

    --success-bg: #064E3B;
    --warning-bg: #78350F;
    --danger-bg: #7F1D1D;
    --info-bg: #1E3A5F;
}

/* ==========================================
   RESET & BASE
   ========================================== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Noto Sans Arabic', 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    direction: rtl;
    line-height: 1.6;
    overflow-x: hidden;
    transition: background var(--transition), color var(--transition);
    -webkit-font-smoothing: antialiased;
    min-width: 320px;
}

a {
    text-decoration: none;
    color: var(--primary);
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-dark);
}

img {
    max-width: 100%;
    height: auto;
}

ul, ol {
    list-style: none;
}

input, select, textarea, button {
    font-family: inherit;
    font-size: inherit;
    outline: none;
    border: none;
}

button {
    cursor: pointer;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-light);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

::selection {
    background: var(--primary);
    color: white;
}

/* ==========================================
   GLASSMORPHISM COMPONENTS
   ========================================== */
.glass {
    background: var(--bg-glass);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: var(--glass-border);
    box-shadow: var(--shadow-glass);
}

.glass-strong {
    background: var(--bg-glass-strong);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: var(--glass-border);
    box-shadow: var(--shadow-glass);
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    transition: all var(--transition);
    min-width: 0;
    min-height: 0;
}

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

.card-glass {
    background: var(--bg-glass);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border-radius: var(--radius-lg);
    border: var(--glass-border);
    box-shadow: var(--shadow-glass);
    padding: 20px;
    transition: all var(--transition);
}

/* ==========================================
   LAYOUT
   ========================================== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
    overflow: clip;
}

.main-content {
    flex: 1;
    margin-right: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    max-width: calc(100% - var(--sidebar-width));
    padding-top: var(--header-height);
    min-height: 100vh;
    transition: margin var(--transition), width var(--transition), max-width var(--transition);
    overflow-x: hidden;
}

.app-wrapper.sidebar-collapsed .main-content {
    margin-right: var(--sidebar-collapsed-width);
    width: calc(100% - var(--sidebar-collapsed-width));
    max-width: calc(100% - var(--sidebar-collapsed-width));
}

.page-content {
    padding: 24px;
    width: 100%;
}

.page-content > * {
    min-width: 0;
}

/* ==========================================
   HEADER
   ========================================== */
.header {
    position: fixed;
    top: 0;
    right: var(--sidebar-width);
    left: 0;
    height: var(--header-height);
    background: var(--bg-glass-strong);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
    transition: all var(--transition);
}

.app-wrapper.sidebar-collapsed .header {
    right: var(--sidebar-collapsed-width);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
    max-width: min(100%, 760px);
}

.page-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-search {
    position: relative;
    width: clamp(220px, 28vw, 320px);
    flex: 0 1 320px;
    min-width: 0;
}

.header-search input {
    width: 100%;
    padding: 10px 40px 10px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.header-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

.header-search i {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

/* Header Actions */
.header-action {
    position: relative;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    cursor: pointer;
    font-size: 1.1rem;
}

.header-action:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

.header-action .badge {
    position: absolute;
    top: -2px;
    left: -2px;
    width: 18px;
    height: 18px;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Theme Toggle */
.theme-toggle {
    position: relative;
    width: 50px;
    height: 26px;
    background: var(--bg-input);
    border-radius: 13px;
    cursor: pointer;
    transition: background var(--transition);
    border: 1px solid var(--border);
}

.theme-toggle::after {
    content: '☀️';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    background: var(--primary);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    transition: all var(--transition);
}

[data-theme="dark"] .theme-toggle::after {
    content: '🌙';
    right: auto;
    left: 2px;
    background: var(--accent);
}

/* User Menu */
.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.user-menu:hover {
    background: var(--bg-hover);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
    overflow: hidden;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-info {
    text-align: right;
    min-width: 0;
    max-width: 160px;
}

.user-info .name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-info .role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ==========================================
   SIDEBAR
   ========================================== */
.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-left: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    z-index: 200;
    transition: all var(--transition);
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
}

.app-wrapper.sidebar-collapsed .sidebar {
    width: 0 !important;
    overflow: hidden !important;
    padding: 0 !important;
    border: 0 !important;
}

.app-wrapper.sidebar-collapsed .main-content,
.app-wrapper.sidebar-collapsed .header {
    margin-right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    right: 0 !important;
}

.sidebar-logo {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-light);
    min-height: var(--header-height);
}

.app-wrapper.sidebar-collapsed .sidebar-logo {
    justify-content: center;
    padding: 18px 12px;
}

.sidebar-logo .logo-icon {
    width: 42px;
    height: 42px;
    background: var(--primary-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.sidebar-logo .logo-text {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.sidebar-logo .logo-sub {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 400;
}

.app-wrapper.sidebar-collapsed .sidebar-logo > div:last-child,
.app-wrapper.sidebar-collapsed .nav-section-title,
.app-wrapper.sidebar-collapsed .nav-item > :not(.nav-icon):not(.nav-badge) {
    display: none !important;
}

.app-wrapper.sidebar-collapsed .sidebar-nav {
    padding: 10px 8px;
}

.app-wrapper.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 11px 8px;
    gap: 0;
    position: relative;
}

.app-wrapper.sidebar-collapsed .nav-item .nav-icon {
    margin: 0;
}

.app-wrapper.sidebar-collapsed .nav-badge {
    position: absolute;
    top: 6px;
    left: 8px;
}

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

.nav-section {
    margin-bottom: 8px;
}

.nav-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 8px 12px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    margin-bottom: 2px;
    position: relative;
    overflow: hidden;
}

.nav-item::before {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    width: 3px;
    height: 100%;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
    transform: scaleY(0);
    transition: transform var(--transition-fast);
}

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

.nav-item.active {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
    font-weight: 600;
}

.nav-item.active::before {
    transform: scaleY(1);
}

.nav-item .nav-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.nav-item:hover .nav-icon,
.nav-item.active .nav-icon {
    transform: scale(1.1);
}

.nav-item .nav-badge {
    margin-right: auto;
    margin-left: 0;
    padding: 2px 8px;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 10px;
}

/* ==========================================
   BUTTONS
   ========================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.9rem;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    border: none;
    cursor: pointer;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.2);
    transform: translateX(-100%);
    transition: transform 0.4s ease;
}

.btn:hover::after {
    transform: translateX(100%);
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: var(--shadow-primary);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(var(--primary-rgb), 0.4);
}

.btn-success {
    background: linear-gradient(135deg, #10B981, #34D399);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, #EF4444, #F87171);
    color: white;
}

.btn-warning {
    background: linear-gradient(135deg, #F59E0B, #FBBF24);
    color: #1A1A2E;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: white;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
}

.btn-block {
    width: 100%;
}

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

/* ==========================================
   FORM ELEMENTS
   ========================================== */
.form-group {
    margin-bottom: 18px;
}

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

.form-control {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-input);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all var(--transition-fast);
}

.form-control:focus {
    border-color: var(--primary);
    background: var(--bg-secondary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.12);
}

.form-control::placeholder {
    color: var(--text-muted);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748B' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 12px center;
    padding-left: 35px;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-error {
    font-size: 0.75rem;
    color: var(--danger);
    margin-top: 4px;
}

.input-group {
    display: flex;
    align-items: stretch;
}

.input-group .form-control {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.input-group-text {
    padding: 0 14px;
    background: var(--bg-input);
    border: 1.5px solid var(--border);
    border-left: none;
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    display: flex;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Checkbox / Toggle */
.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    display: inline-block;
}

.toggle-switch input {
    display: none;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    right: 3px;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: var(--radius-full);
    transition: transform var(--transition-fast);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::after {
    transform: translateX(-20px);
}

/* ==========================================
   TABLE
   ========================================== */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 640px;
}

.data-table th {
    background: var(--bg-input);
    padding: 12px 14px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-align: right;
    white-space: nowrap;
    border-bottom: 2px solid var(--border);
}

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

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

.data-table tbody tr:hover {
    background: var(--bg-hover);
}

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

/* ==========================================
   BADGES & TAGS
   ========================================== */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}

.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); }
.badge-primary { background: rgba(var(--primary-rgb), 0.1); color: var(--primary); }

/* ==========================================
   MODAL
   ========================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: calc(20px + env(safe-area-inset-top, 0px)) 20px calc(20px + env(safe-area-inset-bottom, 0px));
    animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    animation: slideUp 0.3s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
}

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

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-start;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-light);
}

/* ==========================================
   TOAST NOTIFICATIONS
   ========================================== */
.toast-container {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    max-width: 420px;
    animation: slideInLeft 0.4s ease;
    border-right: 4px solid var(--primary);
}

.toast-success { border-right-color: var(--success); }
.toast-error   { border-right-color: var(--danger); }
.toast-warning { border-right-color: var(--warning); }
.toast-info    { border-right-color: var(--info); }

.toast-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.9rem;
}

.toast-success .toast-icon { background: var(--success-bg); color: var(--success); }
.toast-error .toast-icon   { background: var(--danger-bg);  color: var(--danger); }
.toast-warning .toast-icon { background: var(--warning-bg); color: var(--warning); }
.toast-info .toast-icon    { background: var(--info-bg);    color: var(--info); }

.toast-content {
    flex: 1;
}

.toast-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.toast-message {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 0.8rem;
}

/* ==========================================
   STAT CARDS
   ========================================== */
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all var(--transition);
}

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

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

.stat-info .stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-info .stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-info .stat-change {
    font-size: 0.72rem;
    font-weight: 600;
    margin-top: 2px;
}

.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ==========================================
   PAGINATION
   ========================================== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 20px;
}

.page-btn {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.page-btn:hover, .page-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.page-dots {
    color: var(--text-muted);
    padding: 0 4px;
}

/* ==========================================
   EMPTY STATE
   ========================================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state i {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ==========================================
   LOADING / SKELETON
   ========================================== */
.skeleton {
    background: linear-gradient(90deg, var(--bg-input) 25%, var(--border-light) 50%, var(--bg-input) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
    width: 80%;
}

.skeleton-title {
    height: 20px;
    margin-bottom: 12px;
    width: 50%;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
}

/* ==========================================
   DROPDOWN
   ========================================== */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 180px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 500;
    display: none;
    animation: fadeIn 0.15s ease;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.85rem;
    transition: all var(--transition-fast);
    cursor: pointer;
}

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

.dropdown-item i {
    width: 18px;
    text-align: center;
    font-size: 0.85rem;
}

.dropdown-divider {
    height: 1px;
    background: var(--border-light);
    margin: 4px 0;
}

/* ==========================================
   GRID HELPERS
   ========================================== */
.grid {
    display: grid;
    gap: 20px;
}

.grid > * {
    min-width: 0;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
.grid-6 { grid-template-columns: repeat(6, 1fr); }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.gap-lg { gap: 24px; }

.text-center { text-align: center; }
.text-left { text-align: left; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.page-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.page-toolbar-group {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    min-width: 0;
}

.page-toolbar-group > * {
    min-width: 0;
}

.filter-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-row .form-control,
.filter-row .btn {
    min-width: 0;
}

/* ==========================================
   ANIMATIONS
   ========================================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

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

@keyframes ripple {
    to { transform: scale(4); opacity: 0; }
}

.animate-fade { animation: fadeIn 0.5s ease; }
.animate-slide { animation: slideUp 0.5s ease; }
.animate-float { animation: float 3s ease-in-out infinite; }

/* ==========================================
   RESPONSIVE
   ========================================== */
.mobile-menu-btn {
    display: flex;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    border: none;
    -webkit-tap-highlight-color: transparent;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 150;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

/* ---- TABLET (≤ 1024px) ---- */
@media (max-width: 1024px) {
    .app-wrapper.sidebar-collapsed .sidebar {
        width: min(320px, 84vw);
        transform: translateX(100%);
    }

    .app-wrapper.sidebar-collapsed .main-content {
        margin-right: 0;
        width: 100%;
        max-width: 100%;
    }

    .app-wrapper.sidebar-collapsed .header {
        right: 0;
    }

    .sidebar {
        width: min(320px, 84vw);
    }

    .sidebar {
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
    }
    
    .sidebar.open {
        transform: translateX(0);
        box-shadow: -5px 0 30px rgba(0,0,0,0.15);
    }
    
    .sidebar-overlay.active {
        display: block;
        animation: fadeIn 0.2s ease;
    }
    
    .main-content {
        margin-right: 0;
        width: 100%;
        max-width: 100%;
    }
    
    .header {
        right: 0;
        padding: 0 16px;
        gap: 12px;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .header-right {
        flex: 1;
    }

    .header-left {
        flex: 1;
        justify-content: flex-end;
        gap: 10px;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .header-left::-webkit-scrollbar {
        display: none;
    }

    .header-search {
        width: min(240px, 100%);
        flex-basis: 220px;
    }

    .grid-3,
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-5, .grid-6 { grid-template-columns: repeat(3, 1fr); }
    
    /* Improve touch targets */
    .btn { min-height: 40px; }
    .btn-sm { min-height: 34px; }
    .nav-item { padding: 12px 14px; }
    
    /* Modal improvements for tablet */
    .modal { max-width: 90vw; }
    .modal-body { padding: 20px; }
    .modal-header { padding: 16px 20px; }
    .modal-footer { padding: 14px 20px; }
}

/* ---- MOBILE (≤ 768px) ---- */
@media (max-width: 768px) {
    html { font-size: 13px; }
    
    :root {
        --header-height: 56px;
    }
    
    .page-content { padding: 14px; }
    .header-search { display: none; }
    
    /* Grid adjustments */
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-5, .grid-6 { grid-template-columns: repeat(2, 1fr); }
    .grid { gap: 14px; }
    
    /* Header mobile */
    .header {
        padding: 0 12px;
        height: var(--header-height);
    }
    
    .page-title { font-size: 1.1rem; max-width: calc(100vw - 168px); }
    .header-left { gap: 6px; max-width: calc(100vw - 88px); }
    .header-right { gap: 8px; }
    .header-action { width: 36px; height: 36px; font-size: 1rem; }
    .theme-toggle { width: 42px; height: 22px; }
    .theme-toggle::after { width: 17px; height: 17px; }
    .user-info { display: none; }
    .user-avatar { width: 32px; height: 32px; font-size: 0.8rem; }
    .user-menu { padding: 4px 6px; gap: 6px; }
    .user-menu > i { display: none; }
    
    /* Stat cards mobile */
    .stat-card { padding: 14px; gap: 12px; }
    .stat-icon { width: 42px; height: 42px; font-size: 1.1rem; }
    .stat-info .stat-value { font-size: 1.2rem; }
    .stat-info .stat-label { font-size: 0.75rem; }
    
    /* Card mobile */
    .card { padding: 16px; border-radius: var(--radius-md); }
    .card:hover { transform: none; }
    
    /* Modal mobile */
    .modal-overlay { padding: 10px; }
    .modal { 
        max-width: 100%; 
        max-height: 92vh;
        border-radius: var(--radius-lg);
    }
    .modal-header { padding: 14px 16px; }
    .modal-body { padding: 16px; }
    .modal-footer { padding: 12px 16px; }
    .modal-title { font-size: 1rem; }
    
    /* Form elements mobile */
    .form-control { 
        padding: 10px 12px; 
        font-size: 0.88rem;
        min-height: 42px;
    }
    .form-label { font-size: 0.82rem; }
    .form-group { margin-bottom: 14px; }
    
    /* Buttons mobile - larger touch targets */
    .btn { 
        padding: 10px 18px; 
        min-height: 42px;
        font-size: 0.88rem;
    }
    .btn-sm { 
        padding: 8px 14px; 
        min-height: 36px;
        font-size: 0.78rem;
    }
    .btn-lg { 
        padding: 14px 24px; 
        font-size: 1rem;
    }
    
    /* Table mobile */
    .data-table { font-size: 0.8rem; }
    .data-table { min-width: 560px; }
    .data-table th, .data-table td { padding: 10px 8px; }
    .data-table th { font-size: 0.75rem; }
    .table-wrapper { border-radius: var(--radius-md); }
    
    /* Toast mobile */
    .toast-container {
        top: auto;
        bottom: 20px;
        left: 12px;
        right: 12px;
    }
    .toast {
        min-width: auto;
        max-width: 100%;
        font-size: 0.85rem;
    }
    
    /* Dropdown mobile */
    .dropdown-menu {
        min-width: 160px;
        font-size: 0.85rem;
    }
    .dropdown-item { padding: 10px 12px; }
    
    /* Badge mobile */
    .badge-status { font-size: 0.7rem; padding: 3px 8px; }
    
    /* Sidebar mobile */
    .sidebar-logo { padding: 14px; min-height: var(--header-height); }
    .sidebar-logo .logo-icon { width: 36px; height: 36px; font-size: 1.1rem; }
    .sidebar-logo .logo-text { font-size: 1.05rem; }
    .sidebar-nav { padding: 10px; }
    .nav-item { padding: 11px 12px; font-size: 0.88rem; }
    .nav-item .nav-icon { width: 28px; height: 28px; font-size: 0.88rem; }
    
    /* Pagination mobile */
    .pagination { gap: 4px; }
    .page-btn { padding: 6px 10px; font-size: 0.8rem; }

    .page-toolbar,
    .page-toolbar-group,
    .filter-row,
    .flex,
    .flex-between {
        gap: 10px;
    }

    .page-toolbar,
    .page-toolbar-group,
    .filter-row,
    .flex-between {
        align-items: stretch;
    }

    .page-toolbar > *,
    .page-toolbar-group > *,
    .filter-row > * {
        flex: 1 1 100%;
    }

    .page-toolbar .btn,
    .page-toolbar .form-control,
    .page-toolbar-group .btn,
    .page-toolbar-group .form-control,
    .filter-row .btn,
    .filter-row .form-control {
        width: 100% !important;
    }
}

/* ---- SMALL MOBILE (≤ 480px) ---- */
@media (max-width: 480px) {
    html { font-size: 12.5px; }
    
    .grid-4, .grid-5, .grid-6 { grid-template-columns: 1fr; }
    .grid { gap: 10px; }
    
    .page-content { padding: 10px; }
    .card { padding: 12px; }
    
    .page-title { font-size: 1rem; }
    
    .stat-card { padding: 12px; gap: 10px; }
    .stat-icon { width: 38px; height: 38px; font-size: 1rem; }
    .stat-info .stat-value { font-size: 1.1rem; }
    
    .modal-overlay { padding: 6px; }
    .modal { max-height: 95vh; }
    
    .header { padding: 0 10px; }
}

/* ==========================================
   PRINT STYLES
   ========================================== */
@media print {
    .sidebar, .header, .mobile-menu-btn, .btn, .pagination,
    .toast-container, .modal-overlay, 
    .pos-cart-toggle, .pos-cart-overlay { display: none !important; }
    
    .main-content { margin: 0 !important; padding: 0 !important; }
    .page-content { padding: 0 !important; }
    
    body { background: white; color: black; }
    .card { border: 1px solid #ddd; box-shadow: none; }
}
