/* ============================================================
   Radni centar — custom stil preko Bootstrap 5 osnove
   Moderan, miran, poslovni izgled u duhu AI chat alata.
   ============================================================ */

:root {
    --rc-bg: #f7f7f8;
    --rc-surface: #ffffff;
    --rc-border: #e4e4e7;
    --rc-text: #1c1c1e;
    --rc-text-muted: #6b7280;
    --rc-primary: #2563eb;
    --rc-primary-soft: #eff4ff;
    --rc-accent: #0f172a;
    --rc-success: #16a34a;
    --rc-danger: #dc2626;
    --rc-warning: #d97706;
    --rc-radius: 12px;
    --rc-sidebar-w: 264px;
    --rc-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

html, body {
    height: 100%;
}

body {
    font-family: var(--rc-font);
    background: var(--rc-bg);
    color: var(--rc-text);
    font-size: 15px;
}

/* ---------- Osnovni raspored ---------- */

.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: var(--rc-sidebar-w);
    min-width: var(--rc-sidebar-w);
    background: var(--rc-surface);
    border-right: 1px solid var(--rc-border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 1030;
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    background: var(--rc-surface);
    border-bottom: 1px solid var(--rc-border);
    position: sticky;
    top: 0;
    z-index: 1020;
}

.topbar-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-actions { display: flex; gap: 8px; }

.app-content {
    flex: 1;
    padding: 24px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

/* Chat ekran koristi punu sirinu i visinu bez unutrasnjeg paddinga */
.app-content.chat-screen {
    max-width: none;
    padding: 0;
    display: flex;
    min-height: 0;
}

/* ---------- Sidebar ---------- */

.sidebar-brand {
    padding: 18px 20px 12px;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--rc-text);
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: linear-gradient(135deg, #2563eb, #1e40af);
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.brand-mark-lg { width: 52px; height: 52px; font-size: 1.2rem; border-radius: 14px; }

.brand-name { font-weight: 700; font-size: 1.02rem; }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
}

.nav-section-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--rc-text-muted);
    padding: 14px 10px 6px;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    color: #3f3f46;
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 500;
    margin-bottom: 2px;
    transition: background 0.12s ease;
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.nav-item:hover { background: #f1f2f4; color: var(--rc-text); }

.nav-item.active {
    background: var(--rc-primary-soft);
    color: var(--rc-primary);
}

.badge-soon {
    margin-left: auto;
    font-size: 0.62rem;
    background: #f4f4f5;
    color: var(--rc-text-muted);
    border: 1px solid var(--rc-border);
    padding: 2px 7px;
    border-radius: 20px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.sidebar-footer {
    border-top: 1px solid var(--rc-border);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.user-chip { display: flex; align-items: center; gap: 10px; min-width: 0; }

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

.user-info { min-width: 0; }
.user-name { font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.72rem; color: var(--rc-text-muted); }

.btn-logout {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--rc-text-muted);
    font-size: 0.8rem;
    padding: 6px 8px;
    border-radius: 8px;
}

.btn-logout svg { width: 15px; height: 15px; }
.btn-logout:hover { background: #f1f2f4; color: var(--rc-danger); }

.btn-menu {
    display: none;
    background: none;
    border: none;
    padding: 4px;
    color: var(--rc-text);
}

.btn-menu svg { width: 22px; height: 22px; }

/* ---------- Kartice na dashboardu ---------- */

.dash-intro { margin-bottom: 22px; }
.dash-intro h2 { font-size: 1.45rem; font-weight: 700; margin-bottom: 4px; }
.dash-intro p { color: var(--rc-text-muted); margin: 0; }

.dash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.dash-card {
    background: var(--rc-surface);
    border: 1px solid var(--rc-border);
    border-radius: var(--rc-radius);
    padding: 20px;
    text-decoration: none;
    color: var(--rc-text);
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

.dash-card:hover {
    border-color: #c7d2fe;
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.08);
    transform: translateY(-2px);
    color: var(--rc-text);
}

.dash-card-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: var(--rc-primary-soft);
    color: var(--rc-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}

.dash-card-icon svg { width: 22px; height: 22px; }
.dash-card h3 { font-size: 1.02rem; font-weight: 650; margin: 0; }
.dash-card p { font-size: 0.86rem; color: var(--rc-text-muted); margin: 0; }
.dash-card .dash-meta { font-size: 0.78rem; color: var(--rc-primary); font-weight: 600; margin-top: auto; }

/* ---------- Chat ekran ---------- */

.chat-layout {
    display: flex;
    flex: 1;
    min-height: calc(100vh - 57px);
    min-width: 0;
}

.chat-history {
    width: 280px;
    min-width: 280px;
    border-right: 1px solid var(--rc-border);
    background: var(--rc-surface);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-history-head {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border-bottom: 1px solid var(--rc-border);
}

.chat-history-head span { font-size: 0.85rem; font-weight: 650; color: var(--rc-text-muted); }

.chat-history-list { flex: 1; overflow-y: auto; padding: 8px; }

.chat-history-item {
    display: block;
    padding: 10px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--rc-text);
    margin-bottom: 2px;
}

.chat-history-item:hover { background: #f1f2f4; color: var(--rc-text); }
.chat-history-item.active { background: var(--rc-primary-soft); }

.chat-history-item .chi-title {
    font-size: 0.86rem;
    font-weight: 550;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-history-item .chi-meta {
    font-size: 0.72rem;
    color: var(--rc-text-muted);
    display: flex;
    gap: 6px;
    margin-top: 2px;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-height: calc(100vh - 57px);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.chat-messages-inner {
    max-width: 820px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.chat-empty {
    text-align: center;
    margin: 8vh auto 0;
    max-width: 480px;
    color: var(--rc-text-muted);
}

.chat-empty h3 { color: var(--rc-text); font-weight: 700; font-size: 1.3rem; margin-bottom: 8px; }

.msg-user {
    align-self: flex-end;
    background: var(--rc-primary);
    color: #fff;
    padding: 12px 16px;
    border-radius: 16px 16px 4px 16px;
    max-width: 75%;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 0.93rem;
    line-height: 1.5;
}

.msg-assistant {
    align-self: stretch;
    max-width: 100%;
}

.msg-user-wrap {
    align-self: flex-end;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    max-width: 75%;
}

.msg-user-wrap .msg-user { max-width: 100%; }

.msg-time {
    font-size: 0.7rem;
    color: var(--rc-text-muted);
}

.msg-time-user { margin-top: 3px; padding-right: 4px; }

.msg-error {
    align-self: stretch;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 0.9rem;
}

/* AI odgovor po sekcijama */

.ai-output {
    background: var(--rc-surface);
    border: 1px solid var(--rc-border);
    border-radius: var(--rc-radius);
    overflow: hidden;
}

.ai-output-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--rc-border);
    background: #fafafa;
}

.ai-avatar {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: linear-gradient(135deg, #2563eb, #1e40af);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
}

.ai-output-head .ai-title { font-weight: 650; font-size: 0.88rem; }
.ai-output-head .ai-badges { margin-left: auto; display: flex; gap: 6px; }

.ai-sections { padding: 6px 18px 14px; }

.ai-section { padding: 12px 0; border-bottom: 1px solid #f0f0f2; }
.ai-section:last-child { border-bottom: none; }

.ai-section-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--rc-text-muted);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-section-body { font-size: 0.92rem; line-height: 1.55; white-space: pre-wrap; }

.ai-section ul, .ai-section ol { margin: 0; padding-left: 20px; }
.ai-section li { margin-bottom: 4px; font-size: 0.92rem; line-height: 1.5; }
.ai-section ol li::marker { font-weight: 650; color: var(--rc-primary); }

/* Prikaz prioriteta: korisnicki unos i AI procena odvojeno */

.priority-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 2px;
}

.priority-key { color: var(--rc-text-muted); }

.priority-reason {
    margin-top: 6px;
    font-size: 0.88rem;
    color: var(--rc-text-muted);
    border-left: 3px solid var(--rc-border);
    padding-left: 10px;
}

/* Upozorenja da je odgovor AI nacrt */

.ai-draft-note {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--rc-warning);
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 6px 10px;
    margin-bottom: 8px;
}

.ai-draft-note::before { content: "⚠"; }

.ai-review-warning {
    font-size: 0.82rem;
    color: #92400e;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 8px;
    line-height: 1.45;
}

.copy-confirm {
    font-size: 0.76rem;
    color: var(--rc-success);
    align-self: center;
    font-weight: 600;
}

.ai-draft-inline {
    font-size: 0.74rem;
    color: var(--rc-warning);
    align-self: center;
}

.ai-reply-box {
    background: #f8fafc;
    border: 1px solid var(--rc-border);
    border-radius: 8px;
    padding: 12px 14px;
    white-space: pre-wrap;
    font-size: 0.92rem;
    line-height: 1.55;
}

.ai-output-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 12px 18px;
    border-top: 1px solid var(--rc-border);
    background: #fafafa;
}

/* Kompozer */

.chat-composer {
    border-top: 1px solid var(--rc-border);
    background: var(--rc-surface);
    padding: 14px 24px 18px;
}

.chat-composer-inner { max-width: 820px; margin: 0 auto; }

.chat-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 8px;
    margin-bottom: 10px;
}

.chat-meta-grid .form-select,
.chat-meta-grid .form-control {
    font-size: 0.82rem;
    padding: 6px 10px;
    border-radius: 8px;
}

.composer-box {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--rc-bg);
    border: 1px solid var(--rc-border);
    border-radius: 14px;
    padding: 10px 12px;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.composer-box:focus-within {
    border-color: var(--rc-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.composer-box textarea {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    outline: none;
    font-size: 0.95rem;
    line-height: 1.5;
    max-height: 200px;
    min-height: 44px;
    padding: 8px 4px;
}

.btn-send {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    background: var(--rc-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.12s ease;
}

.btn-send svg { width: 18px; height: 18px; }
.btn-send:hover { background: #1d4ed8; }
.btn-send:disabled { background: #a5b4fc; cursor: not-allowed; }

.composer-hint {
    font-size: 0.72rem;
    color: var(--rc-text-muted);
    margin-top: 6px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

/* Indikator kucanja */

.typing-indicator {
    display: inline-flex;
    gap: 5px;
    padding: 14px 18px;
    background: var(--rc-surface);
    border: 1px solid var(--rc-border);
    border-radius: 14px;
    align-self: flex-start;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    animation: rc-bounce 1.2s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }

@keyframes rc-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* ---------- Opsti UI elementi ---------- */

.page-card {
    background: var(--rc-surface);
    border: 1px solid var(--rc-border);
    border-radius: var(--rc-radius);
    padding: 22px;
    margin-bottom: 18px;
}

.page-card h2, .page-card h5 { font-weight: 650; }

.table-clean {
    background: var(--rc-surface);
    border: 1px solid var(--rc-border);
    border-radius: var(--rc-radius);
    overflow: hidden;
}

.table-clean table { margin: 0; }

.table-clean thead th {
    background: #fafafa;
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--rc-text-muted);
    font-weight: 650;
    border-bottom: 1px solid var(--rc-border);
    padding: 10px 14px;
    white-space: nowrap;
}

.table-clean tbody td {
    padding: 12px 14px;
    font-size: 0.9rem;
    vertical-align: middle;
    border-bottom: 1px solid #f0f0f2;
}

.table-clean tbody tr:last-child td { border-bottom: none; }
.table-clean tbody tr:hover { background: #fafbfc; }

.status-pill {
    display: inline-block;
    font-size: 0.74rem;
    font-weight: 650;
    padding: 3px 10px;
    border-radius: 20px;
    white-space: nowrap;
}

.pill-gray { background: #f4f4f5; color: #52525b; }
.pill-blue { background: var(--rc-primary-soft); color: var(--rc-primary); }
.pill-green { background: #f0fdf4; color: var(--rc-success); }
.pill-red { background: #fef2f2; color: var(--rc-danger); }
.pill-yellow { background: #fffbeb; color: var(--rc-warning); }

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--rc-text-muted);
}

.empty-state svg { width: 44px; height: 44px; margin-bottom: 12px; opacity: 0.4; }

.flash-message { border-radius: 10px; }

.btn { border-radius: 9px; font-weight: 550; }
.btn-primary { background: var(--rc-primary); border-color: var(--rc-primary); }
.btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }

.form-control, .form-select { border-radius: 9px; border-color: var(--rc-border); }
.form-control:focus, .form-select:focus {
    border-color: var(--rc-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-label { font-size: 0.85rem; font-weight: 600; }

/* ---------- Login ---------- */

.login-page {
    background: var(--rc-bg);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-wrapper { width: 100%; max-width: 400px; }

.login-card {
    background: var(--rc-surface);
    border: 1px solid var(--rc-border);
    border-radius: 16px;
    padding: 34px 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

.login-brand { text-align: center; margin-bottom: 26px; }
.login-brand h1 { font-size: 1.35rem; font-weight: 700; margin: 14px 0 4px; }
.login-brand p { font-size: 0.85rem; color: var(--rc-text-muted); margin: 0; }

.login-footnote {
    text-align: center;
    font-size: 0.78rem;
    color: var(--rc-text-muted);
    margin-top: 16px;
}

/* ---------- Responsive ---------- */

/* Tabele na malim ekranima: horizontalni scroll + diskretan indikator */
@media (max-width: 767px) {
    .table-clean { overflow-x: auto; }
    .table-clean table { min-width: 640px; }
    .table-clean::before {
        content: "↔ Tabela može da se pomera bočno";
        display: block;
        padding: 6px 14px;
        font-size: 0.72rem;
        color: var(--rc-text-muted);
        background: #fafafa;
        border-bottom: 1px solid var(--rc-border);
    }
}

@media (max-width: 991px) {
    .app-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: 0 0 40px rgba(0,0,0,0.15);
    }

    .app-sidebar.open { transform: translateX(0); }

    .btn-menu { display: block; }

    .chat-history { display: none; }

    .app-content { padding: 16px; }
}
