:root {
    --sidebar-width: 248px;
    --sidebar-collapsed-width: 72px;
    --topbar-height: 60px;
    --brand: #1d5fd6;
    --brand-dark: #123a8c;
    --brand-light: #eaf1ff;
    --sidebar-from: #0b1d3d;
    --sidebar-to: #16305c;
    --sidebar-text: rgba(255, 255, 255, 0.68);
    --sidebar-text-hover: #ffffff;
    --sidebar-active-bg: rgba(255, 255, 255, 0.12);
    --sidebar-heading: rgba(255, 255, 255, 0.38);
    --surface: #f4f6fb;
    --border: #e6e9f2;
    --radius: 10px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-card: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    background: var(--surface);
    color: #1f2933;
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

/* Topbar */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    z-index: 1030;
    padding: 0 1.25rem;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.topbar-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
    box-shadow: 0 2px 6px rgba(29, 95, 214, 0.35);
    color: #fff;
    font-size: 1rem;
}

.topbar-brand-text {
    color: #16233f;
    font-size: 1.02rem;
    letter-spacing: 0.01em;
}

.topbar-icon-btn {
    color: #64748b;
    padding: 0.4rem 0.55rem;
    border-radius: 50%;
    line-height: 1;
}

.topbar-icon-btn:hover {
    background: var(--surface);
    color: var(--brand);
}

.topbar-icon-btn i {
    font-size: 1.15rem;
}

.topbar-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--brand-light);
    color: var(--brand-dark);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

/* App shell */
.app-shell {
    display: flex;
    padding-top: var(--topbar-height);
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, var(--sidebar-from) 0%, var(--sidebar-to) 100%);
    position: fixed;
    top: var(--topbar-height);
    bottom: 0;
    left: 0;
    overflow-x: hidden;
    z-index: 1020;
    transition: transform 0.2s ease, width 0.2s ease;
}

.sidebar-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.1rem 0.85rem;
}

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

.sidebar-footer .sidebar-link {
    margin-bottom: 0;
    cursor: pointer;
}

.sidebar-heading {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sidebar-heading);
    padding: 0.9rem 0.75rem 0.35rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    max-height: 2rem;
    opacity: 1;
    transition: max-height 0.2s ease, opacity 0.15s ease, padding 0.2s ease;
}

.sidebar-heading:first-child {
    padding-top: 0.25rem;
}

.sidebar-divider {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin: 0.6rem 0.75rem 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    text-decoration: none;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
    font-size: 0.9rem;
    margin-bottom: 2px;
    transition: background 0.12s ease, color 0.12s ease;
}

.sidebar-link i {
    font-size: 1rem;
    width: 1.1rem;
    text-align: center;
    color: inherit;
    opacity: 0.9;
    flex-shrink: 0;
}

.sidebar-link span {
    display: inline-block;
    white-space: nowrap;
    overflow: hidden;
    max-width: 220px;
    opacity: 1;
    transition: max-width 0.2s ease, opacity 0.15s ease;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--sidebar-text-hover);
}

.sidebar-link.active {
    background: var(--sidebar-active-bg);
    color: #ffffff;
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--brand);
}

.sidebar-link.disabled {
    color: rgba(255, 255, 255, 0.25);
    cursor: not-allowed;
}

.sidebar-link.disabled:hover {
    background: none;
    color: rgba(255, 255, 255, 0.25);
}

/* Content */
.content {
    margin-left: var(--sidebar-width);
    padding: 1.75rem 2rem;
    width: 100%;
    transition: margin-left 0.2s ease;
}

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

.content-header-actions {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.breadcrumb {
    font-size: 0.82rem;
    align-items: center;
}

.breadcrumb-item a {
    color: #64748b;
    text-decoration: none;
}

.breadcrumb-item a:hover {
    color: var(--brand);
}

.breadcrumb-item.active {
    color: #16233f;
    font-weight: 700;
    font-size: 1.05rem;
}

/* Cards */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
}

.card-body {
    padding: 1.25rem 1.4rem;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
}

/* Buttons */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.88rem;
    padding: 0.5rem 1rem;
}

.btn-sm {
    border-radius: 7px;
    padding: 0.3rem 0.65rem;
    font-size: 0.82rem;
}

.btn-primary {
    background: var(--brand);
    border-color: var(--brand);
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover, .btn-primary:focus {
    background: var(--brand-dark);
    border-color: var(--brand-dark);
}

.btn-outline-secondary {
    color: #475569;
    border-color: var(--border);
}

.btn-outline-secondary:hover {
    background: var(--surface);
    color: #16233f;
    border-color: #cbd5e1;
}

/* Tables */
.table thead th {
    background: var(--surface);
    color: #64748b;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
}

.table td {
    padding: 0.7rem 1rem;
    border-color: var(--border);
    vertical-align: middle;
}

.table-hover tbody tr:hover {
    background: var(--brand-light);
}

/* DataTables integration */
.table thead tr.filters th {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 0.4rem 0.6rem;
}

.table thead tr.filters input {
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
}

div.dataTables_wrapper div.dataTables_length,
div.dataTables_wrapper div.dataTables_filter,
div.dataTables_wrapper div.dataTables_info,
div.dataTables_wrapper div.dataTables_paginate {
    padding: 0.85rem 1.1rem;
    font-size: 0.85rem;
    color: #64748b;
}

div.dataTables_wrapper div.dataTables_filter input,
div.dataTables_wrapper div.dataTables_length select {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

div.dataTables_wrapper div.dataTables_paginate .paginate_button.current,
div.dataTables_wrapper div.dataTables_paginate .paginate_button.current:hover {
    background: var(--brand) !important;
    border-color: var(--brand) !important;
    color: #fff !important;
    border-radius: 6px;
}

div.dataTables_wrapper div.dataTables_paginate .paginate_button {
    border-radius: 6px;
    padding: 0.3rem 0.65rem;
}

table.dataTable thead .sorting:before,
table.dataTable thead .sorting:after,
table.dataTable thead .sorting_asc:before,
table.dataTable thead .sorting_asc:after,
table.dataTable thead .sorting_desc:before,
table.dataTable thead .sorting_desc:after {
    opacity: 0.35;
}

/* Forms */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border);
    background: #fbfcfe;
    font-size: 0.9rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 0.2rem rgba(29, 95, 214, 0.14);
    background: #fff;
}

.form-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 0.35rem;
}

/* Badges */
.badge {
    font-weight: 600;
    letter-spacing: 0.01em;
    padding: 0.4em 0.65em;
    border-radius: 6px;
}

/* Collapsible sidebar (desktop) — icon-only rail when collapsed */
@media (min-width: 992px) {
    html.sidebar-collapsed .sidebar {
        width: var(--sidebar-collapsed-width);
    }

    html.sidebar-collapsed .content {
        margin-left: var(--sidebar-collapsed-width);
    }

    html.sidebar-collapsed .sidebar-heading {
        max-height: 0;
        opacity: 0;
        padding-top: 0;
        padding-bottom: 0;
    }

    html.sidebar-collapsed .sidebar-divider {
        display: none;
    }

    html.sidebar-collapsed .sidebar-link span {
        max-width: 0;
        opacity: 0;
    }

    html.sidebar-collapsed .sidebar-link {
        justify-content: center;
        padding: 0.65rem;
    }

    html.sidebar-collapsed .sidebar-link i {
        width: auto;
        font-size: 1.15rem;
    }
}

.sidebar-collapse-toggle i {
    transition: transform 0.2s ease;
}

html.sidebar-collapsed .sidebar-collapse-toggle i {
    transform: rotate(180deg);
}

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

    .sidebar.show {
        transform: translateX(0);
        box-shadow: 0 0 24px rgba(0, 0, 0, 0.25);
    }

    .content {
        margin-left: 0;
    }
}

/* Печатење фактура */
@media print {
    .topbar, .sidebar, .content-header, .no-print {
        display: none !important;
    }

    .content {
        margin-left: 0;
        padding: 0;
    }

    .printable-invoice {
        box-shadow: none;
        border: none;
    }
}
