:root {
    --bg-dark: #121212;
    --bg-card: #1e1e1e;
    --brand-gold: #C5A059;
    --bg-hover: #2a2a2a;

    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;

    /* Vibrant Accents */
    --accent: #f5a623;
    /* Matching the yellow from the design */
    --accent-glow: rgba(245, 166, 35, 0.2);
    --accent-hover: #d48b1a;

    --success: #22c55e;
    --danger: #ef4444;

    --border: #2a2a2a;
    --sidebar-width: 250px;
    --radius: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
}

body {
    background: var(--bg-dark);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Base Panel */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.glass-input {
    background: #181818;
    border: 1px solid var(--border);
    color: white;
    padding: 0.8rem;
    border-radius: 8px;
    width: 100%;
    outline: none;
    transition: all 0.3s ease;
}

.glass-input:focus {
    border-color: var(--accent);
}

input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }

    .sidebar.mobile-visible {
        transform: translateX(0);
        box-shadow: 20px 0 50px rgba(0, 0, 0, 0.5);
    }
}

.brand {
    font-size: 1.4rem;
    font-weight: 700;
    color: white;
    margin-bottom: 3rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.brand-text {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    color: var(--brand-gold);
}

.brand-icon {
    background: var(--accent);
    color: #121212;
    padding: 6px;
    border-radius: 6px;
    font-weight: 800;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.nav-item {
    padding: 0.8rem 1rem;
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.95rem;
}

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

.nav-item.active {
    background: var(--accent);
    color: #1a1a1a;
    font-weight: 600;
}

.nav-item ion-icon {
    font-size: 1.2rem;
}

.sidebar-bottom {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 2rem 3rem;
    width: calc(100% - var(--sidebar-width));
    max-width: 1600px;
    transition: all 0.3s ease;
}

@media (max-width: 768px) {
    .main-content {
        margin-left: 0;
        padding: 1rem;
        width: 100%;
    }
}

/* Top Bar */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.search-wrapper {
    position: relative;
    width: 350px;
}

.search-bar {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 0.8rem 1rem 0.8rem 2.5rem;
    border-radius: 8px;
    color: white;
    outline: none;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.search-bar:focus {
    border-color: var(--text-secondary);
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.icon-button {
    color: var(--text-secondary);
    font-size: 1.4rem;
    background: none;
    border: none;
    cursor: pointer;
    transition: color 0.2s;
    position: relative;
}

.icon-button:hover {
    color: white;
}

.notification-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #e0d0c1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

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

/* KPI Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 1024px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    position: relative;
    overflow: hidden;
    /* adding a subtle dotted background pattern similar to the image */
    background-image: radial-gradient(#2a2a2a 1px, transparent 1px);
    background-size: 20px 20px;
}

.kpi-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.kpi-title {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
}

.kpi-unit {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.kpi-trend {
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.trend-up {
    color: var(--success);
}

.trend-down {
    color: var(--danger);
}

.kpi-trend span {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.kpi-icon.yellow {
    background: rgba(245, 166, 35, 0.1);
    color: var(--accent);
}

.kpi-icon.red {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

/* Main Chart Area */
.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    background-image: radial-gradient(#2a2a2a 1px, transparent 1px);
    background-size: 20px 20px;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.chart-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.chart-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.chart-legend {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.legend-dot.yellow {
    background: var(--accent);
}

.legend-dot.red {
    background: var(--danger);
}

.chart-select {
    background: #181818;
    border: 1px solid var(--border);
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.85rem;
    outline: none;
    margin-left: 1rem;
}

/* Bottom Layout */
.bottom-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

.widget {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.widget-title {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.widget-action {
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
}

th {
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    padding: 0.8rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 1rem 0.8rem;
    color: white;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

.product-cell {
    font-weight: 500;
}

.status-badge {
    padding: 0.4rem 0.8rem;
    border-radius: 2rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.status-ok {
    background: rgba(34, 197, 94, 0.1);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.status-low {
    background: rgba(245, 158, 11, 0.1);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.status-critical {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
    animation: status-pulse 2s infinite;
}

.status-completed {
    background: rgba(34, 197, 94, 0.1);
    color: #4ade80;
}

.status-processing {
    background: rgba(245, 166, 35, 0.1);
    color: var(--accent);
}

.status-scheduled {
    background: rgba(160, 160, 160, 0.1);
    color: #a0a0a0;
}

/* Progress Bar for Efficiency */
.progress-container {
    width: 100%;
    height: 6px;
    background: #333;
    border-radius: 3px;
    overflow: hidden;
    position: relative;
    max-width: 100px;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
}

/* Stock Alerts Widget */
.alert-card {
    background: #1a1a1a;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
}

.alert-info h4 {
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
    font-weight: 600;
}

.alert-info p {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.alert-action {
    color: var(--accent);
    font-size: 1.2rem;
    cursor: pointer;
}

/* Buttons */
.btn-primary {
    background: var(--accent);
    color: #1a1a1a;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.action-btn {
    background: var(--accent);
    color: #1a1a1a;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.action-btn:hover {
    background: var(--accent-hover);
}

.secondary-btn {
    background: #181818;
    color: white;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.3s ease;
}

.secondary-btn:hover {
    background: #2a2a2a;
}

/* Tabs */
.tabs {
    display: inline-flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.tab-btn {
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: white;
}

.tab-btn.active {
    background: #2a2a2a;
    color: white;
    border-color: var(--border);
}

/* View Toggling */
.hidden {
    display: none !important;
}

.print-hidden {}

@media print {
    .print-hidden {
        display: none !important;
    }
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeInUp 0.4s ease forwards;
}

/* Print Styles update */
@media print {

    /* Solid black for everything */
    * {
        color: black !important;
        text-shadow: none !important;
        box-shadow: none !important;
        filter: none !important;
        backdrop-filter: none !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    body {
        background: white !important;
        color: black !important;
    }

    /* Hide UI Chrome and Controls - VERY AGGRESSIVE */
    .sidebar,
    .top-bar,
    .menu-toggle,
    .print-hidden,
    .hidden,
    .sidebar-bottom,
    #sidebar-overlay,
    .header-actions,
    .tabs,
    .search-wrapper,
    .chart-select,
    .widget-action,
    nav.nav-links,
    button,
    input,
    select,
    ion-icon,
    .btn-primary,
    .action-btn,
    .secondary-btn,
    .status-badge ion-icon {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
    }

    /* Layout cleanup */
    .main-content {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        background: white !important;
    }

    .main-content,
    section {
        display: block !important;
        width: 100% !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    /* Table & Container Styles */
    .glass,
    .kpi-card,
    .widget,
    .chart-container,
    .table-container {
        background: white !important;
        border: none !important;
        color: black !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
        background-image: none !important;
        padding: 0 !important;
        margin-bottom: 2rem !important;
        overflow: visible !important;
        display: block !important;
        opacity: 1 !important;
    }

    table {
        border-collapse: collapse !important;
        width: 100% !important;
        margin-top: 1rem !important;
    }

    th,
    td {
        border: 1px solid #333 !important;
        /* Darker border for PDF visibility */
        color: black !important;
        padding: 8px !important;
        opacity: 1 !important;
        visibility: visible !important;
    }

    th {
        background: #eee !important;
        font-weight: 700 !important;
        /* Bolder for PDF */
        text-transform: uppercase !important;
    }

    /* Elements that should stay visible */
    #print-header,
    #print-header h1,
    #print-subtitle,
    h1,
    h2,
    h3,
    h4,
    h5,
    h6,
    p {
        display: block !important;
        color: black !important;
        opacity: 1 !important;
        visibility: visible !important;
    }

    span,
    div,
    td,
    th {
        color: black !important;
        opacity: 1 !important;
        visibility: visible !important;
    }

    #print-header {
        margin-bottom: 2rem !important;
        text-align: center !important;
    }

    #print-header h1 {
        font-size: 2rem !important;
        margin-bottom: 0.5rem !important;
    }

    /* Force visibility of fade-in elements */
    .fade-in {
        animation: none !important;
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
    }
}

/* Custom Input Widths for Production */
.ing-row,
.ing-row-3,
.ing-row-output {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.8rem;
}

.ing-row label,
.ing-row-3 label,
.ing-row-output label {
    flex: 0 0 120px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.ing-input {
    background: #181818;
    border: 1px solid var(--border);
    color: white;
    padding: 0.6rem;
    border-radius: 6px;
    width: 100%;
    outline: none;
}

@keyframes status-pulse {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.7;
        transform: scale(1.02);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Glassmorphism Modal Enhancements */
#restock-modal .glass,
#outward-modal .glass,
#production-modal .glass {
    backdrop-filter: blur(20px);
    background: rgba(20, 20, 20, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

.inventory-row:hover {
    background: rgba(255, 255, 255, 0.05);
}

.product-cell-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--accent);
}

.kpi-card-glow {
    position: absolute;
    top: -20px;
    right: -20px;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
    opacity: 0.05;
    filter: blur(20px);
}

#sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 999;
    display: none;
}

#sidebar-overlay.visible {
    display: block;
}

/* Responsive Overrides */
@media (max-width: 768px) {
    .top-bar {
        padding: 0.5rem 0;
        gap: 1rem;
    }

    .search-wrapper {
        display: none;
    }

    .section-title {
        font-size: 1.4rem;
    }

    .glass {
        padding: 1.2rem !important;
    }

    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 1rem;
    }

    table {
        min-width: 600px;
    }

    .tabs {
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 0.5rem;
        width: 100%;
        display: flex;
        gap: 0.5rem;
    }

    /* Grid overrides for production/sales */
    div[style*="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));"],
    div[style*="display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));"],
    div[style*="display:grid; grid-template-columns: 1fr 1fr; gap:2rem;"],
    .bottom-layout {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .ing-row,
    .ing-row-output,
    .ing-row-3 {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.4rem !important;
    }

    .ing-row label,
    .ing-row-output label,
    .ing-row-3 label {
        flex: 0 0 auto !important;
        width: 100% !important;
        margin-bottom: 0.1rem;
        font-size: 0.85rem;
    }

    .ing-input {
        width: 100% !important;
        height: 44px !important;
    }
}

/* Hamburger Menu Toggle */
.menu-toggle {
    display: none;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: white;
    padding: 0.6rem;
    border-radius: 8px;
    font-size: 1.4rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

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

@media (max-width: 768px) {
    .menu-toggle {
        display: flex;
    }
}