/* ROMULUS ERP - Custom Styles */
/* Colors: #1F2A53 (dark blue), #CBB373 (gold), #FFFFFF (white) */

:root {
    --r-blue: #1F2A53;
    --r-blue-light: #2a3a6e;
    --r-gold: #CBB373;
    --r-gold-hover: #b89f5e;
    --r-white: #FFFFFF;
    --r-gray-bg: #f4f6f9;
    --r-gray-text: #6c757d;
    --r-sidebar-width: 240px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--r-gray-bg);
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--r-sidebar-width);
    height: 100vh;
    background: var(--r-blue);
    color: var(--r-white);
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.3s;
}

.sidebar-brand {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--r-gold);
    letter-spacing: 2px;
}

.sidebar-brand small {
    color: rgba(255,255,255,0.5);
    font-size: 0.7rem;
}

.sidebar-nav {
    padding: 10px 0;
}

.sidebar-section {
    padding: 8px 20px 4px;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255,255,255,0.35);
    margin-top: 8px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 0.88rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
    background: rgba(255,255,255,0.08);
    color: var(--r-white);
}

.sidebar-nav a.active {
    background: rgba(255,255,255,0.1);
    color: var(--r-gold);
    border-left-color: var(--r-gold);
}

.sidebar-nav a i {
    font-size: 1rem;
    width: 20px;
    text-align: center;
}

/* Main content */
.main-content {
    margin-left: var(--r-sidebar-width);
    min-height: 100vh;
}

/* Top bar */
.topbar {
    background: var(--r-white);
    padding: 12px 24px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--r-blue);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--r-gray-text);
    font-size: 0.85rem;
}

/* Page content */
.page-content {
    padding: 24px;
}

/* Cards */
.stat-card {
    background: var(--r-white);
    border-radius: 8px;
    padding: 20px;
    border: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: var(--r-white);
}

.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--r-blue);
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--r-gray-text);
}

/* Buttons */
.btn-gold {
    background: var(--r-gold);
    border-color: var(--r-gold);
    color: var(--r-blue);
    font-weight: 600;
}

.btn-gold:hover {
    background: var(--r-gold-hover);
    border-color: var(--r-gold-hover);
    color: var(--r-blue);
}

.btn-blue {
    background: var(--r-blue);
    border-color: var(--r-blue);
    color: var(--r-white);
}

.btn-blue:hover {
    background: var(--r-blue-light);
    border-color: var(--r-blue-light);
    color: var(--r-white);
}

/* Tables */
.table-container {
    background: var(--r-white);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-container .table {
    margin-bottom: 0;
}

.table-container .table thead th {
    background: var(--r-blue);
    color: var(--r-white);
    font-weight: 500;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
    padding: 12px 16px;
    white-space: nowrap;
}

.table-container .table tbody td {
    padding: 10px 16px;
    font-size: 0.88rem;
    vertical-align: middle;
    border-color: #f0f0f0;
    white-space: nowrap;
}

.table-container .table tbody tr:hover {
    background: rgba(203,179,115,0.06);
}

/* Status badges */
.badge-nacrt { background: #6c757d; }
.badge-poslat { background: #0d6efd; }
.badge-odobren { background: #198754; }
.badge-odbijen { background: #dc3545; }
.badge-fakturisan { background: var(--r-gold); color: var(--r-blue); }
.badge-izdat { background: #0dcaf0; color: #000; }
.badge-poslat_sef { background: #0d6efd; }
.badge-odobren_sef { background: #198754; }
.badge-storniran { background: #dc3545; }
.badge-placen { background: #198754; }
.badge-kreiran { background: #6c757d; }
.badge-u_pripremi { background: #ffc107; color: #000; }
.badge-u_proizvodnji { background: #0d6efd; }
.badge-zavrsen { background: #198754; }
.badge-isporucen { background: var(--r-gold); color: var(--r-blue); }
.badge-kreirana { background: #6c757d; }
.badge-poslata { background: #0d6efd; }
.badge-isporucena { background: #198754; }

/* Ponude status badges */
.badge-ponuda-nacrt { background: #6c757d; }
.badge-ponuda-poslata { background: #0d6efd; }
.badge-ponuda-prihvacena { background: #198754; }
.badge-ponuda-odbijena { background: #dc3545; }
.badge-ponuda-istekla { background: #fd7e14; }

/* Priority badges */
.badge-nizak { background: #6c757d; }
.badge-srednji { background: #0d6efd; }
.badge-visok { background: #fd7e14; }
.badge-hitan { background: #dc3545; }

/* Modal */
.modal-header {
    background: var(--r-blue);
    color: var(--r-white);
}

.modal-header .btn-close {
    filter: brightness(0) invert(1);
}

/* Loading spinner */
.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 60px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--r-gray-text);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.3;
}

/* Stavke table in forms */
.stavke-table input {
    font-size: 0.85rem;
}

.stavke-table .form-control-sm {
    padding: 0.25rem 0.5rem;
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 64px;
    right: 20px;
    z-index: 10000;
    pointer-events: none;
}
.toast-container .alert {
    pointer-events: all;
}

/* ========== MOBILE APP LAUNCHER GRID ========== */
.mobile-app-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 4px 0 8px;
}
.mobile-app-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 18px 8px 14px;
    border-radius: 24px;
    text-decoration: none !important;
    color: white !important;
    gap: 8px;
    box-shadow: 0 4px 18px rgba(0,0,0,0.22), inset 0 1px 0 rgba(255,255,255,0.28);
    min-height: 92px;
    transition: transform 0.15s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.15s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    overflow: hidden;
}
.mobile-app-tile::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(145deg, rgba(255,255,255,0.2) 0%, transparent 55%);
    pointer-events: none;
    border-radius: inherit;
}
.mobile-app-tile:active {
    transform: scale(0.91);
    box-shadow: 0 1px 6px rgba(0,0,0,0.18);
}
.mobile-app-tile i {
    font-size: 1.9rem;
    line-height: 1;
    position: relative;
}
.mobile-app-tile span {
    font-size: 0.72rem;
    font-weight: 500;
    text-align: center;
    line-height: 1.2;
    text-transform: none;
    opacity: 0.96;
    position: relative;
    letter-spacing: 0;
}

/* ========== MOBILE CARDS (liste) ========== */
.mobile-card {
    background: white;
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.09);
}
.mobile-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 4px;
}
.mobile-card-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--r-blue);
    text-decoration: none;
}
.mobile-card-title:hover { text-decoration: underline; }
.mobile-card-meta {
    font-size: 0.82rem;
    color: var(--r-gray-text);
    margin-bottom: 6px;
}
.mobile-card-footer {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #f0f0f0;
}

/* Mobile bottom navigation */
.mobile-bottom-nav {
    position: fixed;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
    left: 12px;
    right: 12px;
    height: 58px;
    background: #fff;
    border: 1.5px solid #dee2e6;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 1050;
    box-shadow: 0 4px 24px rgba(0,0,0,0.13);
}
.mob-nav-btn {
    flex: 1;
    height: 58px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--r-gray-text);
    font-size: 0.62rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s;
}
.mob-nav-btn i { font-size: 1.35rem; line-height: 1; }
.mob-nav-btn:active { color: var(--r-blue); }

/* Utility Mobile Bar (hidden on desktop, shown on mobile) */
.utility-mobile-bar {
    display: none;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    white-space: nowrap;
    width: 100%;
    padding: 2px 0;
    scrollbar-width: none;
}
.utility-mobile-bar::-webkit-scrollbar { display: none; }
.umob-item {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--r-blue);
    white-space: nowrap;
    flex-shrink: 0;
}
.umob-station {
    font-size: 0.68rem;
    color: #198754;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 1;
}
.umob-sep {
    width: 1px;
    height: 14px;
    background: #ddd;
    flex-shrink: 0;
}
.umob-radio-select {
    font-size: 0.7rem;
    padding: 2px 4px;
    border-radius: 4px;
    border: 1px solid #ccc;
    max-width: 90px;
    min-width: 60px;
    background: #fff;
    color: var(--r-blue);
    flex-shrink: 1;
}

/* Mobile */
.sidebar-toggle {
    display: none;
    background: var(--r-blue);
    color: var(--r-white);
    border: none;
    padding: 8px 12px;
    font-size: 1.2rem;
    cursor: pointer;
}

/* Sidebar overlay - mobilni */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        border-radius: 0 20px 20px 0;
        box-shadow: 6px 0 24px rgba(0,0,0,0.3);
        width: min(82vw, 260px);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .sidebar-toggle {
        display: none;
    }
    .topbar {
        padding: 8px 12px;
        flex-wrap: wrap;
    }
    .utility-header {
        order: 3;
        width: 100%;
        flex-wrap: wrap;
        justify-content: center;
        padding: 6px 0 2px;
        gap: 4px 10px;
        font-size: 0.7rem;
        border-top: 1px solid #eee;
        margin-top: 4px;
    }
    .utility-header .utility-divider {
        display: none;
    }
    .utility-radio select {
        max-width: 80px;
        font-size: 0.68rem;
    }
    .utility-clock {
        font-size: 0.68rem;
    }
    .utility-kurs {
        font-size: 0.68rem;
    }
    .utility-weather {
        font-size: 0.68rem;
    }
    /* Tabele na mobilnom */
    .page-content {
        padding: 12px 8px;
    }
    .table-container .table thead th {
        font-size: 0.7rem;
        padding: 8px 10px;
        letter-spacing: 0;
    }
    .table-container .table tbody td {
        font-size: 0.78rem;
        padding: 7px 10px;
    }
    .table-container .table .btn-sm {
        padding: 2px 5px;
        font-size: 0.7rem;
    }
    /* Hint za horizontalni scroll */
    .table-container {
        position: relative;
    }
    .table-container::after {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        width: 20px;
        height: 100%;
        background: linear-gradient(to right, transparent, rgba(0,0,0,0.04));
        pointer-events: none;
    }
    /* Naslovi stranica */
    .d-flex.justify-content-between.mb-3 {
        gap: 8px !important;
    }
    .d-flex.justify-content-between.mb-3 h5 {
        font-size: 1rem;
    }

    /* Utility header: kompaktan na mobilnom — sakrij desktop sadrzaj, prikazi mobile bar */
    .utility-radio, .utility-clock, .utility-kurs, .utility-weather, .utility-divider {
        display: none !important;
    }
    .utility-mobile-bar { display: flex !important; }

    /* Main content: spusti dole za bottom nav visinu (58px nav + 12px od dna + 14px gap iznad) */
    .main-content {
        padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px));
    }

    /* Chat FAB: iznad bottom nav-a */
    .chat-fab {
        bottom: calc(86px + env(safe-area-inset-bottom, 0px)) !important;
        right: 16px !important;
    }

    /* Topbar: kompaktan user info */
    .topbar-username, .topbar-role-badge { display: none !important; }

    /* Input: spreci auto-zoom (mora biti 16px) */
    input[type="text"], input[type="number"], input[type="email"],
    input[type="password"], input[type="tel"], input[type="search"],
    textarea, select { font-size: 16px !important; }

    /* Modali: pun sirina na mobilnom */
    .modal-dialog {
        margin: 8px auto;
        max-width: calc(100vw - 16px) !important;
    }
    /* modal-xl i modal-lg: full-screen */
    .modal-dialog.modal-xl, .modal-dialog.modal-lg {
        margin: 0;
        max-width: 100vw !important;
        min-height: 100dvh;
    }
    .modal-dialog.modal-xl .modal-content,
    .modal-dialog.modal-lg .modal-content {
        border-radius: 0;
        min-height: 100dvh;
    }
    .modal-dialog.modal-xl .modal-body,
    .modal-dialog.modal-lg .modal-body {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Alarm/Delete popup: override inline min-width */
    .popup-centered {
        width: calc(100vw - 32px) !important;
        min-width: unset !important;
        max-width: calc(100vw - 32px) !important;
    }

    /* Chat panel: full-screen na mobilnom */
    .chat-panel {
        position: fixed !important;
        inset: 0 !important;
        bottom: 0 !important;
        right: 0 !important;
        width: 100vw !important;
        height: 100dvh !important;
        max-width: 100vw !important;
        border-radius: 0 !important;
        z-index: 2000 !important;
        resize: none !important;
    }

    /* Touch targets */
    .btn { min-height: 40px; }
    .btn-sm { min-height: 36px; }
    .btn.btn-sm.py-0 { min-height: unset; }

    /* Search-select dropdown: prilagodi sirini */
    .search-select-dd {
        min-width: 0;
        width: calc(100vw - 40px);
        max-width: 320px;
    }

    /* Stavke forma u modal: horizontalni scroll */
    .stavke-table { min-width: 680px; }

    /* Toast: puna sirina na dnu */
    .toast-container {
        top: auto;
        bottom: 16px;
        right: 8px;
        left: 8px;
    }
    .toast-container .alert {
        min-width: 0 !important;
        max-width: 100% !important;
    }
}

/* Permissions grid u Users modalu */
.perm-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.15rem 0.5rem;
    max-height: 280px;
    overflow-y: auto;
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 0.375rem;
    border: 1px solid #dee2e6;
}
.perm-grid .form-check { margin-bottom: 0; }

/* Print */
@media print {
    .sidebar, .topbar, .no-print, .toast-container { display: none !important; }
    .mobile-bottom-nav { display: none !important; }
    .chat-fab, .chat-panel { display: none !important; }
    .ai-widget-fab, .ai-widget-panel, [class*="ai-asistent"] { display: none !important; }
    .sip-phone, .radio-player { display: none !important; }
    .main-content { margin-left: 0; }
    .page-content { padding: 10px; }
    .btn { display: none !important; }
    .table-container { box-shadow: none; }
}

/* Badge for otkazan status */
.badge-otkazan { background: #dc3545; }

/* Utility Header */
.utility-header {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.8rem;
}

.utility-clock {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--r-blue);
    font-weight: 600;
    white-space: nowrap;
}

.utility-radio {
    display: flex;
    align-items: center;
    gap: 6px;
}

.utility-radio select {
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid #ccc;
    max-width: 120px;
    background: #fff;
}

.utility-radio .radio-btn {
    background: var(--r-blue);
    color: var(--r-white);
    border: none;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.7rem;
    transition: background 0.2s;
}

.utility-radio .radio-btn:hover {
    background: var(--r-gold);
    color: var(--r-blue);
}

.utility-radio .radio-btn.playing {
    background: #198754;
    animation: pulse-radio 2s infinite;
}

@keyframes pulse-radio {
    0%, 100% { box-shadow: 0 0 0 0 rgba(25,135,84,0.4); }
    50% { box-shadow: 0 0 0 4px rgba(25,135,84,0); }
}

.utility-radio input[type="range"] {
    width: 50px;
    height: 4px;
    accent-color: var(--r-blue);
}

.utility-kurs {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--r-blue);
    font-weight: 600;
    white-space: nowrap;
}

.utility-weather {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--r-blue);
    cursor: pointer;
    white-space: nowrap;
}

.utility-weather:hover {
    color: var(--r-gold-hover);
}

.utility-divider {
    width: 1px;
    height: 20px;
    background: #ddd;
}

@media (max-width: 992px) {
    .utility-header {
        gap: 10px;
        font-size: 0.75rem;
    }
    .utility-weather span,
    .utility-kurs span {
        font-size: 0.72rem;
    }
}

/* Search Select Component */
.search-select-ctrl {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    min-height: calc(1.5em + 0.5rem + 2px);
    padding-right: 2rem;
    white-space: nowrap;
    overflow: hidden;
}
.search-select-ctrl:focus {
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13,110,253,.25);
}
.search-select-lbl {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    pointer-events: none;
    font-size: 0.85rem;
}
.search-select-dd {
    min-width: 300px;
    z-index: 9999;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    overflow: hidden;
}
.ss-sw { padding: 6px 6px 4px; border-bottom: 1px solid #f0f0f0; }
.ss-list { max-height: 220px; overflow-y: auto; }
.ss-opt {
    padding: 5px 10px;
    cursor: pointer;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ss-opt:hover, .ss-opt.hl { background: #f0f4ff; }
.ss-opt.selected { background: rgba(31,42,83,0.09); font-weight: 500; color: var(--r-blue); }
.ss-opt.selected.hl { background: rgba(31,42,83,0.15); }
.ss-empty { padding: 8px 10px; color: #6c757d; font-size: 0.82rem; font-style: italic; }

/* Kalkulator uvoza modal */
.kalkulator-result {
    background: #e8f5e9;
    border-radius: 8px;
    padding: 12px;
    margin-top: 12px;
}

.kalkulator-result .result-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--r-blue);
}

/* === SIP PHONE === */
.sip-fab {
    position: fixed; bottom: 88px; right: 24px;
    width: 56px; height: 56px; border-radius: 50%;
    background: #546e7a; color: white; border: none;
    font-size: 1.4rem; cursor: pointer; z-index: 8000;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    display: flex; align-items: center; justify-content: center;
    flex-direction: column; gap: 1px;
    transition: background 0.2s, transform 0.2s;
}
.sip-fab:hover { transform: scale(1.08); }
.sip-fab.sip-fab-reg { background: #2e7d32; }
.sip-fab.sip-fab-active { background: #c62828; animation: sip-pulse 1.5s infinite; }
.sip-fab.sip-fab-incoming { background: #e65100; animation: sip-pulse 0.8s infinite; }
.sip-fab-timer { font-size: 0.55rem; font-weight: 700; line-height: 1; }

@keyframes sip-pulse {
    0%,100% { box-shadow: 0 4px 16px rgba(0,0,0,0.25); }
    50% { box-shadow: 0 4px 24px rgba(198,40,40,0.6); }
}

.sip-panel {
    position: fixed; bottom: 155px; right: 24px;
    width: 300px; background: white; border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.22);
    z-index: 8001; overflow: hidden; user-select: none;
    resize: both; min-width: 260px; min-height: 200px;
}
.sip-panel-header {
    background: #37474f; color: white;
    padding: 10px 12px; display: flex; align-items: center; gap: 8px;
    cursor: grab; user-select: none;
}
.sip-ext-label { font-weight: 700; font-size: .95rem; }
.sip-status-txt { flex: 1; font-size: .72rem; opacity: .8; }
.sip-close-btn { background: none; border: none; color: white; opacity: .7; cursor: pointer; font-size: .9rem; padding: 0; }
.sip-close-btn:hover { opacity: 1; }

/* Status LED */
.sip-led {
    width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
    transition: background 0.3s;
}
.sip-led-gray   { background: #9e9e9e; }
.sip-led-green  { background: #43a047; }
.sip-led-red    { background: #e53935; }
.sip-led-orange { background: #fb8c00; }
.sip-led-pulse  { animation: led-pulse 1s infinite; }
@keyframes led-pulse {
    0%,100% { opacity: 1; } 50% { opacity: 0.4; }
}

/* Incoming view (in panel) */
.sip-incoming-view { padding: 24px 16px; text-align: center; }
.sip-ring-icon { font-size: 2.5rem; color: #e65100; margin-bottom: 8px; animation: sip-ring 0.6s infinite alternate; }
@keyframes sip-ring { from { transform: rotate(-12deg); } to { transform: rotate(12deg); } }
.sip-caller-number { font-size: 1.3rem; font-weight: 700; color: #1F2A53; }
.sip-caller-name   { font-size: .85rem; color: #546e7a; margin: 4px 0 16px; }
.sip-incoming-btns { display: flex; gap: 24px; justify-content: center; }

/* Active call view */
.sip-active-view { padding: 24px 16px; text-align: center; }
.sip-active-number { font-size: 1.2rem; font-weight: 700; color: #1F2A53; }
.sip-active-name   { font-size: .82rem; color: #546e7a; }
.sip-active-timer  { font-size: 1.6rem; font-weight: 300; color: #2e7d32; margin: 12px 0; letter-spacing: 2px; }
.sip-active-btns   { display: flex; gap: 16px; justify-content: center; }
.sip-mute-btn {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    background: #eceff1; border: none; border-radius: 12px;
    padding: 12px 16px; font-size: .7rem; color: #546e7a; cursor: pointer;
    transition: background 0.2s;
}
.sip-mute-btn i { font-size: 1.3rem; }
.sip-mute-btn.active { background: #ffccbc; color: #bf360c; }

/* Dialer */
.sip-dialer-view { padding: 12px; }
.sip-display-row {
    display: flex; align-items: center; gap: 6px; margin-bottom: 6px;
}
.sip-display-input {
    flex: 1; border: 2px solid #e0e0e0; border-radius: 10px;
    padding: 8px 12px; font-size: 1.1rem; font-weight: 600;
    text-align: center; outline: none; color: #1F2A53;
}
.sip-display-input:focus { border-color: #90a4ae; }
.sip-backspace-btn {
    background: none; border: none; color: #90a4ae; font-size: 1.1rem;
    cursor: pointer; padding: 6px; border-radius: 8px;
}
.sip-backspace-btn:hover { color: #546e7a; background: #f5f5f5; }

.sip-search-results {
    max-height: 100px; overflow-y: auto; margin-bottom: 6px;
    border: 1px solid #e0e0e0; border-radius: 8px; font-size: .82rem;
}
.sip-customer-row {
    display: flex; flex-direction: column;
    padding: 6px 10px; border-bottom: 1px solid #f5f5f5;
}
.sip-customer-row:last-child { border-bottom: none; }
.sip-customer-name { font-weight: 600; color: #1F2A53; font-size: .82rem; }
.sip-customer-phones { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 3px; }
.sip-phone-pick-btn {
    font-size: .72rem; padding: 2px 8px; border-radius: 12px;
    background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7;
    cursor: pointer; display: inline-flex; align-items: center; gap: 3px;
    transition: background 0.1s;
}
.sip-phone-pick-btn:hover { background: #c8e6c9; }
.sip-hangup-sm {
    width: 46px; height: 46px; border-radius: 50%;
    background: #c62828; color: white; border: none;
    font-size: 1.1rem; cursor: pointer;
    box-shadow: 0 3px 10px rgba(198,40,40,0.35);
    transition: transform 0.15s, opacity 0.15s;
    margin-right: 12px;
}
.sip-hangup-sm:hover:not(:disabled) { transform: scale(1.08); }
.sip-hangup-sm:disabled { background: #ef9a9a; box-shadow: none; cursor: not-allowed; opacity: 0.45; }
.sip-callable { color: #1b5e20 !important; }
.sip-callable:hover { background: rgba(46,125,50,0.08); border-radius: 3px; }
.sip-inline-icon { font-size: .65em; margin-left: 3px; vertical-align: middle; opacity: .65; }

.sip-keypad {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
    margin-bottom: 10px;
}
.sip-key {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: #f5f7fa; border: 1px solid #e8eaed; border-radius: 10px;
    padding: 10px 4px 8px; cursor: pointer; gap: 1px;
    transition: background 0.1s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}
.sip-key:active { background: #e8eaed; transform: scale(0.94); }
.sip-key-num { font-size: 1.15rem; font-weight: 600; color: #1F2A53; line-height: 1; }
.sip-key-sub { font-size: 0.52rem; color: #90a4ae; letter-spacing: 1px; line-height: 1; }

.sip-calling-anim {
    text-align: center; padding: 20px; color: #e65100;
    font-size: .9rem; font-weight: 600;
}
.sip-action-row { display: flex; justify-content: center; padding: 4px 0 8px; }
.sip-warn { text-align: center; font-size: .72rem; color: #f57c00; padding: 4px 0 8px; }

/* Call/Hangup buttons */
.sip-call-btn {
    width: 58px; height: 58px; border-radius: 50%;
    background: #2e7d32; color: white; border: none;
    font-size: 1.3rem; cursor: pointer;
    box-shadow: 0 3px 10px rgba(46,125,50,0.4);
    transition: transform 0.15s;
}
.sip-call-btn:hover { transform: scale(1.08); }
.sip-call-btn:disabled { background: #a5d6a7; box-shadow: none; cursor: not-allowed; }
.sip-hangup-btn-lg {
    display: flex; align-items: center; gap: 8px;
    background: #c62828; color: white; border: none;
    padding: 12px 24px; border-radius: 30px; font-size: .9rem;
    cursor: pointer; box-shadow: 0 3px 10px rgba(198,40,40,0.4);
    transition: transform 0.15s;
}
.sip-hangup-btn-lg:hover { transform: scale(1.05); }

/* Answer / Reject buttons */
.sip-answer-btn {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    background: #2e7d32; color: white; border: none;
    width: 62px; height: 62px; border-radius: 50%;
    font-size: 1.3rem; cursor: pointer;
    box-shadow: 0 3px 10px rgba(46,125,50,0.4);
}
.sip-answer-btn span { font-size: .6rem; line-height: 1; }
.sip-reject-btn {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    background: #c62828; color: white; border: none;
    width: 62px; height: 62px; border-radius: 50%;
    font-size: 1.3rem; cursor: pointer;
    box-shadow: 0 3px 10px rgba(198,40,40,0.4);
}
.sip-reject-btn span { font-size: .6rem; line-height: 1; }

/* Incoming overlay (kad je panel zatvoren) */
.sip-incoming-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.55);
    z-index: 9500; display: flex; align-items: center; justify-content: center;
}
.sip-incoming-card {
    background: white; border-radius: 24px;
    padding: 32px 40px; text-align: center;
    box-shadow: 0 16px 60px rgba(0,0,0,0.35);
    min-width: 280px;
}
.sip-inc-ring {
    font-size: 3rem; color: #e65100;
    margin-bottom: 12px; animation: sip-ring 0.5s infinite alternate;
}
.sip-inc-title  { font-size: .85rem; color: #546e7a; margin-bottom: 4px; }
.sip-inc-number { font-size: 1.5rem; font-weight: 700; color: #1F2A53; }
.sip-inc-name   { font-size: .9rem; color: #2e7d32; margin: 4px 0 20px; }
.sip-inc-btns   { display: flex; gap: 32px; justify-content: center; margin-top: 20px; }

/* Mobile adjustments */
@media (max-width: 768px) {
    .sip-fab { bottom: calc(150px + env(safe-area-inset-bottom,0px)) !important; right: 16px !important; }
    .sip-panel {
        position: fixed !important; inset: 0 !important;
        width: 100vw !important; max-width: 100vw !important;
        height: 100dvh !important; border-radius: 0 !important;
        bottom: 0 !important; right: 0 !important;
        z-index: 8002 !important; resize: none !important;
    }
    .sip-incoming-card { width: calc(100vw - 40px); }
}

/* === AI ASISTENT === */
.ai-fab { position:fixed; bottom:152px; right:24px; width:56px; height:56px;
    border-radius:50%; background:linear-gradient(135deg,#1F2A53,#3a4a8a); color:white; border:none;
    font-size:1.4rem; cursor:pointer; z-index:8000;
    box-shadow:0 4px 16px rgba(0,0,0,0.3); display:flex; align-items:center;
    justify-content:center; transition:transform 0.2s; }
.ai-fab:hover { transform:scale(1.08); }
.ai-panel { position:fixed; bottom:220px; right:24px; width:360px; height:520px;
    background:white; border-radius:16px; box-shadow:0 8px 40px rgba(0,0,0,0.22);
    z-index:8001; display:flex; flex-direction:column; overflow:hidden;
    resize:both; min-width:300px; min-height:350px; }
.ai-panel-header { background:linear-gradient(135deg,#1F2A53,#3a4a8a); color:white;
    padding:10px 14px; display:flex; align-items:center; justify-content:space-between; flex-shrink:0;
    cursor:grab; user-select:none; }
.ai-panel-header span { font-weight:600; font-size:.95rem; }
.ai-messages { flex:1; overflow-y:auto; padding:12px; display:flex; flex-direction:column; gap:8px; }
.ai-msg { display:flex; }
.ai-msg-user { justify-content:flex-end; }
.ai-msg-ai { justify-content:flex-start; }
.ai-bubble { max-width:85%; padding:8px 12px; border-radius:14px; font-size:.85rem; line-height:1.5; }
.ai-msg-user .ai-bubble { background:#1F2A53; color:white; border-bottom-right-radius:4px; }
.ai-msg-ai .ai-bubble { background:#f0f2f5; color:#1a1a2e; border-bottom-left-radius:4px; }
.ai-thinking { display:flex; gap:4px; align-items:center; padding:12px 14px; }
.ai-thinking span { width:7px; height:7px; border-radius:50%; background:#888;
    animation:aiDot 1.2s infinite ease-in-out; }
.ai-thinking span:nth-child(2) { animation-delay:.2s; }
.ai-thinking span:nth-child(3) { animation-delay:.4s; }
@keyframes aiDot { 0%,80%,100%{transform:scale(0.7);opacity:.5} 40%{transform:scale(1);opacity:1} }
.ai-input-row { padding:10px 12px; border-top:1px solid #eee; display:flex; gap:6px; flex-shrink:0; }
.ai-input-row input { flex:1; }
@media (max-width: 768px) {
    .ai-fab { bottom:calc(214px + env(safe-area-inset-bottom,0px)) !important; right:16px !important; }
    .ai-panel { position:fixed !important; inset:0 !important; width:100% !important; height:100% !important;
        bottom:0 !important; right:0 !important; border-radius:0 !important; resize:none !important; }
}

/* === CHAT === */
.chat-fab { position:fixed; bottom:24px; right:24px; width:56px; height:56px;
    border-radius:50%; background:var(--r-blue); color:white; border:none;
    font-size:1.4rem; cursor:pointer; z-index:8000;
    box-shadow:0 4px 16px rgba(0,0,0,0.25); display:flex; align-items:center;
    justify-content:center; transition:transform 0.2s; }
.chat-fab:hover { transform:scale(1.08); background:var(--r-blue-light); }
.chat-fab-badge { position:absolute; top:-4px; right:-4px; background:#dc3545;
    color:white; border-radius:10px; font-size:.65rem; min-width:18px; height:18px;
    display:flex; align-items:center; justify-content:center; padding:0 4px; font-weight:700; }
.chat-panel { position:fixed; bottom:90px; right:24px; width:340px; height:500px;
    background:white; border-radius:16px; box-shadow:0 8px 40px rgba(0,0,0,0.22);
    z-index:8001; display:flex; flex-direction:column; overflow:hidden;
    resize:both; min-width:280px; min-height:350px; }
.chat-panel-header { background:var(--r-blue); color:white; padding:10px 14px;
    display:flex; align-items:center; gap:8px; flex-shrink:0;
    cursor:grab; user-select:none; }
.chat-panel-header strong { flex:1; font-size:.95rem; }
.chat-search { padding:8px 12px; border-bottom:1px solid #eee; flex-shrink:0; }
.chat-msgs { flex:1; overflow-y:auto; padding:10px; display:flex;
    flex-direction:column; gap:4px; }
.chat-msg-other { align-self:flex-start; max-width:82%; }
.chat-msg-me { align-self:flex-end; max-width:82%; }
.chat-bubble { padding:7px 11px; border-radius:14px; font-size:.85rem;
    line-height:1.4; word-break:break-word; display:inline-block; }
.chat-msg-other .chat-bubble { background:#f0f2f5; border-bottom-left-radius:4px; }
.chat-msg-me .chat-bubble { background:var(--r-blue); color:white; border-bottom-right-radius:4px; }
.chat-sender { font-size:.72rem; color:#888; margin-bottom:2px; }
.chat-time { font-size:.68rem; color:#aaa; margin-top:2px; }
.chat-msg-me .chat-time { text-align:right; }
.chat-seen-by { font-size:.64rem; color:#aaa; margin-top:1px; opacity:.85; }
.chat-input-row { padding:8px 10px; border-top:1px solid #eee; display:flex; gap:6px; flex-shrink:0; }
.chat-contact-item { display:flex; align-items:center; gap:10px; padding:10px 14px;
    cursor:pointer; border-bottom:1px solid #f5f5f5; transition:background 0.15s; }
.chat-contact-item:hover { background:#f4f6f9; }
.chat-contact-avatar { width:36px; height:36px; border-radius:50%; background:var(--r-blue);
    color:white; display:flex; align-items:center; justify-content:center;
    font-size:.85rem; font-weight:700; flex-shrink:0; }
.chat-contact-avatar.group { background:var(--r-gold); color:var(--r-blue); }
.chat-contact-info { flex:1; min-width:0; }
.chat-contact-name { font-weight:600; font-size:.88rem; }
.chat-contact-preview { font-size:.75rem; color:#888; white-space:nowrap;
    overflow:hidden; text-overflow:ellipsis; }
.chat-unread-badge { background:#dc3545; color:white; border-radius:10px;
    font-size:.68rem; min-width:18px; height:18px; display:flex; align-items:center;
    justify-content:center; padding:0 5px; font-weight:700; margin-left:auto; flex-shrink:0; }
/* Chat edit/delete actions */
.btn-chat-act { width:22px; height:22px; border-radius:50%; border:none;
    background:#e9ecef; color:#555; display:flex; align-items:center;
    justify-content:center; cursor:pointer; font-size:.65rem; padding:0;
    transition:background .1s; flex-shrink:0; }
.btn-chat-act:hover { background:#ced4da; }
.btn-chat-act-del:hover { background:#f8d7da; color:#dc3545; }
.chat-bubble-deleted { opacity:.55; font-style:italic; font-size:.82rem; }
/* Linkovi i copy-on-click unutar chat bubble-a */
.chat-msg-me .chat-bubble a { color:#cce5ff; }
.chat-msg-me .chat-bubble .copy-number { border-bottom-color:rgba(255,255,255,.5); }
.chat-edited-tag { font-size:.62rem; opacity:.65; margin-left:5px; }
/* Emoji Picker */
.emoji-picker-popup { position:absolute; bottom:calc(100% + 4px); left:0; z-index:2000;
    background:#fff; border:1px solid #dee2e6; border-radius:12px; padding:8px;
    width:264px; max-height:210px; overflow-y:auto;
    box-shadow:0 4px 24px rgba(0,0,0,.18); }
.emoji-grid { display:flex; flex-wrap:wrap; gap:2px; }
.emoji-btn-item { font-size:1.25rem; cursor:pointer; padding:3px 4px;
    border-radius:6px; line-height:1; user-select:none; transition:background .1s; }
.emoji-btn-item:hover { background:#f0f0f0; }
/* Flatpickr alt input — Bootstrap stilovi */
.datepick-alt { background:#fff !important; }
.flatpickr-calendar { font-size:.85rem; }
.flatpickr-day.selected, .flatpickr-day.selected:hover { background:var(--r-blue); border-color:var(--r-blue); }
/* Zebra platno badge */
.badge.bg-purple { background-color: #6f42c1 !important; color: white; }
