
:root { --sidebar-w: 250px; }
:root {

  /* BACKGROUND */
  --bg: #ffffff;
  --bg-panel: #f8f9fb;
  --bg-soft: #eef2f7;
  --bg-hover: #f1f3f6;

  /* TEXT */
  --text: #1f2937;
  --text-soft: #6b7280;

  /* BORDER */
  --border: #e5e7eb;

  /* PRIMARY (blu moderno) */
  --primary: #3b82f6;
  --primary-soft: rgba(59,130,246,0.15);

  /* STATUS */
  --status-open: #3b82f6;
  --status-open-bg: rgba(59,130,246,0.15);

  --status-progress: #f59e0b;
  --status-progress-bg: rgba(245,158,11,0.18);

}

.dark {

  --bg: #1e1e1e;
  --bg-panel: #2a2a2a;
  --bg-soft: #333;
  --bg-hover: #3a3a3a;

  --text: #e5e7eb;
  --text-soft: #9ca3af;

  --border: #444;

}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  //display: flex;
  height: 100vh;
  font-family: "Segoe UI", sans-serif;
  background: #f5f5f5;
  color: #222;
  overflow: hidden;
  transition: all 0.3s ease;
}

#app-container {
  display: flex;
  width: 100%;
  height: 100vh;
}

/* === SIDEBAR === */
.sidebar {
  background: #2c3e50; color: #fff;
  width: var(--sidebar-w);
  height: 100vh;
  position: relative;
  flex-shrink: 0;
  display: flex; flex-direction: column;
  border-right: 1px solid rgba(255,255,255,0.08);
  //transition: transform 0.35s ease, opacity 0.25s ease;
  z-index: 3;
}
.sidebar.hidden {
  transform: translateX(-100%);
  opacity: 0;
  position: absolute;
}

.brand {
  padding: 16px; background: #253646;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-weight: 700; letter-spacing: .3px;
  white-space: nowrap;
}

.navwrap { overflow-y: auto; flex: 1; }

.sidebar ul { list-style: none; }
.sidebar li {
  padding: 10px 15px; cursor: pointer;
  user-select: none; position: relative; white-space: nowrap;
}
.sidebar li:hover { background: #34495e; }
.sidebar li .caret { float: right; transition: transform 0.2s; }
.sidebar li.open > .caret { transform: rotate(90deg); }
.sidebar ul ul { display: none; background: #34495e; }
.sidebar li.open > ul { display: block; animation: fadeIn 0.25s; }
@keyframes fadeIn { from{opacity:0;transform:translateY(-4px)} to{opacity:1;transform:translateY(0)} }

/* === RIGHT SECTION === */
.right-section {
  display: flex;
  flex-direction: column;
  flex: 1;
  height: 100vh;
  width: calc(100% - var(--sidebar-w));
  transition: width 0.3s ease;
}
.sidebar.hidden + .right-section {
  width: 100%;
}

/* === TOPBAR === */
.topbar {
  height: 50px;
  background: #222;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 15px;
  border-bottom: 1px solid #111;
  flex-shrink: 0;
}
.menu-left, .menu-right { display: flex; align-items: center; gap: 15px; }
.menu-left i { cursor: pointer; font-size: 1.5em; }

.dropdown { position: relative; cursor: pointer; }
.dropdown-content {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  background: #333;
  border-radius: 6px;
  overflow: hidden;
  min-width: 180px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
  z-index: 999;
}
.dropdown-content a {
  display: block;
  color: #fff;
  text-decoration: none;
  padding: 10px 14px;
}
.dropdown-content a:hover { background: #444; }
.dropdown.open .dropdown-content { display: block; }

/* === MAIN === */
.main {
  flex: 1;
  //padding: 20px;
  overflow-y: auto;
  //background: #f5f5f5;
  background: #fff;
  
}

/* === MODAL === */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: rgba(0,0,0,0.6);
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  z-index: 10000;
  padding-top: 10vh;
}
.modal.show { visibility: visible; opacity: 1; }
.modal-content {
  background: #fff;
  padding: 20px 30px;
  border-radius: 8px;
  text-align: center;
  box-shadow: 0 5px 20px rgba(0,0,0,0.3);
}
.modal.large .modal-content {
  width: 90%;
  max-width: 800px;
  height: 60%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.modal.small .modal-content { width: 90%; max-width: 350px; }

/* === AUTH === */
.auth-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

#app-container.auth-mode {
  display: block;
}

.auth-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-box {
  background: #fff;
  padding: 30px;
  border-radius: 8px;
  width: 100%;
  max-width: 350px;
  box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

.auth-box h2 {
  margin-bottom: 20px;
  text-align: center;
}

.auth-box input {
  width: 100%;
  padding: 10px;
  margin-bottom: 15px;
  border: 1px solid #ccc;
  border-radius: 6px;
}

.auth-box button {
  width: 100%;
  padding: 10px;
  background: #2c3e50;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}

.auth-box button:hover {
  background: #1a252f;
}

.auth-footer {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  background: #eee;
  color: #555;
}

.input-error {
  font-size: 12px;
  color: #d93025;
  margin: -10px 0 10px;
}

.auth-error {
  display: none;
  background: #fdecea;
  color: #d93025;
  padding: 10px;
  border-radius: 6px;
  margin-bottom: 15px;
  font-size: 13px;
}

/* === DEVTOOLS === */
.dev-panel {
  position: fixed;
  bottom: 10px;
  right: 10px;
  width: 300px;
  background: #111;
  color: #0f0;
  font-size: 12px;
  border-radius: 8px;
  box-shadow: 0 5px 20px rgba(0,0,0,.5);
  z-index: 99999;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.dev-header {
  background: #000;
  padding: 8px;
  border-bottom: 1px solid #333;
}

.dev-body {
  padding: 10px;
  display: flex;
  gap: 10px;
}

.dev-body button {
  flex: 1;
  padding: 6px;
  background: #222;
  color: #0f0;
  border: 1px solid #333;
  cursor: pointer;
}

.dev-body button:hover {
  background: #333;
}

#devOutput {
  padding: 10px;
  max-height: 200px;
  overflow: auto;
  white-space: pre-wrap;
}



















/* struttura base */
.navwrap,
.navwrap ul{
  list-style:none;
  margin:0;
  padding:0;
}

/* item */
.menu-item{
  user-select:none;
}

/* label cliccabile */
.menu-label{
  display:flex;
  align-items:center;
  padding:10px 12px;
  cursor:pointer;
  gap:8px;
}

/* hover */
.menu-label:hover{
  background:var(--bg-hover);
}

/* titolo */
.menu-title{
  flex:1;
}

/* caret */
.caret{
  transition:transform 0.2s ease;
}

/* nascondi submenu di default */
.menu-item ul{
  display:none;
  padding-left:12px;
}

/* quando aperto */
.menu-item.open > ul{
  display:block;
}

/* rotazione caret quando aperto */
.menu-item.open > .menu-label .caret{
  transform:rotate(90deg);
}














.tickets-container{
  display:flex;
  height:100%;
}

.tickets-list{
  width:300px;
  border-right:1px solid var(--border);
  overflow-y:auto;
}

.reports-list-panel{
  padding-top:10px;
  display:flex;
  flex-direction:column;
  height:100%;
  background:var(--bg-panel);
  //border-right:1px solid var(--border);
}

.reports-list-tabs{
  display:flex;
  //gap:20px;
  padding:0 12px;
  border-bottom:1px solid var(--border);
}

/* singolo tab */
.reports-list-tabs{
  display:flex;
  border-bottom:1px solid #dee2e6;
  padding:0 12px;
}

/* tab */
.reports-tab{
  border:1px solid #eee;
  border-top-left-radius:6px;
  border-top-right-radius:6px;

  padding:7px 7px;
  margin-bottom:-1px; /* 🔥 per attaccarsi alla linea */

  background:transparent;
  color:#495057;

  font-size:13px;
  cursor:pointer;

  transition:all 0.2s ease;
}

/* hover */
.reports-tab:hover{
  background:#f8f9fa;
  border-color:#e9ecef #e9ecef #dee2e6;
}

/* attivo */
.reports-tab.active{
  background:#fff;
  color:#212529;

  border-color:#dee2e6 #dee2e6 #fff;
  font-weight:500;
}

/* tab */
.reports-tab{
  display:flex;
  align-items:center;
  gap:6px; /* 🔥 badge di fianco */
}

.reports-list-empty{
  padding: 30px 15px 15px 15px;
  text-align:center;
}

/* label */
.tab-label{
  display:inline-block;
}

/* badge base */
.tab-badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;

  min-width:18px;
  height:18px;
  padding:0 6px;

  font-size:11px;
  font-weight:600;

  border-radius:6px;

  line-height:1;
}

/* 🎨 PASTEL COLORS */

/* tutte */
.tab-badge.is-all{
  background:#f3f4f6;   /* grigio pastello */
  color:#6b7280;
}

/* aperte */
.tab-badge.is-open{
  //background:#dbeafe;   /* blu pastello */
  //color:#2563eb;
  background: #3a7d6f;
  color:#fff;
  //opacity:0.5;

}

/* in carico */
.tab-badge.is-progress{
  //background:#fef3c7;   /* giallo pastello */
  //color:#d97706;
  background: #c27a3f;
  color:#fff;
  //opacity:0.5;
}

/* attivo */
.reports-tab.active .tab-badge{
  //background:#e0e7ff;   /* leggermente più evidente */
  //color:#1d4ed8;
}

.reports-list-search{
  position:relative;
  padding:12px;
  background:#fff;
}

/* input */
.reports-list-search input{
  width:100%;
  padding:10px 40px 10px 14px; /* spazio per icona a destra */

  border:none;
  border-radius:999px;

  background:var(--bg);
  color:var(--text);

  outline:none;

  /* 🔥 shadow input */
  box-shadow:
    0 2px 6px rgba(0,0,0,0.08),
    0 6px 16px rgba(0,0,0,0.10);

  transition:all 0.2s ease;
}

/* focus */
.reports-list-search input:focus{
  box-shadow:
    0 0 0 2px rgba(0,128,255,0.2),
    0 4px 12px rgba(0,0,0,0.12);
}

/* icona lente */
.search-icon{
  position:absolute;
  right:22px;
  top:50%;
  transform:translateY(-50%);

  width:18px;
  height:18px;

  color:var(--text-soft);
  pointer-events:none;
}
.reports-list-items{
  display:flex;
  flex-direction:column;
  //gap:8px; /* spazio tra item */
  border-top: solid 1px #ddd;
}

.report-item{
  //padding:12px;
  border-bottom:1px solid var(--border);
  cursor:pointer;
  display:flex;
  flex-direction:column;
  background: #eee;
  box-shadow: 1px 0px 10px rgba(0,0,0,0.15);
  
  
}

.report-item:hover{
  background:var(--bg-hover);
}

.report-item.active{
  background:var(--bg-soft);
}

.report-item-top,
.report-item-bottom{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:6px 12px;
  position:relative;
}

.report-item-middle{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:6px 12px;
}

.report-item-content

.report-item-middle .hidden{
  display:none;
}


.report-item-title{
  font-size:14px;
  font-weight:600;
  color:var(--text);
  min-width:0;
  flex:1;
}

.report-item-time{
  font-size:12px;
  color:var(--text-soft);
  white-space:nowrap;
}

.report-item-user{
  font-size:12px;
  color:var(--text-soft);
  min-width:0;
  flex:1;
}

.report-item-status{
  font-size:11px;
  padding:3px 8px;
  border-radius:999px;
  white-space:nowrap;
  margin-top:14px;
  margin-right:10px;
  
}

.report-item-status.is-open{
  //background:rgba(0, 128, 255, 0.12);
  background: #3a7d6f;
  color:#fff;
  //opacity:0.5;
}

.report-item-status.is-progress{
  //background:rgba(255, 166, 0, 0.14);
  background: #c27a3f;
  color:#fff;
  //opacity:0.5;
}

.report-item-preview{
  font-size:13px;
  color:var(--text-soft);
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  padding: 0px 12px 12px 12px;
}
.arrow-title{
  font-size:12px;  
  display:inline-block;
  transform:translateY(-4px);
  color:#ddd;

}

.tickets-chat{
  flex:1;
  display:flex;
  flex-direction:column;
}

.tickets-details{
  width:280px;
  border-left:1px solid var(--border);
  overflow-y:auto;
}







































.nav-icon{
  width:24px;
  height:24px;
  display:block;
}

/* ICON */
.admin-icon{
  width:40px;
  height:40px;
  border-radius:10px;
  background:rgba(255,255,255,.04);
  display:flex;
  align-items:center;
  justify-content:center;
  box-shadow: 0px 0px 6px #ddd;
}


.icon-chat{
  fill: currentColor;
  flex-shrink: 0;
  vertical-align:middle;
}


.icon-chat-enter{
  flex-shrink: 0;
}

.chat-container {
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.chat-tool-icon{
  width:22px;
  height:22px;
  display:block;
}

/* WRAPPER */
/*
.chat-wrapper{
  height: 100%;
  display: flex;
  flex-direction: column;
}*/

.chat-wrapper{
  height:100%;
  display:flex;
  flex-direction:column;
}

.chat-view{
  flex:1;
  display:flex;
  flex-direction:column;
  background:var(--bg-main);
  min-height:0;
}

.chat-main{
  flex:1;
  overflow-y:auto;
  display:flex;
  flex-direction:column;
  padding:10px 10px 10px 10px;
  
  min-height:0; 
}


.admin-list{
  padding:14px 14px 14px 14px;
  
}

/* HEADER */
/*
.chat-header{
  margin-bottom:14px;
}
*/
  .chat-header{
    display:flex;
    align-items:center;
    justify-content:space-between;
    padding:10px 16px;
    border-bottom:1px solid var(--border);
    background:var(--bg-panel);
    
    /*position:fixed;*/
    position: static; /* era fixed */
    
    /*
    top:56px;
    left:0;
    right:0;
    z-index:9;
    */
  }
  
.chat-header-left{
  display:flex;
  align-items:left;
  gap:0px;
  margin-right:10px;
}  
  
.chat-header-title{
  font-weight:600;
}

.chat-header-subtitle{
  font-size:12px;
  color:var(--muted);
}  

.chat-header-group{
  font-weight: normal;
}

.chat-header h2{
  margin:0;
  font-size:18px;
  font-weight:600;
}

.chat-header-menu-btn{
  background:none;
  border:none;
  color:var(--txt);
  //color:#e6e9ee;
  font-size:22px;
  cursor:pointer;
  padding:4px 8px;
}


.chat-sub{
  font-size:13px;
  color:var(--muted);
}

/* LIST */
.chat-list{
  display:flex;
  flex-direction:column;
  gap:12px;
}

.chat-check-icon{
  width:14px;
  height:14px;
  color:#fff;
  opacity:0.5;
}

.chat-check-icon.read{
  //color:#5aa8ff; //#2f6bff;
  //background:#fff;
  opacity:1.0;
}

.chat-check-icon-recived{
  width:14px;
  height:14px;
  color:#555;
  opacity:0.5;
}

.chat-check-icon-recived.read{
  //color:#555; //#2f6bff;
  //background:#fff;
  opacity:1.0;
}


/*---------------------------------*/

/*
.chat-view{
  height:100dvh;
  display:flex;
  flex-direction:column;
  background:var(--bg-main);
}
*/

/*

  .chat-view{
    height:100%;
    position:relative;
    display:flex;
    flex-direction:column;
    background:var(--bg-main);
    
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
  }

.chat-wrapper,
.chat-view{
  height: 100%;
  //max-height: 100%;
}
*/



.chat-back-btn{
  border:solid 1px #ddd;
  background:none;
  font-size:20px;
  color:var(--txt);
  cursor:pointer;
  //background: #eee;
  border-radius:5px 5px 5px 5px;
  margin-right:5px;
}


.chat-title{
  font-size:16px;
  margin:0;
}

.chat-subtitle{
  font-size:12px;
  color:var(--muted);
}

.chat-status{
  font-size:11px;
  padding:2px 6px;
  border-radius:6px;
  background:var(--bg-soft);
}


/*
.chat-messages{
  flex:1;
  overflow-y:auto;
  padding:12px;
  display:flex;
  flex-direction:column;
  gap:10px;
}
*/
  .chat-messages{
    flex:1;
    padding:12px;
    display:flex;
    flex-direction:column;
    gap:10px;
    overflow:visible;
  }


.chat-message{
  display:flex;
}

.chat-message.is-sent{
  justify-content:flex-end;
}

.chat-message.is-received{
  justify-content:flex-start;
}

.chat-bubble{
  max-width:75%;
  padding:10px 12px;
  border-radius:14px;
  background: var(--bg-panel); // var(--bg-soft);
  position:relative;
  box-shadow: 0px 0px 5px #ccc;
  margin-bottom: 8px;
}

.chat-message.is-sent .chat-bubble{
  //background:var(--accent);
  background:#4a8f3c; //#5fae4e;
  
  color:#fff;
}

.chat-bubble-text{
  font-size:14px;
  line-height:1.4;
  word-wrap:break-word;
}

.chat-bubble-meta{
  display:flex;
  justify-content:flex-end;
  gap:6px;
  margin-top:4px;
  font-size:11px;
  //opacity:1.0;
}

.chat-checks{
  font-size:12px;
}

/* CARD */
.admin-card{
  background:var(--bg-panel);
  border-radius:12px;
  box-shadow:0 2px 8px rgba(0,0,0,.2);
  overflow:hidden;
  margin-bottom:15px;
}

.chat-bubble.has-media{
  padding:6px;
}

.chat-media-thumb img{
  width:100%;
  border-radius:10px;
  display:block;
}

.chat-bubble-caption{
  font-size:13px;
  margin-top:6px;
}

.chat-location-card{
  display:flex;
  gap:10px;
  align-items:center;
  background:var(--bg-soft);
  border-radius:10px;
  padding:10px;
  border:none;
  cursor:pointer;
}

.chat-location-icon{
  font-size:20px;
}

.chat-location-title{
  font-size:13px;
  font-weight:600;
}

.chat-location-text{
  font-size:12px;
  color:var(--muted);
}

.chat-attachment-preview{
  padding:8px 10px;
  border-top:1px solid var(--border);
  background:var(--bg-panel);
}

.chat-preview-list{
  display:flex;
  gap:8px;
  overflow-x:auto;
}

.chat-preview-item{
  position:relative;
  width:70px;
  height:70px;
}

.chat-preview-item img{
  width:100%;
  height:100%;
  object-fit:cover;
  border-radius:8px;
}

.chat-preview-remove{
  position:absolute;
  top:-6px;
  right:-6px;
  width:20px;
  height:20px;
  border-radius:50%;
  border:none;
  background:#000;
  color:#fff;
  font-size:12px;
  cursor:pointer;
}

/*
.chat-composer-wrap{
  border-top:1px solid var(--border);
  background:var(--bg-panel);
  padding:8px;
  display:flex;
  flex-direction:column;
  gap:6px;
}
*/

  .chat-composer-wrap{
  border-top:1px solid var(--border);
  background:var(--bg-panel);
  padding:8px;

  display:flex;
  flex-direction:column;
  gap:6px;

  flex: 0 0 auto;
}

.chat-send-btn:disabled{
  opacity:0.4;
  cursor:not-allowed;
}

.chat-tools{
  display:flex;
  gap:8px;
}

.chat-tool-btn{
  border:none;
  background:var(--bg-soft);
  border-radius:10px;
  padding:6px 10px;
  font-size:16px;
  cursor:pointer;
}

.chat-composer{
  display:flex;
  align-items:flex-end;
  gap:8px;
}

.chat-input-box{
  flex:1;
  background:var(--bg-soft);
  border-radius:14px;
  padding:6px 10px;
  max-height:140px;
  overflow-y:auto;
}

.chat-message-input{
  width:100%;
  border:none;
  outline:none;
  resize:none;
  background:transparent;
  color:var(--txt);
  font-size:15px;
  line-height:1.4;
  min-height:32px;
}

.chat-send-btn{
  width:44px;
  height:44px;
  border-radius:50%;
  border:none;
  background:#3f7de8; //var(--accent);
  color:#fff;
  font-size:18px;
  cursor:pointer;
  flex-shrink:0;
}

.chat-send-btn:active{
  transform:scale(.95);
}

.chat-day-separator{
  text-align:center;
  font-size:12px;
  color:var(--muted);
  margin:10px 0;
}


.chat-messages{
  scroll-behavior:smooth;
}







#mainContent{
  height:100vh;
  overflow:hidden; /* 🔴 questo è il punto chiave */
  display:flex;
  flex-direction:column;
}

.open-reports-container-class{
  flex:1;
  display:flex;
  flex-direction:column;
  overflow:hidden;
}



.tickets-container{
  flex:1;
  display:flex;
  overflow:hidden;
}

.tickets-list{
  width:300px;
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

/* unico punto scroll */
#reports-list-items{
  flex:1;
  overflow-y:auto;
}

.tickets-chat{
  flex:1;
  overflow:hidden;
}

.tickets-details{
  width:300px;
  overflow:hidden;
}

.module-title{
  padding:12px 12px 12px 12px;
  border-bottom:solid 1px #ddd;
}

#devWsPanel {
  position: fixed;
  bottom: 0;
  right: 0;
  width: 300px;
  height: 300px;
  background: #111;
  color: #0f0;
  z-index: 9999;
  display: none;
}

/*------------------------------*/
.chat-message-badge {
  position: absolute;
  top: 0px;
  right: 4px;

  width: 32px;
  height: 32px;
  
  display: none;
  
}

.chat-message-badge.has-unread{
  display: block;
}

/* svg sfondo */
.chat-message-badge .icon-chat {
  width: 100%;
  height: 100%;
  fill:#cc4a4a;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

/* numero sopra */
.badge-count {
  position: absolute;
  top: 46%;
  left: 50%;
  transform: translate(-50%, -55%);

  font-size: 10px;
  font-weight: 700;
  color: #fff;
}


