/* ============================================================
   CRM Farmacia della Corte - TEMA COMUNE (ottobre 2026)
   Caricato da inclusioni/meta.php su tutte le pagine, attivo con <body class="tm">.
   Modernizza l'aspetto delle pagine esistenti (Bootstrap 3) senza cambiarne il
   funzionamento: menu, pulsanti, moduli, tabelle DataTables, avvisi, piè di pagina.
   Le pagine rinnovate a mano (es. Pazienti, .pg-mod) usano in piu' moderno-crm.css.
   ============================================================ */

body.tm {
  --t-bg: #f4f5fa;
  --t-card: #ffffff;
  --t-border: #e3e6f0;
  --t-text: #1f2333;
  --t-muted: #6b7088;
  --t-primary: #5b5bd6;
  --t-primary-dark: #4545b8;
  --t-primary-soft: #eef0ff;
  --t-radius: 12px;
  --t-shadow: 0 1px 2px rgba(20, 24, 60, .06), 0 4px 14px rgba(20, 24, 60, .05);
  background: var(--t-bg);
  color: var(--t-text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  padding-top: 76px;              /* spazio per il menu fisso */
  -webkit-font-smoothing: antialiased;
}
body.tm .container { width: auto; max-width: 1440px; padding-left: 20px; padding-right: 20px; }
body.tm h1, body.tm h2, body.tm h3, body.tm h4 { font-weight: 650; letter-spacing: -.01em; color: var(--t-text); }
body.tm a { color: var(--t-primary-dark); }
body.tm a:hover { color: var(--t-primary); }

/* ----------- MENU ----------- */
body.tm .tm-nav {
  background: #fff; border: 0; border-bottom: 1px solid var(--t-border);
  box-shadow: 0 1px 8px rgba(20, 24, 60, .05); min-height: 60px; margin: 0;
}
body.tm .tm-nav .navbar-brand { height: 60px; padding: 10px 15px; display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--t-text); }
body.tm .tm-nav .navbar-brand img { max-height: 38px; }
body.tm .tm-nav .tm-brand-text { font-size: 16px; line-height: 1.1; }
body.tm .tm-nav .tm-brand-text small { display: block; font-size: 11px; font-weight: 500; color: var(--t-muted); }
body.tm .tm-nav .navbar-nav > li > a {
  color: var(--t-muted); font-weight: 600; padding: 9px 13px; margin: 11px 2px; border-radius: 8px;
  transition: background .15s, color .15s;
}
body.tm .tm-nav .navbar-nav > li > a .fa { margin-right: 4px; opacity: .85; }
body.tm .tm-nav .navbar-nav > li > a:hover,
body.tm .tm-nav .navbar-nav > li > a:focus { background: var(--t-bg); color: var(--t-text); }
body.tm .tm-nav .navbar-nav > .active > a,
body.tm .tm-nav .navbar-nav > .active > a:hover,
body.tm .tm-nav .navbar-nav > .open > a,
body.tm .tm-nav .navbar-nav > .open > a:hover { background: var(--t-primary-soft); color: var(--t-primary-dark); }
body.tm .tm-nav .dropdown-menu { border: 1px solid var(--t-border); border-radius: 10px; box-shadow: var(--t-shadow); padding: 6px; min-width: 210px; }
body.tm .tm-nav .dropdown-menu > li > a { border-radius: 6px; padding: 8px 12px; font-weight: 500; color: var(--t-text); }
body.tm .tm-nav .dropdown-menu > li > a .fa { width: 18px; color: var(--t-muted); }
body.tm .tm-nav .dropdown-menu > li > a:hover,
body.tm .tm-nav .dropdown-menu > .active > a { background: var(--t-primary-soft); color: var(--t-primary-dark); }
body.tm .tm-nav .tm-user > a { color: var(--t-text) !important; }
body.tm .tm-avatar {
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--t-primary); color: #fff; font-size: 12px; font-weight: 700; margin-right: 6px; vertical-align: middle;
}
body.tm .tm-nav .navbar-toggle { border: 1px solid var(--t-border); border-radius: 8px; margin-top: 13px; padding: 8px 10px; }
body.tm .tm-nav .navbar-toggle .icon-bar { background: var(--t-text); }
body.tm .submenu { display: none; }                   /* "Sei loggato come" ora e' nel menu utente */

/* ----------- CARD / JUMBOTRON (pagine esistenti) ----------- */
body.tm .jumbotron, body.tm .tm-card, body.tm .panel {
  background: var(--t-card); border: 1px solid var(--t-border); border-radius: var(--t-radius);
  box-shadow: var(--t-shadow); padding: 24px; margin-bottom: 20px; color: var(--t-text);
}
body.tm .jumbotron { padding: 28px 28px; }
body.tm .jumbotron h1 { font-size: 28px; margin-top: 0; }
body.tm .jumbotron p { font-size: 15px; }
body.tm .jumbotron .jumbotron { box-shadow: none; border: 0; padding: 0; margin: 0; }   /* jumbotron annidati */
body.tm .panel-heading { background: none; border-bottom: 1px solid var(--t-border); padding: 0 0 12px; margin-bottom: 12px; font-weight: 650; }

/* ----------- PULSANTI ----------- */
/* NB 17/10/2026: esclusi anche i pulsanti-scorciatoia (.m-chip, .m-seg, .tm-chip): questa regola e' molto
   specifica e sovrascriveva il loro colore di "attivo" (la scorciatoia scelta restava bianca). */
body.tm .btn, body.tm .container button:not(.navbar-toggle):not(.close):not(.fstToggleBtn):not(.m-btn):not(.pp-btn):not(.ce-del):not(.m-chip):not(.m-seg):not(.tm-chip),
body.tm .container input[type=submit], body.tm .container input[type=button] {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--t-border);
  background: #fff; color: var(--t-text); font-weight: 600; box-shadow: none; cursor: pointer;
  transition: background .15s, border-color .15s; white-space: normal;
}
body.tm .btn:hover, body.tm .container button:not(.navbar-toggle):not(.close):not(.m-chip):not(.m-seg):not(.tm-chip):not(.m-btn):hover { background: var(--t-bg); }
body.tm .btn-primary, body.tm .container button[type=submit]:not(.m-btn):not(.pp-btn), body.tm .container input[type=submit] {
  background: var(--t-primary); border-color: var(--t-primary); color: #fff;
}
body.tm .btn-primary:hover, body.tm .container button[type=submit]:not(.m-btn):not(.pp-btn):hover, body.tm .container input[type=submit]:hover {
  background: var(--t-primary-dark); border-color: var(--t-primary-dark); color: #fff;
}
body.tm .btn-success { background: #1f9d6b; border-color: #1f9d6b; color: #fff; }
body.tm .btn-danger  { background: #fff; border-color: #f2c4bf; color: #c0392b; }
body.tm .btn-danger:hover { background: #fdecea; }
body.tm .btn-lg { min-height: 46px; font-size: 16px; padding: 0 24px; }

/* ----------- MODULI ----------- */
body.tm .form-control, body.tm .container select, body.tm .container input[type=text],
body.tm .container input[type=password], body.tm .container input[type=email], body.tm .container input[type=number],
body.tm .container input[type=date], body.tm .container textarea {
  border: 1px solid var(--t-border); border-radius: 8px; box-shadow: none; min-height: 38px; padding: 6px 12px;
  background: #fff; color: var(--t-text); font-size: 14px;
}
body.tm .container textarea { min-height: 80px; }
body.tm .form-control:focus, body.tm .container input:focus, body.tm .container select:focus, body.tm .container textarea:focus {
  border-color: var(--t-primary); box-shadow: 0 0 0 3px var(--t-primary-soft); outline: 0;
}
body.tm label, body.tm .control-label { font-weight: 600; color: var(--t-text); }
body.tm .form-group { margin-bottom: 14px; }

/* ----------- TABELLE (DataTables e tabelle semplici) ----------- */
body.tm .table { background: #fff; border-radius: var(--t-radius); overflow: hidden; font-variant-numeric: tabular-nums; }
body.tm .table > thead > tr > th {
  background: #fafbfd; color: var(--t-muted); font-size: 12px; font-weight: 650; text-transform: uppercase;
  letter-spacing: .03em; border-bottom: 1px solid var(--t-border) !important; border-top: 0 !important; padding: 10px 10px;
}
body.tm .table > tbody > tr > td { padding: 9px 10px; border-top: 1px solid #f0f1f6; vertical-align: middle; }
body.tm .table > tbody > tr:hover > td { background: var(--t-primary-soft); }
body.tm .table > tfoot > tr > th, body.tm .table > tfoot > tr > td { background: #fafbfd; color: var(--t-muted); font-size: 12px; text-transform: uppercase; }
body.tm .dataTables_wrapper { background: #fff; border: 1px solid var(--t-border); border-radius: var(--t-radius); box-shadow: var(--t-shadow); padding: 4px 0 8px; margin-bottom: 20px; position: relative; overflow-x: auto; }
body.tm .pg-mod .dataTables_wrapper, body.tm .pg-prod .dataTables_wrapper { border: 0; box-shadow: none; padding: 0; margin: 0; }   /* gia' dentro una card */
body.tm .dataTables_wrapper .table { border-radius: 0; margin: 0 !important; }
body.tm .dataTables_info { color: var(--t-muted); padding: 10px 14px !important; }
body.tm .dataTables_paginate { padding: 6px 14px !important; }
body.tm .pagination { margin: 0; }
body.tm .pagination > li > a, body.tm .pagination > li > span { border-radius: 6px !important; margin: 0 2px; border-color: var(--t-border); color: var(--t-text); }
body.tm .pagination > .active > a, body.tm .pagination > .active > a:hover { background: var(--t-primary); border-color: var(--t-primary); color: #fff; }
body.tm .dataTables_length, body.tm .dataTables_filter { padding: 8px 14px; color: var(--t-muted); }
body.tm .dataTables_filter input, body.tm .dataTables_length select { border-radius: 8px; border: 1px solid var(--t-border); }
/* caricamento: barra sottile animata al posto del riquadro "Processing..." */
body.tm .dataTables_processing {
  position: absolute; top: 0 !important; left: 0 !important; right: 0; width: 100% !important; height: 3px !important;
  margin: 0 !important; padding: 0 !important; border: 0 !important; font-size: 0; box-shadow: none !important;
  background: linear-gradient(90deg, transparent, var(--t-primary), transparent) !important; background-size: 50% 100% !important;
  animation: tm-bar 1s linear infinite;
}
@keyframes tm-bar { from { background-position: -50% 0; } to { background-position: 150% 0; } }

/* ----------- SCORCIATOIE DI PERIODO (js/periodo.js, pagine non ancora rinnovate) ----------- */
body.tm .tm-presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
body.tm .container .tm-chip {
  min-height: 0 !important; height: auto; padding: 3px 11px !important; border-radius: 14px !important;
  border: 1px solid var(--t-border) !important; background: #fff !important; color: var(--t-muted) !important;
  font-size: 12px; font-weight: 600; cursor: pointer; transition: all .15s;
}
body.tm .container .tm-chip:hover { border-color: var(--t-primary) !important; color: var(--t-primary-dark) !important; }
body.tm .container .tm-chip.active { background: var(--t-primary) !important; border-color: var(--t-primary) !important; color: #fff !important; }

/* ----------- AVVISI ----------- */
body.tm .alert, body.tm .alert-success, body.tm .alert-danger, body.tm .alert-info, body.tm .alert-warning {
  border-radius: 10px; border: 1px solid transparent; padding: 12px 16px; font-size: 14px; font-weight: 500;
}
body.tm h2.alert { font-size: 15px; }
body.tm .alert-success { background: #e8f6ef; border-color: #bfe5d1; color: #17704c; }
body.tm .alert-danger  { background: #fdecea; border-color: #f5c6c0; color: #a12d22; }
body.tm .alert-info    { background: #eef4ff; border-color: #cddcfb; color: #2950a3; }
body.tm .alert-warning { background: #fff7e6; border-color: #fbe0a8; color: #8a5a00; }

/* ----------- PIE' DI PAGINA ----------- */
body.tm footer, body.tm .footer { background: transparent !important; color: var(--t-muted) !important; border-top: 1px solid var(--t-border); margin-top: 24px; }
body.tm footer a, body.tm .footer a { color: var(--t-muted) !important; }

/* ----------- LOGIN ----------- */
body.tm.tm-login { padding-top: 0; min-height: 100vh; background: radial-gradient(1200px 600px at 10% -10%, #e7e9ff 0, transparent 60%), radial-gradient(900px 500px at 110% 110%, #e6f5ee 0, transparent 60%), var(--t-bg); }
body.tm.tm-login .tm-nav, body.tm.tm-login footer, body.tm.tm-login .footer { display: none; }
.tm-login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.tm-login-card { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--t-border); border-radius: 16px; box-shadow: 0 10px 40px rgba(20, 24, 60, .10); padding: 32px 28px; }
.tm-login-logo { text-align: center; margin-bottom: 18px; }
.tm-login-logo img { max-height: 54px; }
.tm-login-logo .tm-login-mark { display: inline-flex; width: 52px; height: 52px; border-radius: 14px; background: var(--t-primary); color: #fff; align-items: center; justify-content: center; font-size: 24px; }
.tm-login-card h1 { font-size: 22px; text-align: center; margin: 0 0 4px; }
.tm-login-card .tm-login-sub { text-align: center; color: var(--t-muted); margin-bottom: 22px; }
.tm-login-card .form-group { margin-bottom: 16px; }
.tm-login-card label { display: block; font-size: 13px; margin-bottom: 6px; }
.tm-login-card .tm-input { position: relative; }
.tm-login-card .tm-input .fa { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--t-muted); }
.tm-login-card .tm-input input { width: 100%; height: 44px; padding: 8px 40px 8px 38px; border: 1px solid var(--t-border); border-radius: 10px; font-size: 15px; }
.tm-login-card .tm-input input:focus { border-color: var(--t-primary); box-shadow: 0 0 0 3px var(--t-primary-soft); outline: 0; }
.tm-login-card .tm-eye { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0 !important; background: none !important; color: var(--t-muted) !important; min-height: 0 !important; padding: 6px !important; cursor: pointer; }
.tm-login-card .tm-submit { width: 100%; height: 46px; border: 0; border-radius: 10px; background: var(--t-primary); color: #fff; font-weight: 700; font-size: 15px; cursor: pointer; margin-top: 6px; }
.tm-login-card .tm-submit:hover { background: var(--t-primary-dark); }
.tm-login-card .alert { margin-bottom: 16px; }
.tm-login-foot { text-align: center; color: var(--t-muted); font-size: 12px; margin-top: 18px; }

/* ----------- HOME ----------- */
.tm-home-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 8px 0 18px; }
.tm-home-head h1 { font-size: 26px; margin: 0; }
.tm-home-head p { color: var(--t-muted); margin: 4px 0 0; }
.tm-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-bottom: 24px; }
.tm-tile {
  display: flex; flex-direction: column; gap: 6px; padding: 18px; background: #fff; border: 1px solid var(--t-border);
  border-radius: var(--t-radius); box-shadow: var(--t-shadow); color: var(--t-text) !important; text-decoration: none !important;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.tm-tile:hover { transform: translateY(-2px); border-color: #cfd3fb; box-shadow: 0 8px 24px rgba(20, 24, 60, .08); }
.tm-tile .tm-ico { width: 40px; height: 40px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; font-size: 18px; color: #fff; }
.tm-tile strong { font-size: 15px; }
.tm-tile span.tm-desc { color: var(--t-muted); font-size: 12.5px; }
.tm-grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
/* home: clienti da seguire (segmenti marketing) */
.tm-segs { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.tm-seg { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--t-border); border-left: 4px solid var(--t-primary);
  border-radius: 10px; background: #fff; color: var(--t-text) !important; text-decoration: none !important; transition: background .15s, transform .15s; }
.tm-seg:hover { background: var(--t-primary-soft); transform: translateY(-1px); }
.tm-seg-n { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tm-seg-t { font-weight: 650; font-size: 13.5px; }
.tm-seg-d { color: var(--t-muted); font-size: 12px; }
.tm-card h3 { font-size: 16px; margin: 0 0 4px; }
.tm-card .tm-card-sub { color: var(--t-muted); margin: 0 0 16px; font-size: 13px; }

/* ----------- CELLULARE E TABLET ----------- */
@media (max-width: 991px) {
  body.tm .tm-grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 767px) {
  body.tm { padding-top: 66px; }
  body.tm .container { padding-left: 12px; padding-right: 12px; }
  body.tm .tm-nav .navbar-collapse { border-top: 1px solid var(--t-border); max-height: calc(100vh - 60px); }
  body.tm .tm-nav .navbar-nav { margin: 6px 0; }
  body.tm .tm-nav .navbar-nav > li > a { margin: 2px 6px; padding: 11px 12px; }
  body.tm .tm-nav .navbar-nav .open .dropdown-menu > li > a { padding: 10px 12px 10px 34px; }
  body.tm .jumbotron, body.tm .tm-card { padding: 18px; }
  body.tm .jumbotron h1 { font-size: 22px; }
  body.tm .tm-tiles { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  body.tm .tm-tile { padding: 14px; }
  body.tm .table { font-size: 13px; }
}
