:root {
    --sidebar-width: 260px;
    --primary-gradient: linear-gradient(135deg, #0ea5e9, #22c55e);
    --sidebar-gradient: linear-gradient(180deg, #0f172a, #020617);
    --bg-color: #f4f7fb;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --accent-green: #22c55e;
    --accent-blue: #0ea5e9;
}

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

body {
    background: var(--bg-color);
    min-height: 100vh;
}

/* Standardized Table Styles (Matches Live Stock Format) */
.table-responsive {
    box-shadow: 0 .125rem .25rem rgba(0,0,0,.075) !important;
    border: 0 !important;
    border-radius: .5rem !important;
    background: #fff;
    overflow-x: auto !important;
}
.table {
    margin-bottom: 0 !important;
    font-family: inherit !important;
}
.table th, .table td {
    white-space: nowrap;
    vertical-align: middle !important;
    border: none !important;
    border-bottom: 1px solid #dee2e6 !important;
    padding: 12px 15px !important;
}
.table thead th {
    background-color: #f8f9fa !important;
    color: #6c757d !important;
    font-weight: 600 !important;
    font-size: 0.875em !important;
    text-transform: none !important; /* Override uppercase */
    border-bottom: 2px solid #dee2e6 !important;
}
.table tbody tr:hover {
    background-color: rgba(0,0,0,.02) !important;
}
.table-bordered {
    border: none !important;
}
.table-bordered th, .table-bordered td {
    border: none !important;
    border-bottom: 1px solid #dee2e6 !important;
}

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-gradient);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    padding: 10px 20px 20px;
    overflow-y: auto;
    z-index: 1000;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
}

.sidebar.collapsed {
    width: 80px;
    padding: 20px 10px;
}

/* Sidebar Header & Brand */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 60px;
    margin-bottom: 20px;
    flex-shrink: 0;
    text-align: center;
    padding: 0;
}

/* Logo Image in Sidebar */
img.brand-full {
    max-height: 50px;
    max-width: 100%;
    object-fit: contain;
    background: none !important;
    -webkit-background-clip: border-box !important;
    color: inherit !important;
    display: block;
    margin: 0 auto;
}

.brand-short {
    font-family: 'a Atmospheric', sans-serif !important;
    font-weight: 700;
    text-transform: uppercase;
    background: linear-gradient(90deg, #0ea5e9, #22c55e);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin: 0 auto;
    width: 100%;
    text-align: center;
    transition: all 0.3s ease;
    display: none;
    line-height: 1.2;
    font-size: 20px;
    letter-spacing: 1px;
}

/* Collapsed State Logic */
.sidebar.collapsed .brand-full {
    display: none;
}

.sidebar.collapsed .brand-short {
    display: block;
    animation: fadeIn 0.5s ease;
}

/* Expanded State Logic (Ensure full is shown, short is hidden) */
.sidebar:not(.collapsed) .brand-full {
    display: block;
}

.sidebar:not(.collapsed) .brand-short {
    display: none;
}

.sidebar.collapsed .menu-title {
    display: none;
}

.sidebar.collapsed .sidebar-link {
    justify-content: center;
    padding: 12px;
}

.sidebar.collapsed .sidebar-link i {
    font-size: 1.2rem;
    margin-right: 0 !important; /* Remove margin when collapsed */
}

.sidebar.collapsed .sidebar-link span,
.sidebar.collapsed .sidebar-link::after,
.sidebar.collapsed .sidebar-link .badge,
.sidebar.collapsed .fa-chevron-down,
.sidebar.collapsed button[data-bs-toggle="collapse"] {
    display: none !important;
}

/* Hide collapse menus when sidebar is collapsed */
.sidebar.collapsed .collapse {
    display: none !important;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

.menu-title {
    font-size: 13px; /* Slightly larger for readability */
    font-family: 'Calibri', sans-serif;
    font-weight: 700;
    opacity: 0.8;
    margin: 20px 0 10px;
    text-transform: uppercase;
    flex-shrink: 0;
    letter-spacing: 0.5px;
}

.menu a, .sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px; /* Increased gap slightly */
    padding: 10px 12px; /* Increased padding for better touch/click target */
    border-radius: 6px; /* Slightly sharper corners for "Office" feel */
    text-decoration: none;
    color: #e2e8f0;
    transition: 0.2s;
    font-family: 'Calibri', sans-serif;
    font-size: 15px; /* Increased size for "Office view" visibility */
    margin-bottom: 2px;
    width: 100%;
    white-space: nowrap; /* Prevent text wrapping */
}

/* Atmospheric text style for menu labels */
.sidebar-link span {
    color: #e2e8f0;
    font-weight: 400; /* Regular weight for Calibri */
    letter-spacing: 0.3px;
}

.menu a:hover, .menu a.active, 
.sidebar-link:hover, .sidebar-link.active {
    background: rgba(255,255,255,0.08);
    color: #ffffff;
    font-weight: 600;
}

/* Ensure readability on hover/active */
.sidebar-link:hover span,
.sidebar-link.active span {
    color: #ffffff;
}

.sidebar-link i {
    width: 30px; /* Fixed width for uniformity */
    text-align: center;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

/* Submenu adjustments */
.sidebar-link.has-arrow::after {
    content: '\f107';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    margin-left: auto;
    transition: transform 0.2s;
}
.sidebar-link.has-arrow[aria-expanded="true"]::after {
    transform: rotate(180deg);
}
.sidebar .collapse {
    /* Removed background bubble to make it look official */
    background: transparent;
    border-radius: 0;
    margin-bottom: 0;
    border-left: 1px solid rgba(255, 255, 255, 0.2); /* Straight line for sub-items */
    margin-left: 27px; /* Align the line exactly under the center of parent icon */
}
.sidebar .collapse .sidebar-link {
    padding-left: 10px; /* Adjust padding to look connected to the line */
    font-size: 14px; /* Make it slightly more readable */
}
/* Ensure third-level submenus also look good */
.sidebar .collapse .collapse {
    margin-left: 20px;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
}

/* MAIN CONTENT */
.main {
    margin-left: var(--sidebar-width);
    padding: 25px;
    width: calc(100% - var(--sidebar-width));
    transition: all 0.3s;
}

.main.expanded {
    margin-left: 80px;
    width: calc(100% - 80px);
}

/* HEADER (Page Title Area) */
.header {
    background: var(--primary-gradient);
    padding: 16px;
    border-radius: 12px;
    color: #fff;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.2);
    position: relative;
    z-index: 1040;
}

.header h1 { font-size: 20px; font-weight: 600; margin: 0; }
.header p { margin: 4px 0 0; opacity: 0.9; font-size: 12px; }

/* CARDS */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.card {
    background: #fff;
    padding: 14px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
    transition: 0.2s;
    border: none;
    display: flex;
    flex-direction: column;
}

.card:hover {
    transform: translateY(-3px);
}

.card h2 {
    font-size: 24px;
    margin-bottom: 4px;
    color: #0f172a;
    font-weight: 700;
}

.section {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
}

.panel {
    background: #fff;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

/* QUICK ACTIONS */
.quick-actions button {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border: none;
    border-radius: 10px;
    background: var(--accent-blue);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    display: block;
}

.quick-actions button:hover {
    background: #0284c7;
}

/* FOOTER */
footer {
    text-align: center;
    margin-top: 16px;
    font-size: 12px;
    color: var(--text-muted);
    padding-bottom: 20px;
}

/* RESPONSIVE */
@media(max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.active {
        transform: translateX(0);
    }
    .main {
        margin-left: 0;
        width: 100%;
    }
    .section {
        grid-template-columns: 1fr;
    }
}
