/* ============================================================
   TROUBLE TICKETING - Design System v2
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --tt-primary:       #4f7df9;
    --tt-primary-light: #eff6ff;
    --tt-primary-dark:  #3b63d4;
    --tt-sidebar-bg:    #0f172a;
    --tt-sidebar-width: 240px;
    --tt-bg:            #f1f5f9;
    --tt-surface:       #ffffff;
    --tt-border:        #e2e8f0;
    --tt-text:          #0f172a;
    --tt-text-muted:    #64748b;
    --tt-success:       #22c55e;
    --tt-warning:       #f59e0b;
    --tt-danger:        #ef4444;
    --tt-orange:        #f97316;
    --tt-gray:          #64748b;
    --tt-light:         #f8fafc;
    --tt-shadow:        0 1px 4px rgba(15,23,42,0.06);
    --tt-shadow-md:     0 4px 16px rgba(15,23,42,0.10);
    --tt-radius:        10px;
    --tt-radius-sm:     6px;
}

/* ─── BASE ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--tt-text);
    background: var(--tt-bg);
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--tt-primary); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--tt-primary-dark); }

/* ─── SIDEBAR ───────────────────────────────────────────── */
.tt-sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--tt-sidebar-width);
    height: 100vh;
    background: var(--tt-sidebar-bg);
    color: #e2e8f0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform 0.25s ease;
}

.tt-sidebar .sidebar-header {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.tt-sidebar .sidebar-header .brand-icon {
    width: 32px; height: 32px;
    background: rgba(79,125,249,0.2);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: var(--tt-primary);
    font-size: 1rem;
    flex-shrink: 0;
}

.tt-sidebar .sidebar-header .brand-text {
    font-size: 0.875rem;
    font-weight: 700;
    color: #f8fafc;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.tt-sidebar .sidebar-header .brand-sub {
    font-size: 0.65rem;
    color: #64748b;
    font-weight: 400;
}

.tt-sidebar .sidebar-user {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    font-size: 0.75rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.tt-sidebar .sidebar-user .user-avatar {
    width: 28px; height: 28px;
    background: var(--tt-primary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    text-transform: uppercase;
}

.tt-sidebar .sidebar-user .user-name {
    font-weight: 600;
    color: #e2e8f0;
    font-size: 0.775rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tt-sidebar .sidebar-user .user-role {
    font-size: 0.65rem;
    color: #64748b;
    margin-top: 0.05rem;
}

.tt-sidebar .sidebar-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.tt-sidebar .sidebar-content::-webkit-scrollbar { width: 3px; }
.tt-sidebar .sidebar-content::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
}

.tt-sidebar .nav-section {
    padding: 0.875rem 1.25rem 0.3rem;
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: #475569;
    font-weight: 600;
}

.tt-sidebar .nav-link {
    color: #94a3b8;
    padding: 0.45rem 1.25rem;
    font-size: 0.8rem;
    font-weight: 500;
    border-left: 2px solid transparent;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    transition: all 0.15s ease;
    border-radius: 0;
    position: relative;
}

.tt-sidebar .nav-link i {
    font-size: 0.95rem;
    width: 1.1rem;
    text-align: center;
    flex-shrink: 0;
}

.tt-sidebar .nav-link:hover {
    color: #e2e8f0;
    background: rgba(255,255,255,0.05);
    border-left-color: rgba(79,125,249,0.4);
    text-decoration: none;
}

.tt-sidebar .nav-link.active {
    color: #fff;
    background: rgba(79,125,249,0.12);
    border-left-color: var(--tt-primary);
    font-weight: 600;
}

.sidebar-footer {
    flex-shrink: 0;
    padding: 0.75rem;
    border-top: 1px solid rgba(255,255,255,0.07);
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.sidebar-footer .nav-link {
    border-radius: var(--tt-radius-sm);
    border-left: none;
    padding: 0.4rem 0.75rem;
}

.sidebar-footer .nav-link:hover {
    border-left: none;
    background: rgba(255,255,255,0.07);
}

.sidebar-footer .nav-link.text-warning { color: #fbbf24 !important; }
.sidebar-footer .nav-link.text-warning:hover { color: #f59e0b !important; background: rgba(251,191,36,0.1); }

/* ─── MAIN CONTENT ──────────────────────────────────────── */
.tt-main {
    margin-left: var(--tt-sidebar-width);
    min-height: 100vh;
    background: var(--tt-bg);
}

.tt-topbar {
    background: var(--tt-surface);
    border-bottom: 1px solid var(--tt-border);
    padding: 0 1.5rem;
    height: 52px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.tt-topbar .topbar-breadcrumb {
    font-size: 0.8rem;
    color: var(--tt-text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.tt-topbar .topbar-breadcrumb .breadcrumb-current {
    color: var(--tt-text);
    font-weight: 600;
}

.tt-topbar .topbar-date {
    font-size: 0.75rem;
    color: var(--tt-text-muted);
    font-weight: 500;
}

.tt-content { padding: 1.5rem; }

/* ─── CARDS ─────────────────────────────────────────────── */
.stat-card {
    background: var(--tt-surface);
    border: 1px solid var(--tt-border);
    border-radius: var(--tt-radius);
    box-shadow: var(--tt-shadow);
    border-left: none;
}

.stat-card .card-body { padding: 1.1rem 1.25rem; }

.stat-card .card-header {
    background: transparent;
    border-bottom: 1px solid var(--tt-border);
    padding: 0.75rem 1.25rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--tt-text);
}

/* Override border-left colored da Bootstrap */
.border-left-primary,
.border-left-success,
.border-left-warning,
.border-left-danger {
    border-left: none !important;
}

/* Indicatore colorato sull'icona */
.stat-card .stat-icon {
    font-size: 1.6rem;
    opacity: 1;
}
.stat-card .stat-icon.text-primary { color: var(--tt-primary) !important; opacity: 0.25; }
.stat-card .stat-icon.text-success { color: var(--tt-success) !important; opacity: 0.3; }
.stat-card .stat-icon.text-warning { color: var(--tt-warning) !important; opacity: 0.4; }
.stat-card .stat-icon.text-danger  { color: var(--tt-danger) !important;  opacity: 0.35; }

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    color: var(--tt-text);
    letter-spacing: -0.02em;
}

.stat-card .stat-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--tt-text-muted);
    margin-top: 0.25rem;
    font-weight: 500;
}

/* ─── GENERIC CARD ──────────────────────────────────────── */
.card {
    background: var(--tt-surface);
    border: 1px solid var(--tt-border);
    border-radius: var(--tt-radius);
    box-shadow: var(--tt-shadow);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--tt-border);
    padding: 0.875rem 1.25rem;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--tt-text);
}

/* ─── TABELLE ───────────────────────────────────────────── */
.ticket-table-container {
    width: 100%;
    overflow-x: auto;
    background: var(--tt-surface);
    border-radius: var(--tt-radius);
    border: 1px solid var(--tt-border);
    box-shadow: var(--tt-shadow);
}

.ticket-table {
    font-size: 0.82rem;
    width: 100%;
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0;
}

.ticket-table th {
    background: #f8fafc;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--tt-text-muted);
    padding: 0.65rem 0.875rem;
    border-bottom: 1px solid var(--tt-border);
    text-align: left;
    white-space: nowrap;
}

.ticket-table td {
    padding: 0.7rem 0.875rem;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
    color: var(--tt-text);
}

.ticket-table tbody tr:last-child td { border-bottom: none; }

.ticket-table tbody tr:hover {
    background: #f8fafc;
    cursor: pointer;
}

.ticket-number {
    font-weight: 700;
    color: var(--tt-primary);
    font-size: 0.78rem;
    letter-spacing: -0.01em;
}

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ─── BADGES ─────────────────────────────────────────────── */
.badge-status {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.25em 0.6em;
    border-radius: 20px;
    letter-spacing: 0.02em;
    display: inline-block;
}

.badge-Aperto          { background: rgba(59,130,246,0.12);  color: #1d4ed8; }
.badge-Assegnato       { background: rgba(139,92,246,0.12);  color: #6d28d9; }
.badge-InLavorazione   { background: rgba(249,115,22,0.12);  color: #c2410c; }
.badge-InAttesaCliente { background: rgba(245,158,11,0.12);  color: #92400e; }
.badge-Chiuso          { background: rgba(34,197,94,0.12);   color: #15803d; }

.priority-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 500;
}

.priority-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 0.4rem;
    flex-shrink: 0;
}

/* ─── TOPBAR SPECIFICO ──────────────────────────────────── */
#topbarBreadcrumb {
    font-size: 0.8rem;
    color: var(--tt-text-muted);
}

#topbarDate {
    font-size: 0.75rem;
    color: var(--tt-text-muted);
}

/* ─── FORM & INPUT ───────────────────────────────────────── */
.form-control, .form-select {
    border-radius: var(--tt-radius-sm);
    border-color: var(--tt-border);
    font-size: 0.875rem;
    color: var(--tt-text);
    background: var(--tt-surface);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus, .form-select:focus {
    border-color: var(--tt-primary);
    box-shadow: 0 0 0 3px rgba(79,125,249,0.15);
    outline: none;
}

.form-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--tt-text);
    margin-bottom: 0.35rem;
}

/* ─── BUTTONS ────────────────────────────────────────────── */
.btn {
    border-radius: var(--tt-radius-sm);
    font-weight: 500;
    font-size: 0.8rem;
    padding: 0.45rem 1rem;
    transition: all 0.15s ease;
}

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

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

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

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

.btn-sm {
    font-size: 0.75rem;
    padding: 0.3rem 0.7rem;
}

/* ─── TICKET DETAIL ──────────────────────────────────────── */
.ticket-detail-header {
    background: var(--tt-surface);
    border: 1px solid var(--tt-border);
    border-radius: var(--tt-radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--tt-shadow);
    margin-bottom: 0;
}

.ticket-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    border-top: 1px solid var(--tt-border);
    padding-top: 0.875rem;
    margin-top: 0.875rem;
}

.meta-item {
    display: flex;
    flex-direction: column;
    padding: 0.25rem 1.25rem 0.25rem 0;
    margin-right: 0.25rem;
    border-right: 1px solid var(--tt-border);
    min-width: 85px;
}

.meta-item:last-child { border-right: none; }

.meta-label {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--tt-text-muted);
    font-weight: 600;
    margin-bottom: 0.15rem;
}

.meta-value {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--tt-text);
}

/* ─── SLA ────────────────────────────────────────────────── */
.sla-ok      { color: var(--tt-success); font-weight: 600; }
.sla-warning { color: var(--tt-orange);  font-weight: 600; }
.sla-breached { color: var(--tt-danger); font-weight: 600; }

/* ─── MESSAGGI ───────────────────────────────────────────── */
.message-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.message-item {
    padding: 0.75rem 1rem;
    border-radius: var(--tt-radius-sm);
    border-left: 3px solid var(--tt-border);
    background: var(--tt-light);
    font-size: 0.85rem;
}

.message-item.staff {
    background: #eff6ff;
    border-left-color: var(--tt-primary);
}

.message-item.customer {
    background: #f8fafc;
    border-left-color: #cbd5e1;
}

.message-item.internal {
    background: #fffbeb;
    border-left-color: var(--tt-warning);
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.35rem;
    gap: 0.5rem;
}

.message-author {
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--tt-text);
}

.message-time {
    font-size: 0.72rem;
    color: var(--tt-text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.message-body {
    white-space: pre-wrap;
    word-break: break-word;
    color: #334155;
    font-size: 0.85rem;
    line-height: 1.55;
}

/* ─── HISTORY ────────────────────────────────────────────── */
.history-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.78rem;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
}

.history-item:last-child { border-bottom: none; }

.history-action {
    font-weight: 600;
    color: var(--tt-primary);
}

.history-time {
    color: var(--tt-text-muted);
    font-size: 0.72rem;
    flex-shrink: 0;
}

/* ─── EMPTY STATE ────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--tt-text-muted);
}

.empty-state i {
    font-size: 2.25rem;
    display: block;
    margin-bottom: 0.75rem;
    opacity: 0.25;
}

/* ─── SOLICITATION BADGE ─────────────────────────────────── */
.solicitation-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--tt-danger);
    color: white;
    border-radius: 50%;
    font-size: 0.58rem;
    font-weight: 700;
    width: 1rem;
    height: 1rem;
    vertical-align: middle;
    line-height: 1;
}

/* ─── MODALI ─────────────────────────────────────────────── */
.modal-content {
    border: 1px solid var(--tt-border);
    border-radius: var(--tt-radius);
    box-shadow: var(--tt-shadow-md);
}

.modal-header {
    border-bottom: 1px solid var(--tt-border);
    padding: 1rem 1.25rem;
}

.modal-title {
    font-size: 0.9rem;
    font-weight: 700;
}

.modal-footer {
    border-top: 1px solid var(--tt-border);
    padding: 0.75rem 1.25rem;
}

/* ─── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 768px) {
    .tt-sidebar { transform: translateX(-100%); }
    .tt-sidebar.show { transform: translateX(0); }
    .tt-main { margin-left: 0; }
    .ticket-table .col-hide-mobile { display: none; }
    .ticket-meta { gap: 0.5rem; }
    .meta-item { border-right: none; padding-right: 0.5rem; min-width: 70px; }
}

.sidebar-toggle {
    display: none;
    position: fixed;
    top: 0.75rem; left: 0.75rem;
    z-index: 1001;
    background: var(--tt-sidebar-bg);
    color: white;
    border: none;
    border-radius: var(--tt-radius-sm);
    padding: 0.4rem 0.6rem;
    font-size: 1.1rem;
    box-shadow: var(--tt-shadow-md);
}

@media (max-width: 768px) { .sidebar-toggle { display: block; } }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.show { display: block; }

/* ─── ALERT ──────────────────────────────────────────────── */
.alert {
    border-radius: var(--tt-radius-sm);
    font-size: 0.85rem;
    border: none;
    padding: 0.75rem 1rem;
}

.alert-danger  { background: rgba(239,68,68,0.08);  color: #b91c1c; }
.alert-success { background: rgba(34,197,94,0.08);  color: #15803d; }
.alert-warning { background: rgba(245,158,11,0.08); color: #92400e; }
.alert-info    { background: rgba(79,125,249,0.08); color: #1d4ed8; }

/* ─── PAGINATION ─────────────────────────────────────────── */
.pagination .page-link {
    border-color: var(--tt-border);
    color: var(--tt-primary);
    font-size: 0.8rem;
    border-radius: var(--tt-radius-sm) !important;
    margin: 0 2px;
}

.pagination .page-item.active .page-link {
    background: var(--tt-primary);
    border-color: var(--tt-primary);
    color: white;
}

/* ─── MISC ───────────────────────────────────────────────── */
.text-muted { color: var(--tt-text-muted) !important; }
.bg-light { background: var(--tt-light) !important; }

hr { border-color: var(--tt-border); opacity: 1; }

/* ─── RATING STARS ──────────────────────────────────────── */
.rating-container {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.rating-star-wrap {
    position: relative;
    display: inline-block;
    width: 1.3rem;
    height: 1.3rem;
    cursor: pointer;
}

.rating-star-wrap .star-icon {
    font-size: 1.3rem;
    color: #FFC107;
    transition: transform 0.12s ease;
    display: block;
    line-height: 1;
}

.rating-star-wrap:hover .star-icon {
    transform: scale(1.15);
}

.rating-star-wrap .star-half-left,
.rating-star-wrap .star-half-right {
    position: absolute;
    top: 0;
    height: 100%;
    width: 50%;
    z-index: 1;
}

.rating-star-wrap .star-half-left { left: 0; }
.rating-star-wrap .star-half-right { right: 0; }

.rating-static {
    display: inline-flex;
    align-items: center;
    gap: 1px;
}

.rating-static .star-icon {
    font-size: 1rem;
    color: #FFC107;
    line-height: 1;
}

/* ─── SEARCHABLE DROPDOWN ──────────────────────────────── */
.searchable-dropdown {
    position: relative;
}

.searchable-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1050;
    max-height: 220px;
    overflow-y: auto;
    background: var(--tt-surface);
    border: 1px solid var(--tt-border);
    border-radius: var(--tt-radius-sm);
    box-shadow: var(--tt-shadow-md);
    margin-top: 2px;
}

.searchable-dropdown-menu.show {
    display: block;
}

.searchable-dropdown-item {
    padding: 6px 10px;
    font-size: 0.82rem;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.searchable-dropdown-item:hover {
    background: var(--tt-primary-light);
    color: var(--tt-primary-dark);
}

/* Scrollbar globale */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
