@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@400;500;600&display=swap');

:root {
    --bg: radial-gradient(circle at 20% 20%, #101827 0, #0a1221 42%, #050a14 100%);
    --card: rgba(255, 255, 255, 0.045);
    --card-strong: rgba(255, 255, 255, 0.08);
    --stroke: rgba(255, 255, 255, 0.14);
    --stroke-strong: rgba(72, 227, 157, 0.28);
    --text: #e9eef7;
    --muted: #a6b5cc;
    --accent: #48e39d;
    --accent-strong: #2bcf86;
    --accent-soft: rgba(72, 227, 157, 0.18);
    --warning: #f0b429;
    --danger: #ff6b6b;
    --shadow: 0 22px 70px rgba(0, 0, 0, 0.32);
    --radius: 18px;
    --radius-sm: 12px;
    --blur: 18px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', 'Space Grotesk', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    padding-bottom: 2rem;
}

a { color: inherit; text-decoration: none; }

/* Header */
.header {
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(var(--blur));
    background: linear-gradient(130deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03));
    border-bottom: 1px solid var(--stroke);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
}

.header-container {
    max-width: 1550px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-icon {
    filter: drop-shadow(0 4px 12px rgba(72, 227, 157, 0.3));
}

.header-branding {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.header-title {
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0;
    background: linear-gradient(135deg, #ffffff 0%, #a6b5cc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-user {
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 500;
}

.header-user-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-logout-small {
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    background: rgba(255, 107, 107, 0.15);
    color: #ff6b6b;
    border: 1px solid rgba(255, 107, 107, 0.3);
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-logout-small:hover {
    background: rgba(255, 107, 107, 0.25);
    border-color: rgba(255, 107, 107, 0.5);
}

.header-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    align-items: center;
}

/* Layout */
.main-container {
    max-width: 1550px;
    margin: 1.5rem auto 0;
    padding: 0 1.5rem 0;
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 1.35rem;
    align-items: start;
}

.panel {
    background: var(--card);
    border: 1px solid var(--stroke);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(var(--blur));
    overflow: hidden;
    position: relative;
}

.panel::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 1px solid transparent;
    border-radius: calc(var(--radius) + 2px);
    pointer-events: none;
    background: linear-gradient(120deg, rgba(72,227,157,0.12), rgba(255,255,255,0)) border-box;
    mask: linear-gradient(#000 0 0) padding-box, linear-gradient(#000 0 0);
    mask-composite: exclude;
}

.table-panel { grid-column: 1; }
.metrics-panel { grid-column: 1 / -1; }

.panel-header {
    padding: 1.1rem 1.35rem;
    border-bottom: 1px solid var(--stroke);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.panel-header h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.panel-body {
    padding: 1.35rem;
}

.muted { color: var(--muted); }

/* Metrics */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.9rem;
}

.metric-card {
    padding: 1rem 1.1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--stroke);
    background: var(--card-strong);
    box-shadow: var(--shadow);
}

.metric-label {
    color: var(--muted);
    font-size: 0.9rem;
}

.metric-value {
    font-size: 1.9rem;
    font-weight: 700;
    margin: 0.2rem 0 0.25rem;
}

.metric-value.danger { color: var(--danger); }

.metric-foot {
    color: var(--muted);
    font-size: 0.9rem;
}

.panel-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

/* Side panel + Tabs */
.side-panel { grid-column: 2; position: sticky; top: 88px; }
.tabsbar { display: flex; gap: 0.5rem; }
.tab-btn { border: 1px solid var(--stroke); background: var(--card-strong); color: var(--text); padding: 0.5rem 0.8rem; border-radius: 999px; font-weight: 600; cursor: pointer; }
.tab-btn.active { background: linear-gradient(135deg, var(--accent), var(--accent-strong)); color: #0a141f; border-color: transparent; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Pagination */
.pagination { display: flex; gap: 0.75rem; align-items: center; justify-content: flex-end; margin-top: 0.6rem; }
.pagination .btn { padding: 0.5rem 0.8rem; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* Buttons */
.btn {
    border: 1px solid var(--stroke);
    border-radius: var(--radius-sm);
    padding: 0.65rem 1rem;
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.2px;
    cursor: pointer;
    color: var(--text);
    background: var(--card-strong);
    transition: transform 160ms ease, box-shadow 160ms ease, border 160ms ease, background 160ms ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #0a141f;
    box-shadow: 0 8px 30px rgba(72, 227, 157, 0.25);
}

.btn-danger {
    background: rgba(255, 107, 107, 0.15);
    color: #ff8b8b;
    border-color: rgba(255, 107, 107, 0.4);
}

.btn-danger:hover {
    background: rgba(255, 107, 107, 0.25);
    border-color: rgba(255, 107, 107, 0.6);
}

.btn-secondary {
    border-color: var(--stroke);
}

.btn:hover { transform: translateY(-1px); }
.btn-primary:hover { box-shadow: 0 10px 40px rgba(72, 227, 157, 0.35); }

/* Forms */
.simple-form {
    display: grid;
    gap: 0.9rem;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-row label {
    font-size: 0.9rem;
    color: var(--muted);
}

.simple-form input,
.simple-form select {
    width: 100%;
    padding: 0.7rem 0.85rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--stroke);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    outline: none;
    transition: border 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.simple-form select option {
    color: #0a0f1a;
    background: #f6f8fb;
}

.simple-form input:focus,
.simple-form select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
    background: rgba(255, 255, 255, 0.07);
}

/* Table */
.inventory-table {
    width: 100%;
    border-collapse: collapse;
    background: transparent;
}

.inventory-table thead th {
    text-align: left;
    font-weight: 600;
    color: var(--muted);
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid var(--stroke);
    letter-spacing: 0.3px;
}

.inventory-table thead th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 1.5rem;
    transition: color 0.2s ease;
}

.inventory-table thead th.sortable:hover {
    color: var(--text);
}

.inventory-table thead th.sortable::after {
    content: '⇅';
    position: absolute;
    right: 0.5rem;
    opacity: 0.3;
    font-size: 0.9rem;
    transition: opacity 0.2s ease;
}

.inventory-table thead th.sortable:hover::after {
    opacity: 0.6;
}

.inventory-table thead th.sortable.sort-asc::after {
    content: '▲';
    opacity: 1;
    color: var(--accent);
}

.inventory-table thead th.sortable.sort-desc::after {
    content: '▼';
    opacity: 1;
    color: var(--accent);
}

.inventory-table tbody td {
    padding: 0.9rem 0.5rem;
    border-bottom: 1px solid var(--stroke);
    font-weight: 500;
    vertical-align: top;
}

.inventory-table tbody tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

.inventory-table tbody tr:last-child td {
    border-bottom: none;
}

.col-name { min-width: 200px; }
.col-desc { min-width: 200px; color: var(--muted); }
.col-qty { width: 90px; text-align: center; }
.col-status { width: 140px; }
.col-param { min-width: 140px; }
.col-cat { width: 120px; }

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-weight: 700;
    letter-spacing: 0.2px;
    border: 1px solid transparent;
    font-size: 0.9rem;
}

.status-critical { background: rgba(255,107,107,0.16); color: #ffc7c7; border-color: rgba(255,107,107,0.35); }
.status-warning { background: rgba(255,195,113,0.14); color: #ffe2b8; border-color: rgba(255,195,113,0.35); }
.status-normal { background: rgba(91,179,255,0.14); color: #d6e9ff; border-color: rgba(91,179,255,0.32); }
.status-sufficient { background: var(--accent-soft); color: #c8ffe5; border-color: var(--stroke-strong); }

.inventory-table strong { font-weight: 700; }

.name-cell { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; }
.btn-copy {
    padding: 0.28rem 0.6rem;
    font-size: 0.82rem;
    line-height: 1;
    border-radius: 10px;
    background: rgba(72, 227, 157, 0.12);
    border-color: var(--stroke-strong);
    color: var(--text);
}
.btn-copy:hover { background: rgba(72, 227, 157, 0.2); }

/* Transactions */
.transactions-list {
    display: grid;
    gap: 0.75rem;
}

.transaction-item {
    padding: 0.9rem 1rem;
    border: 1px solid var(--stroke);
    border-radius: var(--radius-sm);
    background: var(--card-strong);
}

.transaction-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.6rem;
    font-size: 0.95rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--stroke);
}

.transaction-type {
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-weight: 700;
    letter-spacing: 0.25px;
}

.transaction-type.UZETO { background: rgba(255, 107, 107, 0.2); color: #ffc8c8; }
.transaction-type.VRACENO { background: var(--accent-soft); color: #c8ffe5; }

.transaction-time { color: var(--muted); font-size: 0.9rem; }

.transaction-details { font-size: 0.95rem; line-height: 1.6; }
.transaction-details div { margin-bottom: 0.3rem; }
.transaction-details strong { color: var(--accent); font-weight: 600; margin-right: 0.4rem; }

/* Toasts */
#toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    z-index: 1000;
}

.toast {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--stroke);
    background: var(--card-strong);
    color: var(--text);
    min-width: 200px;
    box-shadow: var(--shadow);
}

.toast.success { border-color: rgba(72, 227, 157, 0.6); }
.toast.error { border-color: rgba(255, 107, 107, 0.6); }
.toast.info { border-color: rgba(255, 255, 255, 0.2); }

/* Inputs next to filters */
.panel-actions input[type="date"] {
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--stroke);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
}

.panel-actions input[type="date"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
    outline: none;
}

/* Utility */
small { color: var(--muted); }

@media (max-width: 720px) {
    .header-container { flex-direction: column; align-items: flex-start; }
    .header-actions { width: 100%; }
    .panel-header { flex-direction: column; align-items: flex-start; }
    .panel-actions { width: 100%; }
    .main-container { grid-template-columns: 1fr; }
    .side-panel { position: static; grid-column: 1; }
}
