/*
 * i3 Inventory - Design System
 * Aligned with GMP Prototype styling
 */

/* ==========================================================================
   CSS Variables / Design Tokens
   ========================================================================== */

:root {
    /* Colors - Primary */
    --primary: #0D6E6E;
    --primary-light: #14919B;
    --primary-dark: #0A5555;
    --secondary: #1E3A5F;
    --secondary-light: #2D4A6F;

    /* Colors - Status */
    --status-released: #059669;
    --status-released-bg: rgba(5, 150, 105, 0.1);
    --status-quarantine: #D97706;
    --status-quarantine-bg: rgba(217, 119, 6, 0.1);
    --status-warning: #EA580C;
    --status-warning-bg: rgba(234, 88, 12, 0.1);
    --status-rejected: #DC2626;
    --status-rejected-bg: rgba(220, 38, 38, 0.1);
    --status-blue: #2563EB;
    --status-blue-bg: rgba(37, 99, 235, 0.1);
    --status-purple: #7C3AED;
    --status-purple-bg: rgba(124, 58, 237, 0.1);

    /* Colors - Grays */
    --white: #FFFFFF;
    --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;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;
}

/* ==========================================================================
   Base Styles / Reset
   ========================================================================== */

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

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--gray-700);
    background: var(--gray-100);
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    color: var(--gray-900);
}

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

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

/* ==========================================================================
   Form Elements
   ========================================================================== */

.form-input,
.form-select {
    width: 100%;
    padding: 0.75rem 1rem;
    font-family: var(--font-family);
    font-size: 0.9375rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    background: var(--white);
    outline: none;
    transition: all var(--transition-fast);
}

/* Custom select dropdown styling */
.form-select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23475569' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
    cursor: pointer;
}

/* Date/time input sizing */
input[type="date"].form-input,
input[type="time"].form-input,
input[type="datetime-local"].form-input {
    min-height: 2.75rem;
}

.form-input:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 110, 110, 0.1);
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-600);
    margin-bottom: var(--space-xs);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 0.9375rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-lg);
    border: none;
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1rem;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: var(--white);
    box-shadow: 0 4px 14px 0 rgba(13, 110, 110, 0.4);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px 0 rgba(13, 110, 110, 0.5);
    color: var(--white);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-success {
    background: linear-gradient(135deg, var(--status-released) 0%, #10b981 100%);
    color: var(--white);
    box-shadow: 0 4px 14px 0 rgba(5, 150, 105, 0.4);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px 0 rgba(5, 150, 105, 0.5);
    color: var(--white);
}

.btn-danger {
    background: linear-gradient(135deg, #f87171 0%, #fca5a5 100%);
    color: var(--white);
    box-shadow: 0 4px 14px 0 rgba(248, 113, 113, 0.3);
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px 0 rgba(248, 113, 113, 0.4);
    color: var(--white);
}

.btn-secondary {
    background: var(--white);
    color: var(--gray-700);
    border: 2px solid var(--gray-200);
}

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

/* ==========================================================================
   Status Badges
   ========================================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.badge-quarantine {
    background: var(--status-quarantine-bg);
    color: var(--status-quarantine);
}

.badge-released {
    background: var(--status-released-bg);
    color: var(--status-released);
}

.badge-rejected {
    background: var(--status-rejected-bg);
    color: var(--status-rejected);
}

.badge-info {
    background: var(--status-blue-bg);
    color: var(--status-blue);
}

.badge-purple {
    background: var(--status-purple-bg);
    color: var(--status-purple);
}

.badge-gray {
    background: rgba(107, 114, 128, 0.1);
    color: #4b5563;
}

/* ==========================================================================
   Navigation
   ========================================================================== */

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    position: relative;
}

.nav-link:hover {
    color: var(--white);
    background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
    color: var(--white);
    background: rgba(255, 255, 255, 0.1);
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary-light);
}

/* ==========================================================================
   Cards & Containers
   ========================================================================== */

.card {
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    transition: all var(--transition-base);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-padded {
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    padding: var(--space-xl);
    transition: all var(--transition-base);
}

.card-padded:hover {
    box-shadow: var(--shadow-lg);
}

/* ==========================================================================
   Tables
   ========================================================================== */

.table-header {
    padding: var(--space-md) var(--space-lg);
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.table-cell {
    padding: var(--space-md) var(--space-lg);
    font-size: 0.875rem;
    color: var(--gray-700);
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}

/* ==========================================================================
   Flash Messages
   ========================================================================== */

.flash {
    margin-bottom: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-lg);
    border-left: 4px solid;
    font-size: 0.9375rem;
}

.flash-error {
    background: var(--status-rejected-bg);
    color: var(--status-rejected);
    border-left-color: var(--status-rejected);
}

.flash-success {
    background: var(--status-released-bg);
    color: var(--status-released);
    border-left-color: var(--status-released);
}

.flash-info {
    background: var(--status-blue-bg);
    color: var(--status-blue);
    border-left-color: var(--status-blue);
}

/* ==========================================================================
   Timeline (for lot history)
   ========================================================================== */

.timeline-icon {
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--white);
}

.timeline-icon-received {
    background: var(--status-blue);
}

.timeline-icon-released {
    background: var(--status-released);
}

.timeline-icon-rejected {
    background: var(--status-rejected);
}

.timeline-icon-consumed {
    background: var(--status-purple);
}

.timeline-icon-default {
    background: var(--gray-400);
}

/* ==========================================================================
   Page Headers
   ========================================================================== */

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: var(--space-lg);
}

.section-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-900);
}

/* ==========================================================================
   Filter Pills
   ========================================================================== */

.filter-pill {
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition-base);
    text-decoration: none;
    display: inline-block;
}

.filter-pill-active {
    color: var(--white);
}

.filter-pill-inactive {
    background: var(--gray-100);
    color: var(--gray-600);
}

.filter-pill-inactive:hover {
    background: var(--gray-200);
}

/* Filter pill color variants */
.filter-pill-primary {
    background: var(--primary);
}

.filter-pill-amber {
    background: var(--status-quarantine);
}

.filter-pill-green {
    background: var(--status-released);
}

.filter-pill-red {
    background: var(--status-rejected);
}

/* Inactive variants with color hint */
.filter-pill-amber-inactive {
    background: var(--status-quarantine-bg);
    color: var(--status-quarantine);
}

.filter-pill-amber-inactive:hover {
    background: rgba(217, 119, 6, 0.2);
}

.filter-pill-green-inactive {
    background: var(--status-released-bg);
    color: var(--status-released);
}

.filter-pill-green-inactive:hover {
    background: rgba(5, 150, 105, 0.2);
}

.filter-pill-red-inactive {
    background: var(--status-rejected-bg);
    color: var(--status-rejected);
}

.filter-pill-red-inactive:hover {
    background: rgba(220, 38, 38, 0.2);
}

/* ==========================================================================
   Dashboard Stats
   ========================================================================== */

.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--gray-900);
    line-height: 1;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

/* ==========================================================================
   Stat Cards (Header Summary Cards)
   ========================================================================== */

/* Base stat card - non-clickable summary */
.stat-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
}

/* Interactive stat card - clickable with hover effects */
.stat-card-interactive {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    display: block;
}

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

/* Active state for interactive cards - adds ring */
.stat-card-active {
    box-shadow: 0 0 0 2px var(--primary);
}

/* Color variants for active ring */
.stat-card-active-red {
    box-shadow: 0 0 0 2px var(--status-rejected);
}

.stat-card-active-amber {
    box-shadow: 0 0 0 2px var(--status-quarantine);
}

.stat-card-active-green {
    box-shadow: 0 0 0 2px var(--status-released);
}

.stat-card-active-gray {
    box-shadow: 0 0 0 2px var(--gray-400);
}

/* Stat card icon container */
.stat-card-icon {
    width: 3rem;
    height: 3rem;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-card-icon svg {
    width: 1.5rem;
    height: 1.5rem;
}

/* Icon background color variants */
.stat-card-icon-red {
    background: var(--status-rejected-bg);
    color: var(--status-rejected);
}

.stat-card-icon-amber {
    background: var(--status-quarantine-bg);
    color: var(--status-quarantine);
}

.stat-card-icon-green {
    background: var(--status-released-bg);
    color: var(--status-released);
}

.stat-card-icon-gray {
    background: var(--gray-100);
    color: var(--gray-500);
}

/* ==========================================================================
   Sidebar
   ========================================================================== */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: 100vh;
    background: var(--secondary);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-header {
    padding: var(--space-lg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    text-decoration: none;
}

.sidebar-logo .logo-icon {
    width: 2.25rem;
    height: 2.25rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: 700;
    font-size: 0.875rem;
}

.sidebar-logo .logo-text {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--white);
}

.sidebar-logo .logo-highlight {
    color: var(--primary-light);
}

.sidebar-nav {
    flex: 1;
    padding: var(--space-md) 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    position: relative;
}

.nav-item svg {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
}

.nav-item:hover {
    color: var(--white);
    background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    color: var(--white);
    background: rgba(255, 255, 255, 0.1);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary-light);
}

.sidebar-footer {
    padding: var(--space-lg);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.user-avatar {
    width: 2.5rem;
    height: 2.5rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: 600;
    font-size: 0.875rem;
}

.user-avatar-lg {
    width: 4rem;
    height: 4rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: 700;
    font-size: 1.25rem;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    color: var(--white);
    font-weight: 500;
    font-size: 0.875rem;
}

.user-role {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.75rem;
}

.logout-link {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.8125rem;
    text-decoration: none;
    transition: color var(--transition-fast);
}

.logout-link:hover {
    color: var(--white);
}

.logout-link svg {
    width: 1rem;
    height: 1rem;
}

/* ==========================================================================
   Main Content Area
   ========================================================================== */

.main-content {
    padding: var(--space-xl);
    min-height: 100vh;
}

.main-content.with-sidebar {
    margin-left: 260px;
}
/* ==========================================================================
   Sticky Table with Column Search
   ========================================================================== */

.table-container {
    max-height: 600px;
    overflow: auto;
    border-radius: var(--radius-xl);
}

.table-sticky {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table-sticky thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.table-sticky thead th {
    background: var(--gray-50);
    border-bottom: 2px solid var(--gray-200);
}

.table-sticky thead tr.search-row th {
    background: var(--white);
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--gray-200);
}

.column-search {
    width: 100%;
    padding: 0.375rem 0.5rem;
    font-size: 0.75rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    background: var(--gray-50);
    outline: none;
    transition: all var(--transition-fast);
}

.column-search:focus {
    border-color: var(--primary);
    background: var(--white);
    box-shadow: 0 0 0 2px rgba(13, 110, 110, 0.1);
}

.column-search::placeholder {
    color: var(--gray-400);
}

/* ==========================================================================
   Pagination
   ========================================================================== */

.pagination-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

.pagination-info {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.pagination-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-600);
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.pagination-btn:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.page-size-select {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    background: var(--white);
    cursor: pointer;
    outline: none;
}

.page-size-select:focus {
    border-color: var(--primary);
}

/* ==========================================================================
   Table Row Hover
   ========================================================================== */

.table-sticky tbody tr:hover {
    background: var(--gray-50);
}

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

/* ==========================================================================
   Mobile Responsive (only applies to screens < 768px)
   Desktop browsers are NOT affected by these styles
   ========================================================================== */

/* Mobile menu toggle button */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 200;
    width: 2.5rem;
    height: 2.5rem;
    background: var(--secondary);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    padding: 0.5rem;
}

.mobile-menu-toggle svg {
    width: 100%;
    height: 100%;
    color: var(--white);
}

/* Mobile overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition-base);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .sidebar-overlay.active {
        display: block;
    }

    .main-content.with-sidebar {
        margin-left: 0;
        padding: var(--space-md);
        padding-top: 4rem;
    }

    .page-title {
        font-size: 1.25rem;
    }

    .table-container {
        max-height: none;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-sticky {
        min-width: 600px;
    }

    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }

    .form-input,
    .form-select {
        font-size: 16px;
    }
}
