/* =========================================
   MOBILE-FRIENDLY THEME CSS
   Versione responsive ottimizzata
   ========================================= */

/* ===========================================
   BASE STYLES
   =========================================== */
html {
  font-size: 100%;
  overflow-y: scroll;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  box-sizing: border-box;
}

*, *:before, *:after {
  box-sizing: inherit;
}

body {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  padding: 0;
  min-width: 320px;
}

body,
input,
select,
textarea {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif;
  color: #000;
}

b, strong {
  font-weight: bold;
}

blockquote {
  margin: 1em 20px;
}

hr {
  display: block;
  height: 1px;
  border: 0;
  border-top: 1px solid #ccc;
  margin: 1em 0;
  padding: 0;
}

small {
  font-size: 85%;
}

ul, ol {
  margin: 1em 0;
  padding: 0 0 0 30px;
}

img {
  border: 0;
  vertical-align: middle;
  max-width: 100%;
  height: auto;
}

form {
  margin: 0;
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

label {
  cursor: pointer;
}

input,
select,
textarea {
  font-size: 16px; /* Previene zoom su iOS */
  margin: 0;
  max-width: 100%;
}

input {
  line-height: normal;
}

input[type="button"],
input[type="reset"],
input[type="submit"] {
  cursor: pointer;
  -webkit-appearance: button;
  min-height: 44px; /* Touch-friendly */
}

input[type="checkbox"],
input[type="radio"] {
  box-sizing: border-box;
  min-width: 20px;
  min-height: 20px;
}

textarea {
  overflow: auto;
  vertical-align: top;
  resize: vertical;
  width: 100%;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
  width: 100%;
  overflow-x: auto;
  display: block;
}

@media (min-width: 768px) {
  table {
    display: table;
  }
}

th, td {
  vertical-align: top;
  padding: 8px;
}

th {
  text-align: left;
  font-weight: normal;
}

h1, h2, h3, h4, h5, h6,
form, fieldset {
  margin: 0;
  padding: 0;
}

/* ===========================================
   TYPOGRAPHY
   =========================================== */
a, .link {
  color: #0072bc;
  text-decoration: none;
  display: inline;
  margin-bottom: 1px;
  min-height: 44px;
  display: inline-block;
  padding: 4px 0;
}

a:hover, .link:hover {
  border-bottom: 1px dotted #0072bc;
  margin-bottom: 0;
  cursor: pointer;
}

h1 {
  color: #00AEEF;
  font-weight: normal;
  font-size: clamp(18px, 5vw, 20px);
  margin-bottom: 10px;
}

h2, .subject {
  font-size: clamp(16px, 4vw, 18px);
  color: black;
  margin-bottom: 8px;
}

h3 {
  font-size: clamp(14px, 3.5vw, 16px);
}

/* ===========================================
   HELPERS
   =========================================== */
.centered {
  text-align: center;
}

.clear {
  clear: both;
  height: 1px;
  visibility: none;
}

.hidden {
  display: none;
}

.faded {
  color: #666;
}

/* ===========================================
   PAGINATION
   =========================================== */
#pagination {
  border: 0;
  margin: 0 0 20px 0;
  padding: 10px 0;
  overflow-x: auto;
  white-space: nowrap;
}

#pagination li {
  border: 0;
  margin: 0;
  padding: 0;
  font-size: 14px;
  list-style: none;
  display: inline-block;
}

#pagination li a {
  margin: 2px;
  display: inline-block;
  padding: 8px 12px;
  text-decoration: none;
  min-height: 44px;
  min-width: 44px;
  text-align: center;
  border: 1px solid #ddd;
  border-radius: 4px;
}

#pagination li a:hover,
#pagination .active {
  color: #ff0084;
  background-color: #f5f5f5;
}

#pagination .previousOff,
#pagination .nextOff {
  color: #666;
  display: inline-block;
  font-weight: bold;
  padding: 8px 12px;
}

/* ===========================================
   ALERTS & NOTICES
   =========================================== */
#msg_notice,
#msg_warning,
#msg_error,
#msg_info {
  margin: 0 0 10px 0;
  padding: 12px 15px;
  border-radius: 4px;
  line-height: 1.5;
  word-wrap: break-word;
}

#msg_notice {
  border: 1px solid #0a0;
  background-color: #e0ffe0;
  color: #0a0;
}

#msg_warning, .warning-banner {
  border: 1px solid #f26522;
  background-color: #ffffdd;
  color: #f26522;
}

#msg_error {
  border: 1px solid #a00;
  background-color: #fff0f0;
  color: #a00;
}

#msg_info {
  color: #3a87ad;
  border: 1px solid #bce8f1;
  background-color: #d9edf7;
}

.error {
  color: #f00;
}

.error input {
  border: 1px solid #f00;
}

/* ===========================================
   BUTTONS
   =========================================== */
.button,
.button:visited {
  background: #222;
  border: none;
  display: inline-block;
  font-size: 16px;
  padding: 12px 20px;
  width: auto;
  max-width: 100%;
  min-height: 44px;
  text-align: center;
  color: #fff;
  text-decoration: none;
  border-radius: 5px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  text-shadow: 0 -1px 1px rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid rgba(0, 0, 0, 0.25);
  position: relative;
  cursor: pointer;
  font-family: helvetica, arial, sans-serif;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.button:hover {
  background-color: #111;
  color: #fff;
}

.button:active {
  top: 1px;
  box-shadow: none;
}

.green.button,
.green.button:visited {
  background-color: #91bd09;
}

.green.button:hover {
  background-color: #749a02;
}

.blue.button,
.blue.button:visited {
  background-color: #00AEEF;
}

.blue.button:hover {
  background-color: #0299d2;
}

/* ===========================================
   LAYOUT
   =========================================== */
body {
  background: #c8c8c8;
}

#container {
  background: #fff;
  width: 100%;
  max-width: 840px;
  margin: 0 auto;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.5);
}

@media (min-width: 768px) {
  #container {
    width: 90%;
  }
}

/* ===========================================
   HEADER
   =========================================== */
#header {
  position: relative;
  min-height: 60px;
  padding: 10px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

#logo {
  height: auto;
  flex: 1 1 auto;
  min-width: 0;
}

#header #logo img {
  max-height: 50px;
  max-width: 100%;
  width: auto;
  height: auto;
  vertical-align: middle;
}

.valign-helper {
  height: 100%;
  display: inline-block;
  vertical-align: middle;
}

#header p {
  width: 100%;
  margin: 10px 0 0 0;
  padding: 0;
  font-size: 14px;
}

@media (min-width: 768px) {
  #header {
    padding: 0 20px;
    min-height: 71px;
  }
  
  #header #logo img {
    max-height: 65px;
    max-width: 380px;
  }
  
  #header p {
    width: auto;
    margin: 0;
    padding: 10px 0 0;
  }
}

/* ===========================================
   NAVIGATION
   =========================================== */
#nav {
  margin: 0;
  padding: 0;
  background: #f5f5f5;
  border-top: 1px solid #aaa;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

#nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: nowrap;
}

#nav li {
  margin: 0;
  padding: 0;
  list-style: none;
  flex: 0 0 auto;
}

#nav li a {
  display: block;
  width: auto;
  min-height: 44px;
  line-height: 44px;
  text-align: center;
  padding: 0 15px;
  color: #333;
  white-space: nowrap;
  border-radius: 0;
  transition: background-color 0.2s;
}

#nav li a.active,
#nav li a:hover {
  background-color: #dbefff;
  color: #000;
}

@media (min-width: 768px) {
  #nav {
    margin: 0 20px;
    padding: 2px 10px;
    height: auto;
    background: url('../images/nav_bg.png') top left repeat-x;
    box-shadow: 0 3px 2px rgba(0, 0, 0, 0.4);
    white-space: nowrap;
  }
  
  #nav ul {
    flex-wrap: wrap;
  }
  
  #nav li a {
    display: inline-block;
    height: 20px;
    line-height: 20px;
    min-height: auto;
    padding: 0 10px 0 32px;
    margin-left: 10px;
    border-radius: 20px;
    background-position: 10px 50%;
    background-repeat: no-repeat;
  }
  
  #nav li a.home {
    background-image: url('../images/icons/home.png');
  }
  
  #nav li a.kb {
    background-image: url('../images/icons/kb.png');
  }
  
  #nav li a.new {
    background-image: url('../images/icons/new.png');
  }
  
  #nav li a.status {
    background-image: url('../images/icons/status.png');
  }
  
  #nav li a.tickets {
    background-image: url('../images/icons/tix.png');
  }
}

.rtl #nav li a {
  background-position: right center;
  background-position: calc(100% - 10px) center;
  padding-left: 10px;
  padding-right: 32px;
  margin-right: 10px;
  margin-left: 0;
}

/* ===========================================
   CONTENT
   =========================================== */
#content {
  padding: 15px;
  margin: 0;
  min-height: 300px;
}

@media (min-width: 768px) {
  #content {
    padding: 20px;
    margin: 0 20px;
    min-height: 350px;
  }
}

/* ===========================================
   FOOTER
   =========================================== */
#footer {
  text-align: center;
  font-size: 12px;
  color: #333;
  padding: 15px;
}

#footer a {
  color: #333;
}

#footer p {
  margin: 10px 0 0 0;
}

#footer #poweredBy {
  display: block;
  width: 126px;
  height: 23px;
  outline: none;
  text-indent: -9999px;
  margin: 0 auto;
  background: url('../images/poweredby.png') top left no-repeat;
  background-size: auto 20px;
}

/* ===========================================
   LANDING PAGE
   =========================================== */
.main-content {
  width: 100%;
}

@media (min-width: 768px) {
  .main-content {
    width: 565px;
  }
}

#landing_page #new_ticket,
#landing_page #check_status {
  width: 100%;
  padding: 15px;
  margin-top: 20px;
  background-position: center top;
  background-repeat: no-repeat;
  padding-top: 80px;
}

@media (min-width: 768px) {
  #landing_page #new_ticket,
  #landing_page #check_status {
    width: 295px;
    padding-left: 75px;
    padding-top: 15px;
    margin-top: 40px;
    background-position: top left;
  }
  
  #landing_page #new_ticket {
    background-image: url('../images/new_ticket_icon.png');
  }
  
  #landing_page #check_status {
    background-image: url('../images/check_status_icon.png');
  }
}

#landing_page h1,
#landing_page h2,
#landing_page h3 {
  margin-bottom: 10px;
}

/* ===========================================
   FORMS
   =========================================== */
#ticketForm div.clear,
#clientLogin div.clear {
  clear: both;
  padding: 10px 0;
  overflow: visible;
}

#ticketForm div label,
#clientLogin div label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
}

label.required,
span.required {
  font-weight: bold;
}

#ticketForm div input,
#clientLogin div input,
#ticketForm div textarea,
#clientLogin div textarea {
  width: 100%;
  border: 1px solid #aaa;
  background: #fff;
  display: block;
  padding: 10px;
  border-radius: 4px;
  font-size: 16px;
}

#ticketForm div input[type=file],
#clientLogin div input[type=file] {
  border: 0;
  padding: 10px 0;
}

#ticketForm div select,
#clientLogin div select {
  display: block;
  width: 100%;
  padding: 10px;
  border: 1px solid #aaa;
  border-radius: 4px;
  font-size: 16px;
  background-color: #fff;
}

#ticketForm td textarea,
#clientLogin td textarea,
#ticketForm div textarea,
#clientLogin div textarea {
  width: 100%;
  min-height: 120px;
}

#ticketForm td em,
#clientLogin td em,
#ticketForm div em,
#clientLogin div em {
  color: #777;
  font-size: 14px;
  display: block;
  margin-top: 5px;
}

#ticketForm > table {
  table-layout: auto;
  display: block;
  overflow-x: auto;
}

#ticketForm > table td {
  display: block;
  width: 100%;
  padding: 10px 0;
}

@media (min-width: 768px) {
  #ticketForm > table {
    table-layout: fixed;
    display: table;
  }
  
  #ticketForm > table td {
    display: table-cell;
    width: 160px;
  }
  
  #ticketForm > table td + td {
    width: auto;
  }
  
  #ticketForm td textarea,
  #clientLogin td textarea,
  #ticketForm div textarea,
  #clientLogin div textarea {
    width: 600px;
  }
}

#ticketForm div.error input,
#clientLogin div.error input {
  border: 1px solid #a00;
}

#ticketForm div.error label,
#clientLogin div.error label {
  color: #a00;
}

/* ===========================================
   CLIENT LOGIN
   =========================================== */
#clientLogin {
  display: block;
  margin-top: 20px;
  padding: 20px;
  border: 1px solid #ccc;
  border-radius: 5px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
  background-color: #f6f6f6;
}

#clientLogin .instructions {
  display: block;
  padding: 0 0 15px 0;
}

#clientLogin p {
  clear: both;
}

#clientLogin strong {
  font-size: 14px;
  color: #d00;
  display: block;
  margin-bottom: 5px;
}

#clientLogin input[type=text],
#clientLogin input[type=password] {
  padding: 12px;
  border-radius: 4px;
  margin-bottom: 15px;
}

#clientLogin input[type=submit] {
  padding: 12px 20px;
  border-radius: 4px;
  width: 100%;
}

@media (min-width: 768px) {
  #clientLogin {
    background: url('../images/lock.png?1319655200') 95% 50% no-repeat #f6f6f6;
  }
  
  #clientLogin .instructions {
    display: table-cell;
    padding-left: 2em;
    padding-right: 90px;
  }
  
  #clientLogin input[type=submit] {
    width: auto;
  }
}

.rtl #clientLogin {
  background-position: 5% 50%;
}

.rtl #clientLogin .instructions {
  padding-left: 90px;
  padding-right: 2em;
}

/* ===========================================
   TABLES
   =========================================== */
#ticketTable {
  border: 1px solid #aaa;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

#ticketTable caption {
  padding: 10px;
  text-align: left;
  color: #000;
  background: #ddd;
  border: 1px solid #aaa;
  border-bottom: none;
  font-weight: bold;
}

#ticketTable th {
  min-height: 44px;
  line-height: 1.5;
  background: #e1f2ff;
  border: 1px solid #aaa;
  padding: 8px;
  white-space: nowrap;
}

#ticketTable th a {
  color: #000;
}

#ticketTable td {
  padding: 8px;
  border: 1px solid #aaa;
}

#ticketTable tr.alt td {
  background: #f9f9f9;
}

@media (min-width: 768px) {
  #ticketTable {
    display: table;
  }
}

.infoTable {
  background: #F4FAFF;
  overflow-x: auto;
  display: block;
}

.infoTable th {
  text-align: left;
  padding: 8px;
}

@media (min-width: 768px) {
  .infoTable {
    display: table;
  }
}

/* ===========================================
   RESPONSIVE UTILITIES
   =========================================== */
.row {
  display: flex;
  flex-wrap: wrap;
  margin: 0 -10px;
}

.span4,
.span8 {
  width: 100%;
  padding: 0 10px;
  margin-bottom: 20px;
}

@media (min-width: 768px) {
  .span4 {
    width: 33.333%;
  }
  
  .span8 {
    width: 66.666%;
  }
}

.sidebar {
  margin-bottom: 20px;
  margin-left: 0;
  width: 100%;
}

@media (min-width: 768px) {
  .sidebar {
    margin-left: 20px;
    width: 215px;
  }
}

.rtl .sidebar {
  margin-left: 0;
  margin-right: 0;
}

@media (min-width: 768px) {
  .rtl .sidebar {
    margin-right: 20px;
  }
}

.sidebar .content {
  padding: 10px;
  border: 1px solid #C8DDFA;
  background: #F7FBFE;
}

.sidebar .content:empty {
  display: none;
}

.sidebar section .header {
  font-weight: bold;
  margin-bottom: 0.3em;
}

.sidebar section + section {
  margin-top: 15px;
}

/* ===========================================
   SEARCH
   =========================================== */
.search-form {
  padding-top: 12px;
}

.searchbar .search,
.search-form .search {
  display: inline-block;
  width: 100%;
  border-radius: 5px;
  border: 1px solid #ccc;
  padding: 12px;
  box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
  font-size: 16px;
}

@media (min-width: 768px) {
  .search-form .search {
    width: 400px;
  }
}

.searchbar .search {
  margin-bottom: 10px;
}

/* ===========================================
   TICKET THREAD
   =========================================== */
.thread-entry {
  margin-bottom: 15px;
}

.thread-entry.avatar {
  margin-left: 0;
  margin-right: 0;
}

@media (min-width: 768px) {
  .thread-entry.avatar {
    margin-left: 60px;
  }
  
  .thread-entry.response.avatar {
    margin-right: 60px;
    margin-left: 0;
  }
}

.thread-entry > .avatar {
  display: none;
}

@media (min-width: 768px) {
  .thread-entry > .avatar {
    margin-left: -60px;
    display: inline-block;
    width: 48px;
    height: auto;
    border-radius: 5px;
  }
  
  .thread-entry.response > .avatar {
    margin-left: initial;
    margin-right: -60px;
  }
}

img.avatar {
  border-radius: inherit;
}

.avatar > img.avatar {
  width: 100%;
  height: auto;
}

.thread-entry .header {
  padding: 12px;
  border: 1px solid #ccc;
  border-color: rgba(0,0,0,0.2);
  border-radius: 5px 5px 0 0;
  word-wrap: break-word;
}

.thread-entry .header .title {
  max-width: 100%;
  vertical-align: bottom;
  display: inline-block;
  margin-left: 0;
}

@media (min-width: 768px) {
  .thread-entry .header .title {
    max-width: 500px;
    margin-left: 15px;
  }
}

.thread-entry.response .header {
  background: #dddddd;
}

.thread-entry.message .header {
  background: #C3D9FF;
}

.thread-entry .thread-body {
  border: 1px solid #ddd;
  border-top: none;
  border-bottom: 2px solid #aaa;
  border-radius: 0 0 5px 5px;
  padding: 12px;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.thread-body .attachments {
  background-color: #f4faff;
  margin: 12px -12px -12px;
  padding: 12px;
  border-top: 1px dotted #ccc;
  border-top-color: rgba(0,0,0,0.2);
  border-radius: 0 0 6px 6px;
}

.thread-body .attachments .filesize {
  margin-left: 0.5em;
}

.thread-body .attachments a,
.thread-body .attachments a:hover {
  text-decoration: none;
}

.thread-body .attachment-info {
  margin-right: 10px;
  display: block;
  width: 100%;
  margin-bottom: 10px;
}

@media (min-width: 768px) {
  .thread-body .attachment-info {
    display: inline-block;
    width: 48%;
  }
}

.thread-body .attachment-info .filename {
  max-width: 100%;
  word-wrap: break-word;
}

/* ===========================================
   LABELS & BADGES
   =========================================== */
.label {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 3px;
  font-weight: bold;
  line-height: 1.5;
  color: #ffffff;
  vertical-align: baseline;
  white-space: nowrap;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
  background-color: #999999;
  display: inline-block;
}

.label-bare {
  background-color: transparent;
  border: 1px solid #999999;
  color: #999999;
  text-shadow: none;
}

/* ===========================================
   ACTION BUTTONS
   =========================================== */
.action-button {
  border-radius: 3px;
  color: #777 !important;
  display: inline-block;
  border: 1px solid #aaa;
  cursor: pointer;
  font-size: 14px;
  overflow: hidden;
  background-color: #dddddd;
  background-image: linear-gradient(top, #efefef 0%, #dddddd 100%);
  padding: 8px 12px;
  text-decoration: none;
  line-height: 1.5;
  margin: 5px;
  min-height: 44px;
  touch-action: manipulation;
}

.action-button span,
.action-button a {
  color: #777 !important;
  display: inline-block;
}

.action-button a {
  color: #777;
  text-decoration: none;
}

/* ===========================================
   MOBILE-SPECIFIC IMPROVEMENTS
   =========================================== */
@media (max-width: 767px) {
  /* Nasconde elementi non essenziali su mobile */
  .desktop-only {
    display: none !important;
  }
  
  /* Migliora la leggibilità */
  body {
    font-size: 15px;
  }
  
  /* Stack layout verticale */
  .login-box {
    width: 100%;
    display: block;
    box-shadow: none;
    padding: 15px;
  }
  
  /* Migliora touch targets */
  a, button, input[type="submit"], .button {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Testo più grande per meglio leggibilità */
  input, select, textarea {
    font-size: 16px !important;
  }
}

/* ===========================================
   PRINT STYLES
   =========================================== */
@media print {
  #header, #nav, #meta, #footer, #reply,
  #pagination, .reload, .refresh,
  .redactor-toolbar, .filedrop .dropzone,
  .back, #loading, .buttons {
    display: none !important;
  }
  
  body {
    background: white;
  }
  
  #container {
    box-shadow: none;
    width: 100%;
  }
  
  a {
    color: #000;
    text-decoration: none;
  }
  
  .thread-entry .header {
    border: 1px solid #000;
  }
}

/* ===========================================
   ACCESSIBILITY
   =========================================== */
:focus-visible {
  outline: 2px solid #00AEEF;
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ===========================================
   PERFORMANCE
   =========================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
