/**
 * Global Styles - Premium Inventory & POS System
 * Mobile-First Design with Glassmorphism and "App-Like" Feel
 */

:root {
    /* Color Palette - Premium */
    --primary: #4f46e5;
    /* Indigo 600 */
    --primary-op: rgba(79, 70, 229, 0.1);
    --secondary: #ec4899;
    /* Pink 500 */
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --dark: #111827;
    --light: #f9fafb;

    /* Backgrounds */
    --bg-body: #f3f4f6;
    /* Light Gray */
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;

    /* Text */
    --text-main: #1f2937;
    --text-muted: #6b7280;

    /* Spacing & Sizes */
    --header-height: 60px;
    --sidebar-width: 260px;
    --input-height: 48px;

    /* Spacing System - Enhanced */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    /* Increased from default */
    --spacing-xl: 32px;

    /* Minimum touch target */
    --radius-md: 12px;
    --radius-lg: 16px;

    /* Shadows (Enhanced for Depth) */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.12), 0 2px 4px -1px rgba(0, 0, 0, 0.08);
    /* Darker */
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    /* Larger & Darker */
    --shadow-card: 0 0 0 1px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.08);
    /* Darker Border & Shadow */
}

/* -------------------------------------------------------------------------- */
/*                                Reset & Base                                */
/* -------------------------------------------------------------------------- */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    border-color: #d1d5db;
    /* Global default border color darkened from #e5e7eb */
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.5;
    font-size: 15px;
    /* Better reading on mobile */
    overflow-x: hidden;
    padding-bottom: env(safe-area-inset-bottom);
    /* iPhone Safety */
}

a {
    text-decoration: none;
    color: inherit;
    transition: 0.2s;
}

/* -------------------------------------------------------------------------- */
/*                                Layout System                               */
/* -------------------------------------------------------------------------- */

/* Sidebar (Desktop Fixed, Mobile Off-Canvas) */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    /* Fallback */
    height: 100dvh;
    /* Mobile browser friendly */
    position: fixed;
    top: 0;
    left: 0;
    background: var(--bg-sidebar);
    border-right: 1px solid rgba(0, 0, 0, 0.05);
    z-index: 1050;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.main-content {
    margin-left: var(--sidebar-width);
    padding: 24px;
    /* Increased padding */
    min-height: 100vh;
    transition: margin-left 0.3s;
}

/* Mobile Header (Sticky Top) */
.mobile-header {
    display: none;
    /* Hidden on Desktop */
    height: var(--header-height);
    background: rgba(238, 242, 255, 0.95);
    /* Light Indigo/Blue Shade */
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1040;
    padding: 0 20px;
    align-items: center;
    justify-content: space-between;
}

/* -------------------------------------------------------------------------- */
/*                            Component: Navigation                           */
/* -------------------------------------------------------------------------- */
.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    background: #e0e7ff;
    /* Match Mobile Header */
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary);
}

.sidebar-nav {
    flex: 1;
    overflow: hidden;
    /* Contains the scrollable list */
    display: flex;
    flex-direction: column;
}

.nav-list {
    list-style: none;
    padding: 16px;
    margin: 0;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    -webkit-overflow-scrolling: touch;
    /* Smooth scroll iOS */
    /* Smooth scroll iOS */
    padding-bottom: 20px;
    /* Safe area for bottom items */
}

.nav-section {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin: 24px 0 8px 12px;
    font-weight: 600;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    border-radius: 6px;
    /* Sharper radius */
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 2px;
    transition: all 0.2s ease;
}

.nav-link:hover {
    background: #f3f4f6;
    /* Gray-100 */
    color: var(--dark);
}

.nav-link.active {
    background: #eff6ff;
    /* Blue-50 */
    color: var(--primary);
    font-weight: 600;
    box-shadow: none;
    /* Clean flat look */
    border-right: 3px solid var(--primary);
    /* Right accent instead of full block */
    border-radius: 6px 0 0 6px;
}

.nav-link.active i {
    opacity: 1;
}

.nav-link i {
    font-size: 1.25rem;
    margin-right: 12px;
    opacity: 0.7;
}

/* Sidebar Footer - Fixed at Bottom */
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    background: #f9fafb;
    /* Light gray background */
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    /* Pushed to bottom if flex container */
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.2;
}

.user-role {
    font-size: 12px;
    color: var(--text-muted);
}

.footer-actions {
    display: flex;
    gap: 8px;
}

.theme-toggle,
.logout-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.theme-toggle:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.logout-btn:hover {
    color: var(--danger);
    border-color: var(--danger);
}


/* -------------------------------------------------------------------------- */
/*                             Component: Cards                               */
/* -------------------------------------------------------------------------- */
.card {
    background: var(--bg-card);
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    margin-bottom: 24px;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding: 20px 24px;
    /* Increased padding */
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

/* -------------------------------------------------------------------------- */
/*                             Component: Forming                             */
/* -------------------------------------------------------------------------- */
.form-control,
.form-select {
    height: var(--input-height);
    border-radius: var(--radius-md);
    border: 1px solid #e5e7eb;
    padding: 0 16px;
    font-size: 1rem;
    background: #fff;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-op);
    outline: none;
    transform: translateY(-1px);
    /* Subtle lift */
}

.btn {
    height: var(--input-height);
    border-radius: var(--radius-md);
    font-weight: 600;
    padding: 0 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.1s;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary);
    border: none;
    box-shadow: 0 4px 6px rgba(79, 70, 229, 0.2);
}

/* -------------------------------------------------------------------------- */
/*                        Component: Responsive Tables                        */
/*              "The Magic Card View" for screens < 768px                     */
/* -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .table-responsive-card thead {
        display: none;
        /* Hide headers */
    }

    .table-responsive-card tbody tr {
        display: block;
        background: #fff;
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-md);
        margin-bottom: 12px;
        padding: 12px;
        position: relative;
        overflow-wrap: break-word;
        word-break: break-word;
    }

    .table-responsive-card tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 6px 0;
        border: none;
        border-bottom: 1px solid #f3f4f6;
        gap: 8px;
    }

    .table-responsive-card tbody td:last-child {
        border-bottom: none;
        justify-content: flex-end;
        /* Actions usually at end */
        padding-top: 12px;
    }

    /* Inject label from data-attribute */
    .table-responsive-card tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.85rem;
        color: var(--text-muted);
        flex-shrink: 0;
    }

    .table-responsive-card tbody td>* {
        text-align: right;
    }
}

/* -------------------------------------------------------------------------- */
/*                               Mobile Tweaks                                */
/* -------------------------------------------------------------------------- */
@media (max-width: 992px) {

    /* Collapse Sidebar by Default */
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 0 0 50px rgba(0, 0, 0, 0.2);
    }

    /* Main Content Expands */
    .main-content {
        margin-left: 0;
        margin-top: var(--header-height);
        /* For Sticky Header */
        padding: 16px;
    }

    /* Show Mobile Header */
    .mobile-header {
        display: flex;
    }

    /* Page Header Stack */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .page-header .btn {
        width: 100%;
    }

    /* Form Grid -> Stack */
    .row>[class*="col-"] {
        width: 100%;
        margin-bottom: 16px;
    }

    .card-body {
        padding: 16px;
    }

    /* Overlay for Sidebar */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(4px);
        z-index: 1045;
        opacity: 0;
        visibility: hidden;
        transition: 0.3s;
    }

    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }
}



/* Mobile: Larger cards */
.card {
    border-radius: var(--border-radius-lg);
}

.card-header {
    padding: var(--spacing-md);
}

.card-title {
    font-size: 17px;
}

.card-body {
    padding: var(--spacing-lg);
    /* 24px */
}

/* Mobile: Better table */
.table {
    font-size: 14px;
}

.table thead th {
    padding: 12px 8px;
    font-size: 11px;
}

.table tbody td {
    padding: 12px 8px;
    font-size: 14px;
}

/* Utilities - Enhanced */
.text-muted {
    color: var(--text-secondary);
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-1 {
    margin-top: var(--spacing-xs);
}

.mt-2 {
    margin-top: var(--spacing-sm);
}

.mt-3 {
    margin-top: var(--spacing-md);
}

.mt-4 {
    margin-top: var(--spacing-lg);
}

.mb-1 {
    margin-bottom: var(--spacing-xs);
}

.mb-2 {
    margin-bottom: var(--spacing-sm);
}

.mb-3 {
    margin-bottom: var(--spacing-md);
}

.mb-4 {
    margin-bottom: var(--spacing-lg);
}

.w-100 {
    width: 100%;
}

.d-flex {
    display: flex;
}

.align-items-center {
    align-items: center;
}

.justify-content-between {
    justify-content: space-between;
}

.gap-2 {
    gap: var(--spacing-sm);
}

.gap-3 {
    gap: var(--spacing-md);
}