:root{
  --amp-bg:#f8fafc;
  --amp-card:#ffffff;
  --amp-text:#111827;
  --amp-muted:#6b7280;
  --amp-border:#e5e7eb;
  --amp-soft:#f3f4f6;
  --amp-primary:#2563eb;
  --amp-primary-dark:#1d4ed8;
  --amp-danger:#b91c1c;
  --amp-success:#16a34a;
  --amp-warning:#f59e0b;
  --amp-radius:18px;
  --amp-shadow:0 10px 30px rgba(15,23,42,.08);
}

/* Reset plugin */
.amp-card,
.amp-card *{
  box-sizing:border-box;
}

/* Contenitore generale */
.amp-card{
  width:100%;
  max-width:1400px;
  margin:28px auto;
  padding:26px;
  background:var(--amp-card);
  border:1px solid var(--amp-border);
  border-radius:var(--amp-radius);
  box-shadow:var(--amp-shadow);
  color:var(--amp-text);
}

/* Form prenotazione paziente più stretto */
.amp-booking-card{
  max-width:640px;
}

/* Portale paziente */
.amp-patient-portal{
  max-width:900px;
}

/* Titoli */
.amp-card h2{
  margin:0 0 20px;
  font-size:26px;
  line-height:1.2;
  color:var(--amp-text);
}

.amp-card h3{
  margin:0 0 14px;
  color:var(--amp-text);
}

/* Form */
.amp-form label,
.amp-filters label{
  display:block;
  margin:0 0 14px;
  font-weight:600;
  color:#374151;
}

.amp-form input,
.amp-form select,
.amp-form textarea,
.amp-filters input,
.amp-filters select,
.amp-table input,
.amp-table textarea,
.amp-table select{
  width:100%;
  min-height:46px;
  padding:10px 12px;
  border:1px solid #d1d5db;
  border-radius:10px;
  box-sizing:border-box;
  font-size:15px;
  background:#fff;
  color:var(--amp-text);
}

.amp-form textarea,
.amp-table textarea{
  min-height:80px;
  resize:vertical;
}

/* Pulsanti */
.amp-form button,
.amp-filters button,
.amp-login input[type=submit],
.amp-small{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:46px;
  padding:10px 18px;
  border:0;
  border-radius:10px;
  background:var(--amp-primary);
  color:#fff;
  font-weight:700;
  cursor:pointer;
  text-decoration:none;
}

.amp-form button{
  width:100%;
}

.amp-form button:hover,
.amp-filters button:hover,
.amp-small:hover{
  background:var(--amp-primary-dark);
}

/* Pulsante Elimina */
.amp-danger,
button.amp-danger,
input.amp-danger{
  background:#ff0000!important;
  color:#fff!important;
  border-color:#dc2626!important;
}

.amp-danger:hover,
button.amp-danger:hover,
input.amp-danger:hover{
  background:#ff0000!important;
  border-color:#b91c1c!important;
}

/* Pulsante Salva */
.amp-small{
  background:#2563eb;
  color:#fff;
}

.amp-small:hover{
  background:#1d4ed8;
}

.amp-small{
  min-height:38px;
  padding:8px 11px;
  margin:2px;
  font-size:13px;
}

/* Avvisi */
.amp-alert{
  padding:13px 15px;
  border-radius:12px;
  margin:0 0 18px;
  font-weight:600;
}

.amp-success{
  background:#ecfdf5;
  color:#065f46;
  border:1px solid #a7f3d0;
}

.amp-error{
  background:#fef2f2;
  color:#991b1b;
  border:1px solid #fecaca;
}

.amp-muted{
  color:var(--amp-muted);
}

/* Header agenda */
.amp-agenda-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  margin-bottom:18px;
}

.amp-logout{
  padding:8px 12px;
  border-radius:10px;
  background:var(--amp-soft);
  text-decoration:none;
  color:var(--amp-text);
}

/* Filtri agenda */
.amp-filters{
  display:grid;
  grid-template-columns:repeat(3,minmax(180px,1fr));
  gap:14px;
  align-items:end;
  margin-bottom:20px;
}

/* Tabelle agenda medico / segreteria */
.amp-table-wrap{
  width:100%;
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
}

.amp-table{
  width:100%;
  min-width:1280px;
  border-collapse:collapse;
  font-size:14px;
}

.amp-table th,
.amp-table td{
  padding:11px 10px;
  border-bottom:1px solid var(--amp-border);
  vertical-align:top;
  text-align:left;
}

.amp-table th{
  position:sticky;
  top:0;
  z-index:2;
  background:#f9fafb;
  color:#374151;
  font-weight:800;
}

.amp-table tr:hover td{
  background:#fcfcfd;
}

.amp-table input,
.amp-table textarea{
  min-width:120px;
  font-size:14px;
}

.amp-table select{
  min-width:130px;
}

.amp-table td a{
  color:var(--amp-primary);
  text-decoration:none;
  overflow-wrap:anywhere;
}

.amp-inline-form,
.amp-cancel-form{
  margin:0;
}

.amp-actions{
  white-space:nowrap;
}

.amp-actions form{
  display:inline-block;
  margin:0 4px 4px 0;
}

/* Nuovo appuntamento interno */
.amp-internal-details{
  margin:16px 0;
  padding:12px;
  border:1px solid var(--amp-border);
  border-radius:14px;
  background:#f9fafb;
}

.amp-internal-details summary{
  cursor:pointer;
  font-weight:700;
  color:#1f2937;
}

.amp-internal-details .amp-card{
  margin-top:12px;
  box-shadow:none;
  border-radius:14px;
}

.amp-check{
  display:flex!important;
  gap:8px;
  align-items:flex-start;
}

.amp-check input{
  width:auto!important;
  margin-top:3px;
}

/* Login */
.amp-login .login-username label,
.amp-login .login-password label{
  display:block;
  margin-bottom:6px;
  font-weight:600;
}

.amp-login input[type=text],
.amp-login input[type=password]{
  width:100%;
  min-height:46px;
  border:1px solid #d1d5db;
  border-radius:10px;
  padding:10px 12px;
  box-sizing:border-box;
}

/* Calendario Segreteria */
.amp-secretary-calendar{
  max-width:1500px;
}

.amp-secretary-calendar .amp-agenda-head{
  align-items:center;
}

.amp-secretary-filters{
  margin-bottom:14px;
}

.amp-legend{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin:14px 0;
}

.amp-legend span{
  display:inline-flex;
  align-items:center;
  padding:6px 10px;
  border-radius:999px;
  font-size:12px;
  font-weight:700;
  background:#f3f4f6;
  color:#374151;
}

.amp-secretary-grid{
  display:grid;
  grid-template-columns:repeat(var(--amp-cols), minmax(260px, 1fr));
  gap:14px;
  align-items:start;
  overflow-x:auto;
  padding-bottom:10px;
}

.amp-doctor-column{
  min-width:260px;
  background:#f8fafc;
  border:1px solid var(--amp-border);
  border-radius:14px;
  padding:10px;
}

.amp-doctor-column header{
  display:flex;
  justify-content:space-between;
  gap:8px;
  align-items:center;
  border-bottom:1px solid var(--amp-border);
  padding-bottom:8px;
  margin-bottom:10px;
}

.amp-doctor-column header strong{
  color:var(--amp-text);
}

.amp-doctor-column header small{
  color:var(--amp-muted);
  font-size:12px;
  white-space:nowrap;
}

.amp-empty-day{
  color:var(--amp-muted);
  background:#fff;
  border:1px dashed #d1d5db;
  border-radius:10px;
  padding:14px;
  text-align:center;
}

.amp-sec-event{
  display:grid;
  grid-template-columns:58px 1fr;
  gap:10px;
  background:#fff;
  border-left:6px solid var(--amp-primary);
  border-radius:12px;
  box-shadow:0 1px 3px rgba(15,23,42,.08);
  padding:10px;
  margin-bottom:10px;
}

.amp-sec-time{
  font-weight:800;
  color:var(--amp-text);
  font-size:15px;
}

.amp-sec-main{
  display:flex;
  flex-direction:column;
  gap:3px;
  min-width:0;
}

.amp-sec-main span,
.amp-sec-main small,
.amp-sec-main em{
  font-size:12px;
  color:#4b5563;
  overflow-wrap:anywhere;
}

.amp-sec-main em{
  margin-top:3px;
  color:var(--amp-muted);
}

.amp-sec-event.st-confermato{border-left-color:#16a34a}
.amp-sec-event.st-in_attesa{border-left-color:#f59e0b}
.amp-sec-event.st-annullato{border-left-color:#dc2626;opacity:.72}
.amp-sec-event.st-completato{border-left-color:#6b7280;opacity:.85}

.amp-sec-event.or-online{
  box-shadow:inset 0 0 0 1px rgba(37,99,235,.18);
}

.amp-sec-event.or-telefono,
.amp-sec-event.or-segreteria{
  box-shadow:inset 0 0 0 1px rgba(124,58,237,.18);
}

.amp-legend .st-confermato{background:#ecfdf5;color:#065f46}
.amp-legend .st-in_attesa{background:#fffbeb;color:#92400e}
.amp-legend .st-annullato{background:#fef2f2;color:#991b1b}
.amp-legend .st-completato{background:#f3f4f6;color:#374151}
.amp-legend .or-online{background:#eff6ff;color:#1d4ed8}
.amp-legend .or-telefono{background:#f5f3ff;color:#6d28d9}

/* Portale paziente */
.amp-portal-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:18px;
  align-items:start;
}

.amp-portal-grid section{
  background:#f9fafb;
  border:1px solid var(--amp-border);
  border-radius:14px;
  padding:16px;
}

.amp-register-form button{
  width:100%;
}

.amp-pwa-hint{
  margin:14px 0 22px;
  padding:12px 14px;
  border-radius:14px;
  background:#eff6ff;
  color:#1d4ed8;
  border:1px solid #bfdbfe;
  font-weight:600;
}

/* Web app mobile paziente */
.amp-app-shell{
  position:relative;
  overflow:hidden;
  background:linear-gradient(180deg,#ffffff 0%,#f8fafc 100%);
}

.amp-app-top{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
  margin-bottom:8px;
}

.amp-app-kicker{
  display:inline-flex;
  margin-bottom:4px;
  color:var(--amp-primary);
  font-size:12px;
  font-weight:800;
  letter-spacing:.08em;
  text-transform:uppercase;
}

.amp-app-hello{
  font-size:15px;
  margin-bottom:16px;
}

.amp-app-actions{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:12px;
  margin:18px 0 18px;
}

.amp-app-actions a,
.amp-app-actions button{
  appearance:none;
  text-decoration:none;
  text-align:left;
  border:1px solid var(--amp-border);
  background:#fff;
  color:var(--amp-text);
  border-radius:18px;
  padding:16px;
  box-shadow:0 8px 22px rgba(15,23,42,.07);
  display:flex;
  flex-direction:column;
  gap:5px;
  min-height:104px;
  cursor:pointer;
  font:inherit;
}

.amp-app-actions strong{
  font-size:15px;
}

.amp-app-actions span{
  font-size:12px;
  color:var(--amp-muted);
  line-height:1.35;
}

.amp-app-section{
  scroll-margin-top:16px;
  margin-top:18px;
}

.amp-profile-card{
  background:#fff;
  border:1px solid var(--amp-border);
  border-radius:16px;
  padding:16px;
}

.amp-bottom-nav{
  display:none;
}

/* Compatibilità temi WordPress/Astra */
body .site-content .amp-card,
body .entry-content .amp-card{
  max-width:1400px;
}

body .entry-content .amp-secretary-calendar{
  max-width:1500px;
}

/* Tablet */
@media(max-width:1024px){
  .amp-card{
    max-width:100%;
    margin:22px 14px;
    padding:22px;
  }

  .amp-filters{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }

  .amp-secretary-grid{
    grid-template-columns:repeat(var(--amp-cols), minmax(240px, 1fr));
  }

  .amp-doctor-column{
    min-width:240px;
  }
}

/* Mobile */
@media(max-width:760px){
  .amp-card{
    margin:16px 10px;
    padding:18px;
    border-radius:16px;
  }

  .amp-card h2{
    font-size:22px;
  }

  .amp-filters{
    grid-template-columns:1fr;
  }

  .amp-agenda-head{
    align-items:flex-start;
    flex-direction:column;
  }

  .amp-portal-grid{
    grid-template-columns:1fr;
  }

  .amp-patient-portal .amp-booking-card{
    margin-left:0;
    margin-right:0;
  }

  /* Agenda medico mobile: tabella trasformata in schede */
  .amp-table-wrap{
    overflow-x:visible;
  }

  .amp-table,
  .amp-table thead,
  .amp-table tbody,
  .amp-table th,
  .amp-table td,
  .amp-table tr{
    display:block;
    width:100%;
    min-width:0;
  }

  .amp-table{
    min-width:0;
  }

  .amp-table thead{
    display:none;
  }

  .amp-table tr{
    margin:0 0 14px;
    padding:14px;
    border:1px solid var(--amp-border);
    border-radius:14px;
    background:#fff;
    box-shadow:0 6px 18px rgba(15,23,42,.06);
  }

  .amp-table tr:hover td{
    background:transparent;
  }

  .amp-table td{
    display:grid;
    grid-template-columns:100px minmax(0,1fr);
    gap:10px;
    align-items:start;
    padding:9px 0;
    border-bottom:1px solid #f1f5f9;
  }

  .amp-table td:last-child{
    border-bottom:0;
  }

  .amp-table td::before{
    content:attr(data-label);
    font-weight:700;
    color:#374151;
    font-size:13px;
    line-height:1.4;
  }

  .amp-table input,
  .amp-table textarea,
  .amp-table select{
    min-width:0;
    width:100%;
    font-size:16px;
  }

  .amp-table textarea{
    min-height:72px;
  }

  .amp-actions{
    white-space:normal;
  }

  .amp-actions form,
  .amp-actions button,
  .amp-actions .amp-small{
    display:block;
    width:100%;
    margin:0 0 8px 0;
  }

  .amp-small{
    min-height:44px;
    font-size:14px;
  }

  /* Segreteria su mobile: colonne impilate */
  .amp-secretary-grid{
    grid-template-columns:1fr;
    overflow-x:visible;
  }

  .amp-doctor-column{
    min-width:0;
  }

  .amp-sec-event{
    grid-template-columns:64px 1fr;
  }

  /* Web app paziente */
  body:has(.amp-app-shell){
    background:#f8fafc;
  }

  .amp-app-shell{
    margin:0;
    min-height:100svh;
    border-radius:0;
    border:0;
    box-shadow:none;
    padding:18px 14px 84px;
    max-width:none;
  }

  .amp-app-top h2{
    font-size:24px;
    line-height:1.1;
  }

  .amp-app-actions{
    grid-template-columns:1fr 1fr;
    gap:10px;
  }

  .amp-app-actions a,
  .amp-app-actions button{
    border-radius:16px;
    min-height:96px;
    padding:14px;
  }

  .amp-pwa-hint{
    font-size:13px;
  }

  .amp-app-section .amp-card{
    border-radius:16px;
    margin:12px 0;
    padding:16px;
  }

  .amp-bottom-nav{
    position:fixed;
    left:10px;
    right:10px;
    bottom:10px;
    z-index:999;
    display:grid;
    grid-template-columns:repeat(3,1fr);
    background:#111827;
    border-radius:18px;
    padding:8px;
    box-shadow:0 12px 34px rgba(15,23,42,.25);
  }

  .amp-bottom-nav a{
    color:#fff;
    text-decoration:none;
    text-align:center;
    font-size:12px;
    font-weight:800;
    padding:10px 6px;
    border-radius:12px;
  }

  .amp-bottom-nav a:active,
  .amp-bottom-nav a:focus{
    background:#374151;
  }
}

/* Smartphone piccoli */
@media(max-width:420px){
  .amp-card{
    margin:12px 6px;
    padding:16px;
    border-radius:14px;
  }

  .amp-table tr{
    padding:12px;
  }

  .amp-table td{
    grid-template-columns:1fr;
    gap:6px;
  }

  .amp-app-actions{
    grid-template-columns:1fr;
  }

  .amp-sec-event{
    grid-template-columns:1fr;
  }
}

/* Migliorie form prenotazione front-end */
.amp-booking-card{
  max-width:720px;
  margin:34px auto;
  padding:30px;
  border:0;
  border-radius:24px;
  background:#fff;
  box-shadow:0 18px 50px rgba(15,23,42,.10);
}

.amp-booking-card h2{
  font-size:34px;
  letter-spacing:-.02em;
  color:#374151;
  margin-bottom:22px;
}

.amp-booking-card .amp-form{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:16px;
}

.amp-booking-card .amp-form label{
  margin:0;
  color:#6b7280;
  font-size:14px;
  font-weight:700;
}

.amp-booking-card .amp-form label:has(textarea),
.amp-booking-card .amp-form button{
  grid-column:1 / -1;
}

.amp-booking-card .amp-form input,
.amp-booking-card .amp-form select,
.amp-booking-card .amp-form textarea{
  margin-top:6px;
  border:1px solid #d8dee8;
  border-radius:14px;
  background:#f9fafb;
  transition:border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.amp-booking-card .amp-form input:focus,
.amp-booking-card .amp-form select:focus,
.amp-booking-card .amp-form textarea:focus{
  outline:none;
  border-color:#22cfd1;
  background:#fff;
  box-shadow:0 0 0 4px rgba(34,207,209,.14);
}

.amp-booking-card .amp-form button{
  justify-self:start;
  width:auto;
  min-width:150px;
  border-radius:12px;
  background:#22cfd1;
  box-shadow:0 10px 22px rgba(34,207,209,.24);
}

.amp-booking-card .amp-form button:hover{
  background:#16b8ba;
}

.amp-booking-card .amp-form select:disabled{
  opacity:.72;
  cursor:progress;
}

@media(max-width:760px){
  .amp-booking-card{
    margin:18px 10px;
    padding:22px;
    border-radius:20px;
  }
  .amp-booking-card h2{
    font-size:28px;
  }
  .amp-booking-card .amp-form{
    grid-template-columns:1fr;
  }
  .amp-booking-card .amp-form button{
    width:100%;
  }
}
