/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f2f2f2;
  --card:      #ffffff;
  --border:    #e4e4e4;
  --text:      #1a1a1a;
  --muted:     #999999;
  --green:     #14FFBC;
  --green-bg:  #e6fff8;
  --orange:    #e65100;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow:    0 1px 6px rgba(0,0,0,.07);
  --sidebar-w: 260px;
  --font:      'Inter', system-ui, sans-serif;
}

html { height: 100%; background: var(--bg); }
body { height: 100%; font-family: var(--font); background: transparent; color: var(--text); font-size: 14px; line-height: 1.5; }

/* decorative bg — must be colorful for glassmorphism to show */
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(ellipse 280px 320px at -20px 80px,  rgba(20,255,188,.35) 0%, transparent 100%),
    radial-gradient(ellipse 200px 200px at 60px 380px,  rgba(0,180,120,.15)  0%, transparent 100%),
    radial-gradient(ellipse 400px 300px at 80% 20%,     rgba(99,102,241,.07) 0%, transparent 100%),
    #ebebeb;
}

/* ── Login ── */
.login-overlay {
  position: fixed; inset: 0; background: var(--bg);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.login-card {
  background: var(--card); border-radius: var(--radius-lg); padding: 40px 36px;
  width: 360px; box-shadow: 0 4px 24px rgba(0,0,0,.10); text-align: center;
}
.login-logo  { font-size: 2.2rem; margin-bottom: 8px; }
.login-title { font-size: 1.5rem; color: var(--text); margin-bottom: 4px; }
.login-sub   { font-size: .8rem; color: var(--muted); margin-bottom: 24px; }
.login-input {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius-md); font-size: .9rem; outline: none;
  transition: border-color .15s; margin-bottom: 10px; font-family: var(--font);
}
.login-input:focus { border-color: var(--text); }
.login-error { color: #e53935; font-size: .82rem; margin-bottom: 8px; }

/* ── Layout ── */
.layout { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar — glassmorphism ── */
.sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  background: rgba(255,255,255,0.28);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-right: 1px solid rgba(255,255,255,0.6);
  box-shadow: 2px 0 20px rgba(20,255,188,.06);
  display: flex; flex-direction: column; height: 100vh; overflow: hidden;
}
.sidebar-top { flex: 1; overflow-y: auto; padding: 20px 16px 12px; scrollbar-width: none; }
.sidebar-top::-webkit-scrollbar { display: none; }
.sidebar-bottom {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-top: 1px solid rgba(228,228,228,.6);
  flex-shrink: 0;
}

.sidebar-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.logo-icon { font-size: 1.1rem; color: var(--muted); cursor: pointer; }
.logo-text { font-size: 1.05rem; color: #002D20; }

/* ── Search — pill, lens right ── */
.search-wrap { position: relative; margin-bottom: 16px; }
.search-icon { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; display: block; pointer-events: none; }
.search-input {
  width: 100%; padding: 7px 32px 7px 14px;
  border: 1px solid var(--border); border-radius: 9999px;
  font-size: .82rem; outline: none; font-family: var(--font); color: var(--text);
  background: #fff; transition: border-color .15s;
}
.search-input:focus { border-color: #aaa; }

.section-label { font-size: .7rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }

.history-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }
.history-item {
  display: flex; align-items: center; justify-content: space-between; gap: 4px;
  padding: 7px 8px; border-radius: var(--radius-sm); font-size: .8rem;
  color: #444; cursor: pointer; transition: background .1s;
}
.history-item:hover { background: rgba(0,0,0,.04); }
.history-item.active { background: var(--green-bg); color: #00a878; font-weight: 600; }
.history-new { color: #002D20; font-weight: 600; gap: 6px; border-bottom: 1px solid rgba(0,0,0,.07); margin-bottom: 4px; padding-bottom: 10px; justify-content: flex-start; }
.history-new:hover { background: rgba(20,255,188,.12); }
.history-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.history-delete {
  flex-shrink: 0; background: none; border: none; cursor: pointer;
  padding: 2px 4px; border-radius: 4px; opacity: 0;
  transition: opacity .15s, background .15s; display: flex; align-items: center;
}
.history-item:hover .history-delete { opacity: 1; }
.history-delete:hover { background: #fee2e2; }
.history-empty { font-size: .8rem; color: var(--muted); padding: 4px 0; }

.divider { height: 1px; background: rgba(228,228,228,.7); margin: 14px 0; }

.field-label { display: block; font-size: .75rem; font-weight: 600; color: #555; margin-bottom: 5px; }
.select-field {
  width: 100%; padding: 8px 10px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: .85rem; outline: none;
  font-family: var(--font); color: var(--text); background: #fff; cursor: pointer;
  appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.select-field:focus { border-color: var(--text); }

.custom-select { position: relative; }
.custom-select-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; font-size: .85rem; font-family: var(--font); color: var(--text);
  cursor: pointer; text-align: left;
}
.custom-select-btn:hover { border-color: #ccc; }
.custom-select-value { display: flex; align-items: center; gap: 6px; }
.custom-select-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: #fff; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: 0 4px 16px rgba(0,0,0,.10); z-index: 50; overflow: hidden;
}
.custom-select-option {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; font-size: .85rem; cursor: pointer; color: var(--text);
  transition: background .1s;
}
.custom-select-option:hover { background: #f5f5f5; }
.brand-logo-sm { width: 17px; height: 16px; object-fit: contain; flex-shrink: 0; }
.brand-inline { display: flex; align-items: center; gap: 6px; }

/* ── Sidebar sections — no card, flat ── */
.corr-section { margin-bottom: 4px; }
.corr-header { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.corr-title { font-size: .8rem; font-weight: 700; color: var(--text); }
.corr-count { font-size: .76rem; color: #555; margin-bottom: 8px; line-height: 1.4; }

/* ── Vedi button ── */
.btn-vedi {
  background: #002D20;
  color: #fff;
  border: 1px solid rgba(20,255,188,.4);
  border-radius: var(--radius-sm);
  padding: 6px 16px;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  box-shadow: 0 1px 4px rgba(0,0,0,.15), 0 1px 4px rgba(0,0,0,.08);
  transition: background .15s;
}
.btn-vedi:hover { background: #003d2a; }

/* ── Compliance dettagliata ── */
.compliance-section { margin-top: 4px; }
.comp-tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.comp-tab {
  padding: 3px 10px; border-radius: 9999px; font-size: .72rem; font-weight: 600;
  cursor: pointer; border: 1px solid var(--border); background: transparent; color: var(--muted);
  transition: all .15s; font-family: var(--font);
}
.comp-tab.active { background: var(--text); color: #fff; border-color: var(--text); }
.comp-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: .8rem; color: #555; }
.comp-score { font-weight: 700; }
.score-green  { color: #009951; }
.score-orange { color: #BF6A02; }
.score-red    { color: #900B09; }

.avatar-circle { width: 34px; height: 34px; border-radius: 50%; background: var(--text); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: .75rem; flex-shrink: 0; }
.avatar-name { font-size: .85rem; font-weight: 600; color: var(--text); }

/* ── Main ── */
.main { flex: 1; display: flex; flex-direction: column; height: 100vh; overflow: hidden; min-width: 0; }
.cards-area { flex: 1; overflow-y: auto; padding: 28px 28px 16px; display: flex; flex-direction: column; }

.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--muted); }
.empty-icon { font-size: 3rem; }
.empty-title { font-size: 1.1rem; font-weight: 600; color: #555; }
.empty-sub { font-size: .85rem; }

.loading-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; }
.spinner { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--text); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: .9rem; color: var(--muted); }

.cards-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ── Transcription card ── */
.trans-card {
  background: var(--card); border-radius: var(--radius-lg); padding: 24px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px;
}
.card-title { font-size: 1.2rem; font-weight: 700; color: #002D20; }
.card-score { font-size: .9rem; font-weight: 700; }
.card-score.score-green { color: #00c896; }
.card-score.score-orange { color: var(--orange); }
.card-score.score-red { color: #dc2626; }
.card-hint { font-size: .78rem; color: var(--muted); }

.card-textarea {
  width: 100%; padding: 12px; border: 1.5px solid var(--border);
  border-radius: var(--radius-md); font-family: var(--font); font-size: .88rem;
  line-height: 1.65; resize: vertical; outline: none; color: var(--text);
  background: #fafafa; transition: border-color .15s; min-height: 160px;
}
.card-textarea:focus { border-color: var(--text); background: #fff; }

.violations-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.viol-label { font-size: .78rem; color: var(--muted); }
.badge-viol { background: #fee2e2; color: #dc2626; border-radius: 4px; padding: 2px 8px; font-size: .75rem; font-weight: 600; }

.card-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 4px; }
.action-icons { display: flex; gap: 8px; align-items: center; }

/* ── Icon buttons — flat, no circle ── */
.icon-btn {
  background: none; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 4px; color: #555; transition: color .1s, opacity .1s;
  border-radius: 4px;
}
.icon-btn:hover { color: var(--text); opacity: .8; }
.icon-btn.active svg path { stroke: #00a878; }

/* ── Approve / Save button — transparent with icon ── */
.btn-approve {
  display: flex; align-items: center; gap: 6px;
  background: transparent; border: 1.5px solid var(--border);
  border-radius: var(--radius-md); padding: 7px 14px;
  font-size: .82rem; font-weight: 600; cursor: pointer;
  font-family: var(--font); color: var(--text);
  white-space: nowrap; transition: border-color .15s, background .15s;
}
.btn-approve:hover { border-color: var(--text); background: rgba(0,0,0,.03); }
.btn-approve:disabled { opacity: .5; cursor: not-allowed; }
.btn-approve.saved { border-color: #00c896; color: #00c896; }

.notes-toggle {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0 0; border-top: 1px solid var(--border);
  font-size: .82rem; color: #666; cursor: pointer; font-weight: 500;
}
.notes-toggle:hover { color: var(--text); }
.notes-body { padding: 10px 0 2px; }
.notes-text { font-size: .83rem; color: #444; line-height: 1.6; margin-bottom: 8px; }
.term-title { font-size: .82rem; font-weight: 700; color: var(--orange); margin-bottom: 4px; }
.term-item { font-size: .82rem; color: var(--orange); }

/* ── Original translation section ── */
.orig-section { margin-top: 16px; }
.orig-toggle {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--card); border-radius: var(--radius-md);
  cursor: pointer; font-size: .82rem; font-weight: 600; color: #555;
  box-shadow: var(--shadow); transition: background .1s;
}
.orig-toggle:hover { background: #f8f8f8; }
.orig-body { background: var(--card); border-radius: 0 0 var(--radius-md) var(--radius-md); padding: 12px 16px 14px; box-shadow: var(--shadow); margin-top: -4px; }
.orig-score { font-size: .8rem; font-weight: 700; margin-bottom: 8px; }
.orig-text { font-size: .88rem; color: #444; line-height: 1.65; white-space: pre-wrap; }

/* ── Revision suggestion ── */
.revision-row { margin-top: 12px; }
.btn-revise {
  display: flex; align-items: center; gap: 6px;
  background: transparent; border: 1px solid #002D20;
  border-radius: var(--radius-sm); padding: 6px 12px;
  font-size: .78rem; font-weight: 600; color: #002D20;
  cursor: pointer; font-family: var(--font); transition: background .15s;
}
.btn-revise:hover { background: #f0fff8; }
.btn-revise:disabled { opacity: .5; cursor: not-allowed; }
.revision-box {
  margin-top: 10px; background: #f0fff8;
  border: 1px solid rgba(0,45,32,.2); border-radius: var(--radius-md);
  padding: 12px 14px;
}
.revision-label { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #002D20; margin-bottom: 6px; }
.revision-text { font-size: .88rem; color: #1a1a1a; line-height: 1.65; white-space: pre-wrap; margin-bottom: 10px; }
.btn-swap {
  display: flex; align-items: center; gap: 6px;
  background: #002D20; color: #fff; border: none;
  border-radius: var(--radius-sm); padding: 7px 14px;
  font-size: .78rem; font-weight: 700; cursor: pointer;
  font-family: var(--font); transition: background .15s;
}
.btn-swap:hover { background: #003d2a; }

.error-banner { background: #fee2e2; color: #dc2626; padding: 12px 16px; border-radius: var(--radius-md); font-size: .85rem; margin-top: 12px; }

/* ── Input bar ── */
.input-bar { flex-shrink: 0; padding: 12px 28px 20px; }
.input-wrap {
  display: flex; flex-direction: column; gap: 8px;
  background: rgba(255,255,255,.85); backdrop-filter: blur(8px);
  border-radius: var(--radius-lg); padding: 14px 14px 10px;
  box-shadow: var(--shadow); border: 1.5px solid var(--border);
}
.source-input {
  width: 100%; border: none; outline: none; font-family: var(--font); font-size: .9rem;
  color: var(--text); resize: none; background: transparent; line-height: 1.5;
}
.source-input::placeholder { color: var(--muted); }
.input-bottom { display: flex; align-items: center; justify-content: space-between; }
.input-icons { display: flex; gap: 6px; align-items: center; }
.input-icon-btn { background: none; border: none; cursor: pointer; display: flex; align-items: center; transition: opacity .15s; opacity: 1; }
.input-icon-btn:hover { opacity: .7; }
.send-btn {
  width: 40px; height: 40px; border-radius: 50%; background: var(--green);
  border: none; cursor: pointer; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; transition: background .15s;
}
.send-btn:hover { background: #00e8a8; }
.send-btn svg { stroke: #1a1a1a; }
.send-btn:disabled { background: #aaa; cursor: not-allowed; }

/* ── Buttons ── */
.bold { font-weight: 800; }
.btn-dark {
  background: var(--text); color: #fff; border: none; border-radius: var(--radius-md);
  padding: 10px 18px; font-size: .88rem; font-weight: 700; cursor: pointer;
  font-family: var(--font); transition: background .15s;
}
.btn-dark:hover { background: #333; }
.btn-dark:disabled { background: #aaa; cursor: not-allowed; }
.btn-full { width: 100%; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.modal-card {
  background: var(--card); border-radius: var(--radius-lg); padding: 28px;
  width: min(640px, 90vw); box-shadow: 0 8px 40px rgba(0,0,0,.18);
  display: flex; flex-direction: column; gap: 14px;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 1rem; }
.modal-textarea { width: 100%; min-height: 300px; border: 1.5px solid var(--border); border-radius: var(--radius-md); padding: 14px; font-family: var(--font); font-size: .9rem; line-height: 1.65; resize: vertical; outline: none; color: var(--text); }
.modal-textarea:focus { border-color: var(--text); }

/* ── Mobile topbar (hidden on desktop) ── */
.mobile-topbar { display: none; }
.sidebar-close-btn { display: none; }
.sidebar-overlay { display: none; }

/* ── RESPONSIVE — mobile ── */
@media (max-width: 768px) {

  /* Mobile top bar */
  .mobile-topbar {
    display: flex; align-items: center; justify-content: space-between;
    position: fixed; top: 0; left: 0; right: 0; z-index: 90;
    height: 52px; padding: 0 16px;
    background: rgba(255,255,255,0.88);
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
    border-bottom: 1px solid rgba(228,228,228,.6);
  }
  .mob-menu-btn, .mob-new-btn {
    background: none; border: none; cursor: pointer;
    display: flex; align-items: center; padding: 6px; color: var(--text);
    border-radius: var(--radius-sm);
  }
  .mob-menu-btn:hover, .mob-new-btn:hover { background: rgba(0,0,0,.06); }
  .mob-logo { font-size: 1rem; color: #002D20; }

  /* Sidebar overlay */
  .sidebar-overlay {
    display: block;
    position: fixed; inset: 0; z-index: 95;
    background: rgba(0,0,0,.35);
  }

  /* Sidebar close button */
  .sidebar-close-btn {
    display: flex; align-items: center; justify-content: center;
    margin-left: auto; background: none; border: none; cursor: pointer;
    padding: 4px; color: var(--muted); border-radius: 6px;
  }
  .sidebar-close-btn:hover { background: rgba(0,0,0,.07); color: var(--text); }

  /* Sidebar becomes a full-height drawer */
  .layout { display: block; padding-top: 52px; }

  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 280px; z-index: 100;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,.12);
  }
  .sidebar.sidebar-open { transform: translateX(0); }

  /* Main fills full width */
  .main {
    height: calc(100vh - 52px);
    width: 100%;
  }

  /* Cards: single column */
  .cards-grid { grid-template-columns: 1fr; gap: 16px; }
  .cards-area { padding: 16px 14px 12px; }

  /* Input bar */
  .input-bar { padding: 8px 14px 16px; }

  /* Cards */
  .trans-card { padding: 16px; }
  .card-textarea { min-height: 120px; }

  /* Hide desktop logo icon in sidebar (already have mob-logo) */
  .sidebar-logo .logo-icon { display: flex; }
  .sidebar-logo .logo-text { display: flex; }

  /* Login card */
  .login-card { width: 90vw; padding: 32px 24px; }

  /* Modal */
  .modal-card { width: 95vw; padding: 20px; }
  .modal-textarea { min-height: 200px; }
}
