/* ============================================
   ZMM Portal - Mazer-inspired Admin Theme
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@300;400;600;700&display=swap');

:root {
    --sidebar-width: 260px;
    --sidebar-bg: #435ebe;
    --sidebar-dark-bg: #3950a2;
    --sidebar-text: rgba(255,255,255,0.7);
    --sidebar-text-active: #fff;
    --sidebar-hover-bg: rgba(255,255,255,0.08);
    --sidebar-active-bg: rgba(255,255,255,0.15);
    --content-bg: #f2f7ff;
    --topbar-bg: #fff;
    --topbar-height: 60px;
    --card-shadow: 0 0 30px rgba(0,0,0,0.05);
    --primary: #435ebe;
    --transition: 0.3s;
}

/* ---- Base ---- */
body {
    font-family: 'Nunito', sans-serif;
    background-color: var(--content-bg);
    overflow-x: hidden;
    color: #25396f;
}

h1, h2, h3, h4, h5, h6 {
    color: #25396f;
    font-weight: 700;
}

a {
    text-decoration: none;
}

/* ---- Sidebar ---- */
#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-dark-bg) 100%);
    z-index: 1040;
    transition: transform var(--transition) ease;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

#sidebar::-webkit-scrollbar {
    width: 5px;
}

#sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 10px;
}

/* Sidebar Header / Brand */
.sidebar-header {
    padding: 1.5rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.sidebar-header .brand-icon {
    width: 38px;
    height: 38px;
    background: rgba(255,255,255,0.15);
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.sidebar-header .brand-text {
    color: #fff;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.sidebar-header .brand-text:hover {
    color: #fff;
}

/* Sidebar Menu */
.sidebar-menu {
    flex: 1;
    padding: 0.75rem;
}

.sidebar-menu .menu-label {
    color: rgba(255,255,255,0.35);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    padding: 1.25rem 0.75rem 0.4rem;
    margin-bottom: 0;
}

.sidebar-menu .nav-item {
    margin-bottom: 2px;
}

.sidebar-menu .nav-link {
    color: var(--sidebar-text);
    padding: 0.6rem 0.85rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.sidebar-menu .nav-link i,
.sidebar-menu .nav-link .bi {
    font-size: 1.05rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-menu .nav-link:hover {
    color: var(--sidebar-text-active);
    background: var(--sidebar-hover-bg);
}

.sidebar-menu .nav-link.active {
    color: var(--sidebar-text-active);
    background: var(--sidebar-active-bg);
}

.sidebar-menu .nav-link .badge {
    margin-left: auto;
    font-size: 0.7rem;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.sidebar-footer .sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: var(--sidebar-text);
    font-size: 0.825rem;
}

.sidebar-footer .user-avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.sidebar-footer .user-info {
    overflow: hidden;
}

.sidebar-footer .user-name {
    color: #fff;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.825rem;
}

.sidebar-footer .user-role {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.45);
}

/* ---- Main Content ---- */
#main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition) ease;
}

#main-content.no-sidebar {
    margin-left: 0;
}

/* Topbar */
.topbar {
    background: var(--topbar-bg);
    min-height: var(--topbar-height);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    position: sticky;
    top: 0;
    z-index: 1030;
    flex-shrink: 0;
}

.topbar .hamburger {
    display: block;
    border: none;
    background: none;
    font-size: 1.4rem;
    color: #6c757d;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    line-height: 1;
}

.topbar .hamburger:hover {
    color: var(--primary);
    background: rgba(67,94,190,0.08);
}

.topbar .page-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #25396f;
    margin: 0;
}

/* User dropdown in topbar */
.user-dropdown .dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: #25396f;
    padding: 0.35rem 0.5rem;
    border-radius: 0.5rem;
    transition: background 0.2s;
}

.user-dropdown .dropdown-toggle:hover {
    background: rgba(67,94,190,0.06);
}

.user-dropdown .dropdown-toggle::after {
    display: none;
}

.user-dropdown .user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.user-dropdown .user-details {
    line-height: 1.2;
}

.user-dropdown .user-details .name {
    font-weight: 600;
    font-size: 0.875rem;
}

.user-dropdown .user-details .role {
    font-size: 0.7rem;
    color: #6c757d;
}

.user-dropdown .dropdown-menu {
    min-width: 200px;
    border: none;
    box-shadow: 0 5px 25px rgba(0,0,0,0.12);
    border-radius: 0.5rem;
    padding: 0.5rem;
}

.user-dropdown .dropdown-item {
    border-radius: 0.35rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.user-dropdown .dropdown-item:hover {
    background: rgba(67,94,190,0.06);
}

/* ---- Content Wrapper ---- */
.content-wrapper {
    flex: 1;
    padding: 1.5rem;
}

/* ---- Card Enhancements ---- */
.card {
    border: none;
    box-shadow: var(--card-shadow);
    border-radius: 0.5rem;
    margin-bottom: 1.25rem;
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    font-weight: 600;
    padding: 1rem 1.25rem;
}

.card-body {
    padding: 1.25rem;
}

/* ---- Page Footer ---- */
.page-footer {
    background: var(--topbar-bg);
    padding: 0.85rem 1.5rem;
    border-top: 1px solid rgba(0,0,0,0.06);
    margin-top: auto;
    flex-shrink: 0;
}

.page-footer p {
    margin-bottom: 0;
    font-size: 0.8rem;
    color: #6c757d;
}

/* ---- Alerts ---- */
.alert {
    border-radius: 0.5rem;
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

/* ---- Tables ---- */
.table {
    font-size: 0.85rem;
    margin-bottom: 0;
}

.table th {
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #25396f;
    vertical-align: middle;
    white-space: nowrap;
}

.table td {
    vertical-align: middle;
}

.table-responsive {
    border-radius: 0.5rem;
}

/* ---- Pivot / Data Table (Mazer style) ---- */
.table-pivot thead th {
    background: linear-gradient(135deg, var(--primary) 0%, var(--sidebar-dark-bg) 100%);
    color: #fff;
    text-transform: none;
    letter-spacing: normal;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.6rem 0.5rem;
    border: 1px solid rgba(255,255,255,0.15);
    position: sticky;
    top: 0;
    z-index: 10;
    text-align: center;
    white-space: normal;
}

.table-pivot tbody td {
    padding: 0.5rem;
    text-align: center;
    border: 1px solid #e9ecef;
    font-size: 0.8rem;
    max-width: 140px;
    word-wrap: break-word;
}

.table-pivot tbody td.text-start {
    text-align: left;
}

.table-pivot tbody tr:hover {
    background-color: rgba(67, 94, 190, 0.06);
}

.table-pivot tbody tr:nth-child(even) {
    background-color: #f8f9ff;
}

.table-pivot tbody tr:nth-child(even):hover {
    background-color: rgba(67, 94, 190, 0.06);
}

.table-pivot .totals-row {
    background-color: #eef2ff !important;
    font-weight: 700;
    border-top: 2px solid var(--primary);
}

.table-pivot .totals-row:hover {
    background-color: #e3e9ff !important;
}

@media (max-width: 768px) {
    .table-pivot thead th,
    .table-pivot tbody td {
        font-size: 0.7rem;
        padding: 0.35rem;
    }
}

/* ---- Tabulator (Mazer style overrides) ---- */
.tabulator .tabulator-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--sidebar-dark-bg) 100%) !important;
    border-bottom: none !important;
}

.tabulator .tabulator-col {
    background: transparent !important;
    border-right: 1px solid rgba(255,255,255,0.15) !important;
    min-height: 80px !important;
    height: auto !important;
    vertical-align: middle !important;
}

.tabulator .tabulator-col-content {
    height: auto !important;
    min-height: 80px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.tabulator .tabulator-col-title {
    color: #fff !important;
    font-weight: 600 !important;
    font-size: 0.8rem !important;
    white-space: normal !important;
    word-wrap: break-word !important;
    overflow: visible !important;
    text-overflow: clip !important;
    line-height: 1.4 !important;
    padding: 10px 6px !important;
}

.tabulator .tabulator-col .tabulator-col-sorter .tabulator-arrow {
    border-bottom-color: rgba(255,255,255,0.6) !important;
}

.tabulator .tabulator-col.tabulator-sortable .tabulator-col-title {
    color: #fff !important;
}

.tabulator .tabulator-cell {
    font-size: 0.75rem;
    padding: 2px 5px !important;
    border-right: 1px solid #e9ecef;
    line-height: 1.3;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: unset !important;
}

.tabulator .tabulator-row {
    min-height: 0 !important;
}

.tabulator .tabulator-row:nth-child(even) {
    background-color: #f8f9ff;
}

.tabulator .tabulator-row:hover {
    background-color: rgba(67, 94, 190, 0.06);
}

.tabulator .tabulator-footer {
    background: #fff;
    border-top: 1px solid #e9ecef;
}

.tabulator .tabulator-footer .tabulator-page.active {
    background-color: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.tabulator .tabulator-footer .tabulator-page:hover:not(.active) {
    background-color: rgba(67, 94, 190, 0.08);
}

/* Editable cells */
.tabulator .tabulator-cell.tabulator-editing {
    background-color: #fff3cd !important;
    border: 2px solid var(--primary) !important;
}

.tabulator .tabulator-cell[tabulator-field="confirmed_quantity"],
.tabulator .tabulator-cell[tabulator-field="actual_delivery_date"],
.tabulator .tabulator-cell[tabulator-field="delivery_status"],
.tabulator .tabulator-cell[tabulator-field="delivery_status_date"] {
    background-color: #eef2ff !important;
    cursor: pointer;
    font-weight: 500;
}

.tabulator .tabulator-cell[tabulator-field="confirmed_quantity"]:hover,
.tabulator .tabulator-cell[tabulator-field="actual_delivery_date"]:hover,
.tabulator .tabulator-cell[tabulator-field="delivery_status"]:hover,
.tabulator .tabulator-cell[tabulator-field="delivery_status_date"]:hover {
    background-color: #dce5ff !important;
    box-shadow: inset 0 0 0 2px var(--primary);
}

/* Status row colors */
.tabulator-row.delivered {
    background-color: #d1e7dd !important;
}

.tabulator-row.ready {
    background-color: #fff3cd !important;
}

.tabulator-row.realized {
    background-color: #ffe5cc !important;
}

.tabulator-row.invoiced {
    background-color: #cfe2ff !important;
}

.tabulator-row.late {
    background-color: #f8d7da !important;
}

/* Orders toolbar */
.table-toolbar {
    background: #fff;
    padding: 1rem 1.25rem;
    border-radius: 0.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--card-shadow);
}

.table-toolbar .filter-box input {
    width: 220px;
}

/* Orders legend */
.legend-box {
    background: #fff;
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
    box-shadow: var(--card-shadow);
    font-size: 0.85rem;
}

.legend-box .badge {
    font-size: 0.75rem;
}

/* ---- Buttons ---- */
.btn {
    border-radius: 0.375rem;
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.45rem 1rem;
}

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

.btn-primary:hover {
    background-color: var(--sidebar-dark-bg);
    border-color: var(--sidebar-dark-bg);
}

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

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

/* ---- Forms ---- */
.form-label {
    font-weight: 600;
    font-size: 0.875rem;
    color: #25396f;
}

.form-control, .form-select {
    border-radius: 0.375rem;
    border-color: #dce7f1;
    font-size: 0.875rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(67,94,190,0.15);
}

/* ---- Badges ---- */
.badge {
    font-weight: 600;
    font-size: 0.75rem;
    padding: 0.35em 0.6em;
    border-radius: 0.35rem;
}

/* ---- Breadcrumb ---- */
.breadcrumb {
    background: transparent;
    padding: 0;
    margin: 0;
    font-size: 0.85rem;
}

/* ---- Breadcrumb Bar ---- */
.breadcrumb-bar {
    background: #fff;
    padding: 0.65rem 1.5rem;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.breadcrumb-bar .breadcrumb {
    font-size: 0.875rem;
}

.breadcrumb-bar .breadcrumb-item a {
    color: var(--primary);
    font-weight: 600;
}

.breadcrumb-bar .breadcrumb-item a:hover {
    color: var(--sidebar-dark-bg);
    text-decoration: underline;
}

.breadcrumb-bar .breadcrumb-item.active {
    color: #6c757d;
    font-weight: 600;
}

.breadcrumb-bar .breadcrumb-item + .breadcrumb-item::before {
    color: #adb5bd;
}

/* ---- Filter Section (used in work_centers) ---- */
.filter-section {
    background-color: #fff;
    border-radius: 0.5rem;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--card-shadow);
}

/* ---- Chart Container (statistics pages) ---- */
.chart-container {
    width: 90%;
    margin: 0 auto 2rem auto;
    background: #fff;
    border-radius: 0.5rem;
    box-shadow: var(--card-shadow);
    padding: 1.5rem;
}

.chart-container canvas {
    max-height: 500px;
}

/* ---- Stat Cards (orders statistics) ---- */
.stat-card {
    border-radius: 0.5rem;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--card-shadow);
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    margin: 0.5rem 0;
}

.stat-label {
    font-size: 0.9rem;
    color: #666;
    text-transform: uppercase;
}

.bg-otcheteni  { background-color: #fff3cd !important; }
.bg-realizirani { background-color: #ffe5cc !important; }
.bg-fakturirani { background-color: #cfe2ff !important; }
.bg-ekspedirani { background-color: #d1e7dd !important; }

/* ---- Sidebar Backdrop (mobile) ---- */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.45);
    z-index: 1035;
    display: none;
    opacity: 0;
    transition: opacity var(--transition) ease;
}

.sidebar-backdrop.show {
    display: block;
    opacity: 1;
}

/* ---- Sidebar Collapsed (desktop toggle) ---- */
@media (min-width: 992px) {
    #sidebar.collapsed {
        transform: translateX(-100%);
    }

    #main-content.sidebar-collapsed {
        margin-left: 0;
    }
}

/* ---- Responsive ---- */
@media (max-width: 991.98px) {
    #sidebar {
        transform: translateX(-100%);
    }

    #sidebar.show {
        transform: translateX(0);
    }

    #main-content {
        margin-left: 0 !important;
    }

    .content-wrapper {
        padding: 1rem;
    }
}

@media (max-width: 575.98px) {
    .content-wrapper {
        padding: 0.75rem;
    }

    .topbar {
        padding: 0 0.75rem;
    }
}

/* ---- Scrollbar (body) ---- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #c0c8d8;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a0a8b8;
}
