/* ==========================================================================
   styles.css - Factory CRM Premium Styling
   Glassmorphism, Neon Dark Accents, Clean Layouts, Responsive Grid, and Print Styles.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-primary: #0b0f19;
    --bg-secondary: #111827;
    --bg-surface: rgba(17, 24, 39, 0.65);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(6, 182, 212, 0.3);
    
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --accent-cyan: #06b6d4;
    --accent-cyan-glow: rgba(6, 182, 212, 0.2);
    --accent-teal: #14b8a6;
    --accent-teal-glow: rgba(20, 184, 166, 0.2);
    --accent-purple: #8b5cf6;
    --accent-purple-glow: rgba(139, 92, 246, 0.2);
    --accent-danger: #ef4444;
    --accent-danger-glow: rgba(239, 68, 68, 0.2);
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;
    
    --sidebar-width: 260px;
    --transition-speed: 0.25s;
    --border-radius-lg: 16px;
    --border-radius-md: 10px;
    --border-radius-sm: 6px;
    --shadow-premium: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* ----------------------------------------------------
   Core & Layout Setup
   ---------------------------------------------------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 15px;
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: #1f2937;
    border-radius: var(--border-radius-sm);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-cyan);
}

/* Dynamic Page Container */
#app-shell {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* ----------------------------------------------------
   Auth Screen (Login Overlay)
   ---------------------------------------------------- */
#login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, #111827 0%, #030712 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 20px;
}

.login-card {
    background: var(--bg-surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    width: 100%;
    max-width: 420px;
    padding: 40px;
    box-shadow: var(--shadow-premium);
    animation: fadeIn 0.4s ease-out;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
    border-radius: var(--border-radius-md);
    margin-bottom: 16px;
    box-shadow: 0 0 20px rgba(6, 182, 212, 0.4);
}

.login-logo svg {
    width: 30px;
    height: 30px;
    stroke: #ffffff;
}

.login-header h1 {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(to right, #ffffff, #9ca3af);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 6px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 13px;
}

.form-group {
    margin-bottom: 20px;
    position: relative;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.input-container {
    position: relative;
    display: flex;
    align-items: center;
}

.input-container svg {
    position: absolute;
    left: 14px;
    width: 18px;
    height: 18px;
    stroke: var(--text-muted);
    pointer-events: none;
}

.form-control {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 12px 14px 12px 42px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    transition: all var(--transition-speed);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px var(--accent-cyan-glow);
    background: rgba(0, 0, 0, 0.3);
}

.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, var(--accent-cyan) 0%, var(--accent-teal) 100%);
    border: none;
    border-radius: var(--border-radius-md);
    padding: 12px;
    color: #ffffff;
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.25);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(6, 182, 212, 0.4);
    filter: brightness(1.1);
}

.btn-primary:active {
    transform: translateY(1px);
}

.login-alert {
    background: var(--accent-danger-glow);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    padding: 12px;
    border-radius: var(--border-radius-md);
    font-size: 13px;
    margin-bottom: 20px;
    display: none;
    align-items: center;
    gap: 8px;
}

/* ----------------------------------------------------
   Navigation Sidebar Layout
   ---------------------------------------------------- */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    transition: width var(--transition-speed);
}

.sidebar-brand {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
}

.brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-teal));
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-icon svg {
    width: 22px;
    height: 22px;
    stroke: #ffffff;
}

.brand-title {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #ffffff;
}

.sidebar-profile {
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid var(--border-color);
}

.profile-avatar {
    width: 40px;
    height: 40px;
    background: var(--bg-primary);
    border: 1.5px solid var(--accent-cyan);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-cyan);
    font-weight: 700;
    font-size: 16px;
}

.profile-info {
    overflow: hidden;
}

.profile-name {
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.profile-role {
    font-size: 11px;
    color: var(--accent-cyan);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.8px;
}

.sidebar-menu {
    list-style: none;
    padding: 20px 12px;
    flex-grow: 1;
    overflow-y: auto;
}

.menu-item {
    margin-bottom: 4px;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    transition: all var(--transition-speed);
}

.menu-link svg {
    width: 20px;
    height: 20px;
    stroke: var(--text-secondary);
    transition: stroke var(--transition-speed);
}

.menu-link:hover {
    background: rgba(255, 255, 255, 0.03);
    color: #ffffff;
}

.menu-link:hover svg {
    stroke: #ffffff;
}

.menu-item.active .menu-link {
    background: linear-gradient(90deg, rgba(6, 182, 212, 0.15) 0%, rgba(20, 184, 166, 0.03) 100%);
    color: var(--accent-cyan);
    font-weight: 600;
    border-left: 3px solid var(--accent-cyan);
    border-radius: 0 var(--border-radius-md) var(--border-radius-md) 0;
    padding-left: 13px;
}

.menu-item.active .menu-link svg {
    stroke: var(--accent-cyan);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.btn-logout {
    width: 100%;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--border-radius-md);
    color: #fca5a5;
    padding: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition-speed);
}

.btn-logout svg {
    width: 18px;
    height: 18px;
    stroke: #fca5a5;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    color: #ffffff;
}

/* ----------------------------------------------------
   Main Workspace Container
   ---------------------------------------------------- */
.main-wrapper {
    margin-left: var(--sidebar-width);
    flex-grow: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 30px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.page-title h2 {
    font-family: var(--font-heading);
    font-size: 26px;
    font-weight: 700;
    color: #ffffff;
}

.page-title p {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 2px;
}

.page-actions {
    display: flex;
    gap: 12px;
}

/* Primary Content Pages Grid/Display */
.tab-content-page {
    display: none;
    animation: pageFadeIn 0.3s ease-out;
}

.tab-content-page.active {
    display: block;
}

/* ----------------------------------------------------
   Components & Panels (Glassmorphism Cards)
   ---------------------------------------------------- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.panel-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transition: all var(--transition-speed);
}

.panel-card:hover {
    border-color: var(--border-hover);
}

/* Dashboard Summary Cards */
.stat-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-info h4 {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 8px;
}

.stat-info p {
    font-family: var(--font-heading);
    font-size: 28px;
    font-weight: 700;
    color: #ffffff;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon.cyan { background: var(--accent-cyan-glow); color: var(--accent-cyan); }
.stat-icon.teal { background: var(--accent-teal-glow); color: var(--accent-teal); }
.stat-icon.purple { background: var(--accent-purple-glow); color: var(--accent-purple); }
.stat-icon.danger { background: var(--accent-danger-glow); color: var(--accent-danger); }

.stat-icon svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
}

/* ----------------------------------------------------
   Tables & Data Presentation
   ---------------------------------------------------- */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 14px;
}

.data-table th {
    background-color: rgba(0, 0, 0, 0.2);
    color: var(--text-primary);
    font-weight: 600;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    letter-spacing: 0.3px;
}

.data-table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    vertical-align: middle;
}

.data-table tbody tr {
    background: transparent;
    transition: background-color var(--transition-speed);
}

.data-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

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

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 50px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge.success { background: rgba(16, 185, 129, 0.15); color: #6ee7b7; border: 0.5px solid rgba(16, 185, 129, 0.3); }
.badge.danger { background: rgba(239, 68, 68, 0.15); color: #fca5a5; border: 0.5px solid rgba(239, 68, 68, 0.3); }
.badge.warning { background: rgba(245, 158, 11, 0.15); color: #fde047; border: 0.5px solid rgba(245, 158, 11, 0.3); }
.badge.info { background: rgba(6, 182, 212, 0.15); color: #67e8f9; border: 0.5px solid rgba(6, 182, 212, 0.3); }

/* Low Stock Blinking Glow Indicator */
.low-stock-pulse {
    animation: pulseDanger 2s infinite;
    background-color: rgba(239, 68, 68, 0.05);
}

/* ----------------------------------------------------
   Inputs & Controls Design
   ---------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--border-radius-md);
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed);
    text-decoration: none;
    border: none;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
    background: var(--accent-danger-glow);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: var(--accent-danger);
    color: #ffffff;
}

.btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
}

.search-bar {
    position: relative;
    max-width: 320px;
    width: 100%;
}

.search-bar svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    stroke: var(--text-muted);
}

.search-bar input {
    padding-left: 38px;
}

/* Flex Controls (Forms In-line / Filters) */
.controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

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

/* Form Styles */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.select-control {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
    padding-right: 40px !important;
}

/* ----------------------------------------------------
   Modal Overlay Structure
   ---------------------------------------------------- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    width: 100%;
    max-width: 580px;
    box-shadow: var(--shadow-premium);
    overflow: hidden;
    transform: translateY(20px);
    transition: transform 0.25s ease;
}

.modal-overlay.active .modal-card {
    transform: translateY(0);
}

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

.modal-header h3 {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-speed);
}

.modal-close:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.05);
}

.modal-body {
    padding: 24px;
    max-height: 70vh;
    overflow-y: auto;
}

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

/* ----------------------------------------------------
   Specialized Tabs Implementation
   ---------------------------------------------------- */

/* Dashboard Layout specifics */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.list-header h3 {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 16px;
}

/* Audit Split-screen view styling */
.audit-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 900px) {
    .audit-panel {
        grid-template-columns: 1fr;
    }
}

.audit-setup-section {
    padding: 20px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
}

.audit-input-table input {
    width: 80px;
    padding: 6px 8px;
    text-align: center;
}

/* Shift Audit Info details */
.variance-positive { color: var(--accent-success); font-weight: bold; }
.variance-negative { color: var(--accent-danger); font-weight: bold; }

/* Report details page */
.report-viewer-card {
    background: #0d1117;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 40px;
    margin-top: 20px;
    font-family: 'Inter', monospace; /* Monospace vibe for structured reports */
    position: relative;
}

.report-header-sheet {
    text-align: center;
    border-bottom: 2px double var(--border-color);
    padding-bottom: 20px;
    margin-bottom: 24px;
}

.report-header-sheet h3 {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: bold;
    color: #ffffff;
    text-transform: uppercase;
}

.report-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    font-size: 13px;
    margin-bottom: 24px;
    color: var(--text-secondary);
}

.report-meta-grid div span {
    font-weight: bold;
    color: var(--text-primary);
}

/* ----------------------------------------------------
   Animations
   ---------------------------------------------------- */
@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

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

@keyframes pulseDanger {
    0% {
        box-shadow: inset 0 0 0px var(--accent-danger-glow);
    }
    50% {
        box-shadow: inset 0 0 15px rgba(239, 68, 68, 0.15);
    }
    100% {
        box-shadow: inset 0 0 0px var(--accent-danger-glow);
    }
}

.badge.success-pulse {
    background: rgba(16, 185, 129, 0.15);
    color: #6ee7b7;
    border: 0.5px solid rgba(16, 185, 129, 0.3);
    animation: greenGlowPulse 2s infinite;
}

@keyframes greenGlowPulse {
    0% { box-shadow: 0 0 2px rgba(16, 185, 129, 0.2); }
    50% { box-shadow: 0 0 10px rgba(16, 185, 129, 0.5); }
    100% { box-shadow: 0 0 2px rgba(16, 185, 129, 0.2); }
}


/* ----------------------------------------------------
   Print Media Styles (For PDF downloads / Printing)
   ---------------------------------------------------- */
@media print {
    body {
        background: #ffffff;
        color: #000000;
    }
    
    .sidebar, .page-actions, .controls-row, .modal-overlay {
        display: none !important;
    }
    
    .main-wrapper {
        margin-left: 0 !important;
        padding: 0 !important;
    }
    
    .report-viewer-card {
        border: none !important;
        background: #ffffff !important;
        color: #000000 !important;
        padding: 0 !important;
    }

    .report-header-sheet h3 {
        color: #000000 !important;
    }

    .report-meta-grid div span, .data-table th {
        color: #000000 !important;
    }

    .data-table {
        border-color: #000000 !important;
    }

    .data-table th, .data-table td {
        border-color: #e5e7eb !important;
        color: #000000 !important;
    }
}
