/* ==========================================================================
   Grimaldi Cloud — foglio di stile
   Palette: blu navale Grimaldi + accento rosso; dashboard in tema operativo
   scuro coerente con l'app di bordo.
   ========================================================================== */

:root {
  --navy-950: #06101d;
  --navy-900: #0a1626;
  --navy-850: #0f1b2d;
  --navy-800: #12233a;
  --navy-700: #17304d;
  --navy-600: #1e3d63;
  --line:     #22406a;

  --grimaldi-blue: #00234b;
  --grimaldi-red:  #cc2229;

  --accent:   #00a8ff;
  --accent-2: #4fd1ff;

  --green:  #16b45c;
  --amber:  #e2a021;
  --red:    #e0413c;
  --purple: #8b6cf5;

  --text:      #e9f1f8;
  --text-soft: #9db4cc;
  --text-dim:  #64809c;

  --radius: 8px;
  --shadow: 0 10px 40px rgba(0, 0, 0, .45);
}

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

body {
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  background: var(--navy-950);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   LANDING / LOGIN
   ========================================================================== */

body.landing { height: 100vh; overflow: hidden; }

.landing-grid {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  height: 100vh;
}

.landing-brand {
  background: var(--grimaldi-blue);
  display: flex;
  align-items: center;
  padding: 0 8vw;
  position: relative;
  overflow: hidden;
}

/* onda sobria in basso, nessun gradiente sgargiante */
.landing-brand::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 120px;
  background:
    radial-gradient(120% 100% at 50% 100%, rgba(0, 168, 255, .10), transparent 70%);
  pointer-events: none;
}

.brand-inner { max-width: 520px; }

.brand-logo { width: 300px; height: auto; display: block; }

.brand-title {
  margin-top: 26px;
  font-size: 44px;
  font-weight: 300;
  letter-spacing: 1px;
  color: #fff;
}

.brand-sub {
  margin-top: 10px;
  font-size: 15px;
  color: #9dc0dd;
  line-height: 1.6;
}

.brand-rule {
  width: 64px;
  height: 3px;
  background: var(--grimaldi-red);
  margin: 28px 0;
}

.brand-points { list-style: none; }
.brand-points li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
  font-size: 14px;
  color: #b8d3e8;
  line-height: 1.5;
}
.brand-points .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 7px;
  flex: none;
}

.brand-footer {
  margin-top: 44px;
  font-size: 11px;
  color: #5f87ab;
  letter-spacing: .3px;
}

.landing-login {
  background: var(--navy-900);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6vw;
}

.login-card { width: 100%; max-width: 380px; }

.login-card h2 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 6px;
}

.login-hint {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 30px;
}

.login-card label {
  display: block;
  font-size: 12px;
  color: var(--text-soft);
  margin-bottom: 7px;
  letter-spacing: .3px;
}

.login-card input {
  width: 100%;
  background: var(--navy-850);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  padding: 12px 14px;
  margin-bottom: 18px;
  transition: border-color .15s, background .15s;
}
.login-card input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--navy-800);
}

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #04121f;
  border: none;
  border-radius: var(--radius);
  padding: 13px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .3px;
  cursor: pointer;
  transition: filter .15s;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); }
.btn-primary:disabled { opacity: .6; cursor: default; }

.login-error {
  background: rgba(224, 65, 60, .12);
  border: 1px solid rgba(224, 65, 60, .45);
  color: #ff9d99;
  font-size: 13px;
  padding: 10px 12px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.login-foot {
  margin-top: 26px;
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
}

@media (max-width: 900px) {
  .landing-grid { grid-template-columns: 1fr; }
  .landing-brand { display: none; }
}

/* ==========================================================================
   DASHBOARD
   ========================================================================== */

body.dash { height: 100vh; overflow: hidden; display: flex; flex-direction: column; }

/* ---- topbar ---- */
.topbar {
  height: 56px;
  background: var(--grimaldi-blue);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 16px;
  flex: none;
}
.topbar .logo { height: 30px; }
.topbar .spacer { flex: 1; }

.topbar .who {
  font-size: 12px;
  color: #a8c8e2;
}
.btn-ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .22);
  color: #dbe9f5;
  padding: 6px 13px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}
.btn-ghost:hover { background: rgba(255, 255, 255, .08); }

/* ---- layout principale ---- */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 0;
  overflow: hidden;
}
.layout > * { min-height: 0; }

/* ---- sidebar navi ---- */
.ships {
  background: var(--navy-900);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  min-height: 0;
  padding: 14px 0;
}
.ships h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-dim);
  padding: 0 18px 12px;
}
.ship-item {
  padding: 12px 18px;
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background .12s;
}
.ship-item:hover { background: var(--navy-850); }
.ship-item.active {
  background: var(--navy-800);
  border-left-color: var(--accent);
}
.ship-name { font-size: 14px; font-weight: 600; }
.ship-meta { font-size: 11px; color: var(--text-dim); margin-top: 3px; }
.badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: .5px;
  margin-top: 6px;
}
.badge.active { background: rgba(22, 180, 92, .18); color: #4fdc92; border: 1px solid rgba(22, 180, 92, .5); }
.badge.closed { background: rgba(224, 65, 60, .15); color: #ff8b86; border: 1px solid rgba(224, 65, 60, .45); }
.badge.none   { background: rgba(100, 128, 156, .15); color: var(--text-dim); border: 1px solid var(--line); }
.badge.offline{ background: rgba(90, 110, 130, .12); color: #6d8399; border: 1px solid #2a3f57; }

/* navi previste in flotta, impianto non ancora installato a bordo */
.ship-item.offline {
  cursor: default;
  opacity: .45;
}
.ship-item.offline:hover { background: transparent; }
.ship-item.offline .ship-name { color: #7a90a6; font-weight: 500; }
.ship-item.offline .ship-meta { color: #4a627c; }

/* ---- area nave ---- */
.ship-view {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;          /* indispensabile: senza questo i figli non scrollano */
  background: var(--navy-950);
}

.route-head {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--navy-900);
  display: flex;
  align-items: center;
  gap: 22px;
  flex: none;
}
.route-title { font-size: 16px; font-weight: 600; }
.route-sub { font-size: 12px; color: var(--text-soft); margin-top: 3px; }
.route-head .spacer { flex: 1; }

.route-select {
  background: var(--navy-800);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 12px;
}

.kpis { display: flex; gap: 26px; }
.kpi { text-align: center; }
.kpi .v { font-size: 22px; font-weight: 700; line-height: 1; }
.kpi .l { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .8px; margin-top: 5px; }
.kpi .v.in   { color: var(--red); }
.kpi .v.out  { color: var(--green); }
.kpi .v.free { color: var(--text-soft); }

/* ---- tre colonne: targhe | stiva | conteggio ---- */
.panes {
  flex: 1;
  display: grid;
  grid-template-columns: 210px 1fr 210px;
  min-height: 0;
  overflow: hidden;
}

/* ogni colonna deve poter "rimpicciolirsi" per far scattare lo scroll interno */
.panes > * { min-height: 0; }

.pane {
  background: var(--navy-900);
  overflow-y: auto;
  min-height: 0;
  padding: 14px 12px;
}
.pane.left  { border-right: 1px solid var(--line); }
.pane.right { border-left: 1px solid var(--line); }

.pane h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  color: var(--text-soft);
  text-align: center;
  margin-bottom: 12px;
}

.big-num {
  text-align: center;
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
}
.big-num.plates { color: var(--accent); }
.big-num.ai-in  { color: var(--green); }
.big-num.ai-out { color: var(--green); }
.big-label {
  text-align: center;
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin: 5px 0 16px;
}

.card {
  background: var(--navy-800);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px;
  margin-bottom: 8px;
}
.card img {
  width: 100%;
  border-radius: 4px;
  display: block;
  cursor: zoom-in;
  background: var(--navy-700);
}
.card .t { font-size: 12px; font-weight: 700; margin-top: 6px; }
.card .s { font-size: 10px; color: var(--text-dim); margin-top: 2px; }
.card .dir {
  font-size: 9px; font-weight: 700; letter-spacing: .5px;
  padding: 1px 6px; border-radius: 3px; display: inline-block; margin-top: 4px;
}
.dir.ENTRATA { background: rgba(22,180,92,.18);  color: #4fdc92; }
.dir.USCITA  { background: rgba(224,65,60,.16);  color: #ff8b86; }

/* ---- stiva ---- */
.hold {
  padding: 16px 18px;
  overflow-y: auto;
  min-height: 0;
  background: var(--navy-950);
}
.hold-bar {
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 12px;
  color: var(--text-soft);
  margin-bottom: 14px;
}
.hold-bar b { color: var(--text); }
.legend { display: flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 2px; }
.sw.red   { background: #8f2a2a; }
.sw.green { background: #1c6b41; }
.sw.free  { background: #26364a; }

.slots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}
.slot {
  aspect-ratio: 1 / .78;
  border-radius: 6px;
  border: 1px solid #26364a;
  background: #16202e;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #405a76;
  padding: 6px;
  transition: transform .1s;
}
.slot.occupied {
  background: #4a1414;
  border-color: #8f2a2a;
  color: #ffd9d7;
  cursor: pointer;
}
.slot.occupied:hover { transform: translateY(-2px); }
.slot.exited {
  background: #10402a;
  border-color: #1c6b41;
  color: #b8f0d0;
  cursor: pointer;
}
.slot.exited:hover { transform: translateY(-2px); }
.slot .qr   { font-size: 13px; font-weight: 700; }
.slot .tm   { font-size: 9px; opacity: .85; margin-top: 3px; }
.slot .st   { font-size: 8px; letter-spacing: .5px; margin-top: 3px; opacity: .8; }

.empty-state {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  padding: 60px 20px;
  line-height: 1.7;
}

/* ---- modale foto mezzo ---- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 8, 16, .86);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 30px;
}
.modal[hidden] { display: none; }
.modal-box {
  background: var(--navy-900);
  border: 1px solid var(--line);
  border-radius: 10px;
  max-width: 1000px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 14px;
}
.modal-head .t { font-size: 16px; font-weight: 700; }
.modal-head .spacer { flex: 1; }
.modal-body { padding: 16px 18px; }
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.photo-grid img {
  width: 100%;
  border-radius: 6px;
  border: 1px solid var(--line);
  display: block;
}
.close-x {
  background: transparent;
  border: none;
  color: var(--text-soft);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}

/* ==========================================================================
   PLAYBACK  e  REGISTRO
   ========================================================================== */

.btn-playback, .btn-log {
  background: #2d1f52;
  border: 1px solid #4a3580;
  color: #d9ccff;
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  margin-left: 8px;
}
.btn-playback:hover, .btn-log:hover { background: #3a2968; }
.btn-log { background: #1c3350; border-color: #2f5480; color: #cfe3f7; }
.btn-log:hover { background: #24425f; }

.pb-box { max-width: 1240px; }
.pb-body { padding: 14px 18px 18px; }

.pb-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.pb-play {
  width: 40px; height: 34px;
  background: var(--purple);
  border: none; border-radius: 6px;
  color: #fff; font-size: 14px;
  cursor: pointer;
}
.pb-play:hover { filter: brightness(1.1); }

.pb-slider {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: #22334d;
  border-radius: 3px;
  outline: none;
}
.pb-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--purple);
  border: 2px solid #fff;
  cursor: pointer;
}

.pb-clock {
  font-size: 11px;
  color: var(--text-soft);
  min-width: 230px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.pb-kpis {
  display: flex;
  gap: 26px;
  padding: 10px 0 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}

.pb-main {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 16px;
  min-height: 0;
}

.pb-slots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 7px;
  max-height: 44vh;
  overflow-y: auto;
  align-content: start;
}

.pb-events {
  border-left: 1px solid var(--line);
  padding-left: 14px;
  max-height: 44vh;
  overflow-y: auto;
}
.pb-events h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-soft);
  margin-bottom: 10px;
}
.pb-ev {
  font-size: 11px;
  padding: 5px 0;
  border-bottom: 1px solid #17263c;
  color: var(--text-soft);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.ev-time { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.ev-cam  { color: var(--text-dim); font-size: 10px; }
.ev-tag {
  font-size: 9px; font-weight: 700; letter-spacing: .4px;
  padding: 1px 6px; border-radius: 3px;
}
.ev-tag.in    { background: rgba(224, 65, 60, .18);  color: #ff9b96; }
.ev-tag.out   { background: rgba(22, 180, 92, .18);  color: #4fdc92; }
.ev-tag.ai    { background: rgba(139, 108, 245, .18); color: #b9a6ff; }
.ev-tag.plate { background: rgba(0, 168, 255, .16);  color: #7fd0ff; }

/* registro */
.log-row {
  display: grid;
  grid-template-columns: 150px 120px 70px 1fr;
  gap: 8px;
  align-items: center;
  font-size: 11px;
  padding: 6px 8px;
  background: var(--navy-850);
  border-radius: 4px;
  margin-bottom: 3px;
}
.log-ts  { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.log-qr  { color: #fff; font-weight: 700; }
.log-det { color: var(--text-soft); }
.log-ev {
  font-size: 9px; font-weight: 700; letter-spacing: .4px;
  padding: 2px 6px; border-radius: 3px; text-align: center;
  background: rgba(100, 128, 156, .16); color: var(--text-soft);
}
.log-ev.ENTRATA        { background: rgba(22, 180, 92, .18);  color: #4fdc92; }
.log-ev.MANOVRA        { background: rgba(226, 160, 33, .18); color: #ffcf72; }
.log-ev.USCITA         { background: rgba(224, 65, 60, .16);  color: #ff9b96; }
.log-ev.SBARCO         { background: rgba(200, 60, 140, .18); color: #ff9ed6; }
.log-ev.ROTTA-CREATA,
.log-ev.ROTTA-CHIUSA   { background: rgba(0, 168, 255, .16);  color: #7fd0ff; }
.log-ev.PORTO-CORRENTE { background: rgba(139, 108, 245, .18); color: #b9a6ff; }

/* scrollbar sobria */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: var(--navy-950); }
::-webkit-scrollbar-thumb { background: #1e3350; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #2a4568; }

