/* ================================================
   Italo Concierge Test — Theme
   Brand: Italo Treno (Red #D7002A, Dark #1C1C1C)
   ================================================ */

:root {
  --italo-red: #D7002A;
  --italo-red-dark: #A80021;
  --italo-red-light: #FF1A3E;
  --italo-red-muted: rgba(215,0,42,0.08);
  --dark: #1C1C1C;
  --dark-2: #2C2C2C;
  --gray-1: #6C6C6C;
  --gray-2: #9A9A9A;
  --gray-3: #D0D0D0;
  --gray-4: #EBEBEB;
  --gray-5: #F5F5F5;
  --white: #FFFFFF;
  --success: #1A8A4A;
  --success-bg: #E8F6EE;
  --warning: #C17A00;
  --warning-bg: #FFF8E1;
  --error: #C0392B;
  --error-bg: #FDECEA;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.10), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
  --nav-h: 60px;
}

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

html { font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--gray-5);
  color: var(--dark);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--italo-red); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== NAVBAR ===== */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--italo-red);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 24px;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.navbar-brand a {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none;
}

.brand-logo {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--white);
  font-style: italic;
}

.brand-sub {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.75);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-left: 1px solid rgba(255,255,255,0.3);
  padding-left: 10px;
}

.navbar-menu {
  display: flex; align-items: center; gap: 4px;
  list-style: none;
  flex: 1;
}

.navbar-menu a {
  color: rgba(255,255,255,0.88);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.navbar-menu a:hover, .navbar-menu a.active {
  background: rgba(255,255,255,0.18);
  color: var(--white);
}

/* Dropdown */
.nav-dropdown { position: relative; }
.dropdown-toggle { cursor: pointer; }

.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%; left: 0;
  min-width: 180px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  list-style: none;
  padding: 4px 0;
  z-index: 200;
}

.nav-dropdown:hover .dropdown-menu { display: block; }

.dropdown-menu li a {
  display: block;
  color: var(--dark) !important;
  padding: 8px 16px;
  font-size: 0.875rem;
  background: transparent;
}

.dropdown-menu li a:hover { background: var(--gray-4) !important; }

.navbar-user {
  display: flex; align-items: center; gap: 12px;
  margin-left: auto;
}

.username { color: rgba(255,255,255,0.9); font-size: 0.875rem; }

.user-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 20px;
}

.badge-admin { background: var(--dark); color: var(--white); }
.badge-tester { background: rgba(255,255,255,0.2); color: var(--white); border: 1px solid rgba(255,255,255,0.4); }

.btn-logout {
  color: rgba(255,255,255,0.8);
  font-size: 0.8rem;
  border: 1px solid rgba(255,255,255,0.3);
  padding: 4px 12px;
  border-radius: 20px;
  text-decoration: none;
  transition: all 0.15s;
}
.btn-logout:hover { background: rgba(255,255,255,0.15); color: var(--white); text-decoration: none; }

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-top: var(--nav-h);
  flex: 1;
  padding: 32px 24px;
  max-width: 1200px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.main-content.full-height {
  margin-top: 0;
  max-width: 100%;
  padding: 0;
}

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
}

.page-header h1 { font-size: 1.6rem; font-weight: 700; color: var(--dark); }
.page-subtitle { color: var(--gray-1); font-size: 0.9rem; margin-top: 4px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary { background: var(--italo-red); color: var(--white); }
.btn-primary:hover { background: var(--italo-red-dark); color: var(--white); text-decoration: none; }

.btn-ghost {
  background: var(--white);
  color: var(--dark);
  border: 1px solid var(--gray-3);
}
.btn-ghost:hover { background: var(--gray-4); color: var(--dark); text-decoration: none; }

.btn-danger { background: var(--error); color: var(--white); }
.btn-danger:hover { background: #a93226; color: var(--white); text-decoration: none; }

.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; }

/* ===== LOGIN ===== */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--italo-red) 0%, var(--italo-red-dark) 50%, var(--dark) 100%);
  padding: 24px;
}

.login-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 44px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.login-header { text-align: center; margin-bottom: 32px; }

.login-logo {
  font-size: 2.8rem;
  font-weight: 800;
  font-style: italic;
  color: var(--italo-red);
  letter-spacing: -2px;
  line-height: 1;
  margin-bottom: 12px;
}

.login-header h1 { font-size: 1.15rem; font-weight: 600; color: var(--dark); margin-bottom: 6px; }
.login-header p { color: var(--gray-1); font-size: 0.875rem; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--dark-2); margin-bottom: 6px; }

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-3);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: var(--font);
  color: var(--dark);
  background: var(--white);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--italo-red);
  box-shadow: 0 0 0 3px var(--italo-red-muted);
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; }
.form-card { background: var(--white); border-radius: var(--radius-lg); padding: 28px; box-shadow: var(--shadow); max-width: 680px; }

.checkbox-wrap { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.checkbox-wrap input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--italo-red); }
.checkbox-wrap label { font-weight: 400; font-size: 0.875rem; }

.login-form { display: flex; flex-direction: column; gap: 4px; }
.login-form .form-group { margin-bottom: 14px; }

/* ===== ALERTS ===== */
.alert {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 18px;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; }
.alert-error { background: var(--error-bg); color: var(--error); border: 1px solid rgba(192,57,43,0.2); }

/* ===== STATS ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 32px; }

.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex; align-items: center; gap: 16px;
  box-shadow: var(--shadow);
}

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}

.stat-icon svg { width: 22px; height: 22px; }
.icon-chat { background: var(--italo-red-muted); color: var(--italo-red); }
.icon-feedback { background: rgba(26,138,74,0.08); color: var(--success); }

.stat-body { display: flex; flex-direction: column; }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--dark); line-height: 1; }
.stat-label { font-size: 0.8rem; color: var(--gray-1); margin-top: 4px; }

/* ===== SECTIONS ===== */
.section { margin-bottom: 32px; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.section-header h2 { font-size: 1.1rem; font-weight: 600; }
.link-more { font-size: 0.875rem; color: var(--italo-red); }

/* ===== CHAT LIST ===== */
.chats-list { display: flex; flex-direction: column; gap: 8px; }

.chat-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--white);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--dark);
  transition: box-shadow 0.15s, transform 0.1s;
}

.chat-item:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  text-decoration: none;
  color: var(--dark);
}

.chat-item-icon {
  width: 38px; height: 38px;
  background: var(--italo-red-muted);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--italo-red);
  flex-shrink: 0;
}
.chat-item-icon svg { width: 18px; height: 18px; }

.chat-item-body { flex: 1; min-width: 0; }
.chat-item-title { font-weight: 500; font-size: 0.9rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-meta { font-size: 0.78rem; color: var(--gray-1); }

/* ===== STATUS BADGES ===== */
.chat-status {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 20px;
}

.status-active { background: var(--success-bg); color: var(--success); }
.status-ended { background: var(--gray-4); color: var(--gray-1); }

.badge { font-size: 0.72rem; font-weight: 600; padding: 3px 10px; border-radius: 20px; text-transform: uppercase; letter-spacing: 0.05em; }
.badge-admin { background: var(--dark); color: var(--white); }
.badge-tester { background: var(--italo-red-muted); color: var(--italo-red); }
.badge-active { background: var(--success-bg); color: var(--success); }
.badge-inactive { background: var(--gray-4); color: var(--gray-1); }

/* ===== TABLES ===== */
.table-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table thead {
  background: var(--gray-5);
  border-bottom: 1.5px solid var(--gray-4);
}

.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-1);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-4);
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--gray-5); }

.actions-cell { display: flex; gap: 6px; align-items: center; }
.text-muted { color: var(--gray-2); font-size: 0.8rem; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--gray-2);
}

.empty-state svg { width: 48px; height: 48px; margin-bottom: 16px; opacity: 0.4; }
.empty-state p { font-size: 0.95rem; }
.empty-state a { color: var(--italo-red); }

/* ===== CHAT PAGE ===== */
.chat-layout {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--nav-h) - 64px);
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-4);
  background: var(--white);
  flex-shrink: 0;
}

.btn-back {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--gray-1);
  text-decoration: none;
  transition: background 0.15s;
}
.btn-back:hover { background: var(--gray-4); text-decoration: none; }
.btn-back svg { width: 18px; height: 18px; }

.chat-header-info { flex: 1; }
.chat-header-info h2 { font-size: 1rem; font-weight: 600; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #FAFAFA;
}

.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  color: var(--gray-2);
  padding: 40px;
}

.chat-welcome-icon {
  width: 64px; height: 64px;
  background: var(--italo-red-muted);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
  color: var(--italo-red);
}
.chat-welcome-icon svg { width: 32px; height: 32px; }
.chat-welcome h3 { font-size: 1.1rem; font-weight: 600; color: var(--dark); margin-bottom: 8px; }
.chat-welcome p { font-size: 0.9rem; }

/* Messages */
.message { display: flex; flex-direction: column; max-width: 75%; }
.message-customer { align-self: flex-end; align-items: flex-end; }
.message-agent { align-self: flex-start; align-items: flex-start; }
.message-system { align-self: center; align-items: center; max-width: 100%; }

.message-bubble {
  padding: 10px 16px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.55;
  position: relative;
  word-break: break-word;
}

.message-customer .message-bubble {
  background: var(--italo-red);
  color: var(--white);
  border-bottom-right-radius: 4px;
}

.message-agent .message-bubble {
  background: var(--white);
  color: var(--dark);
  border: 1px solid var(--gray-4);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow);
}

.message-system .message-bubble {
  background: var(--gray-4);
  color: var(--gray-1);
  font-size: 0.8rem;
  padding: 6px 14px;
  border-radius: 20px;
}

.message-time {
  font-size: 0.72rem;
  color: var(--gray-2);
  margin-top: 4px;
  padding: 0 4px;
}

/* Message hover feedback button */
.message-actions {
  margin-top: 8px;
  display: none;
}

.message-agent:hover .message-actions,
.message-agent .message-bubble:focus-within .message-actions {
  display: flex;
}

.message-agent .message-bubble:hover .message-actions {
  display: flex;
}

.btn-feedback {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--italo-red);
  background: var(--italo-red-muted);
  border: 1px solid rgba(215,0,42,0.15);
  border-radius: 20px;
  padding: 4px 10px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-feedback:hover { background: rgba(215,0,42,0.14); }
.btn-feedback svg { width: 13px; height: 13px; }

/* Chat Input */
.chat-input-area {
  padding: 14px 20px;
  border-top: 1px solid var(--gray-4);
  background: var(--white);
  flex-shrink: 0;
}

.chat-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--gray-5);
  border: 1.5px solid var(--gray-3);
  border-radius: 24px;
  padding: 8px 8px 8px 16px;
  transition: border-color 0.15s;
}

.chat-input-wrap:focus-within {
  border-color: var(--italo-red);
  box-shadow: 0 0 0 3px var(--italo-red-muted);
}

#chat-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--dark);
  resize: none;
  outline: none;
  max-height: 120px;
  line-height: 1.5;
}

.btn-send {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--italo-red);
  color: var(--white);
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}
.btn-send:hover { background: var(--italo-red-dark); }
.btn-send:disabled { background: var(--gray-3); cursor: not-allowed; }
.btn-send svg { width: 16px; height: 16px; }

#chat-input:disabled { opacity: 0.5; cursor: not-allowed; }

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 2px;
  min-height: 20px;
}
.typing-indicator span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--gray-4, #adb5bd);
  display: inline-block;
  animation: typing-bounce 1.1s ease-in-out infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.18s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.36s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-6px); opacity: 1; }
}

.chat-ended-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  background: var(--gray-5);
  color: var(--gray-1);
  font-size: 0.875rem;
  border-top: 1px solid var(--gray-4);
}
.chat-ended-banner svg { width: 16px; height: 16px; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 16px;
}

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--gray-4);
}

.modal-header h3 { font-size: 1rem; font-weight: 600; }

.modal-close {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--gray-4);
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-1);
  transition: background 0.15s;
  line-height: 1;
}
.modal-close:hover { background: var(--gray-3); }

.modal-body { padding: 20px 24px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding-top: 16px; margin-top: 4px; border-top: 1px solid var(--gray-4); }

.feedback-msg-preview {
  background: var(--gray-5);
  border-left: 3px solid var(--italo-red);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 10px 14px;
  font-size: 0.82rem;
  color: var(--gray-1);
  margin-bottom: 18px;
  max-height: 80px;
  overflow-y: auto;
}

.mb-4 { margin-bottom: 16px; }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.toast-success { background: var(--success); color: var(--white); }
.toast-error { background: var(--error); color: var(--white); }

/* ===== CODE ===== */
code.action-code {
  background: var(--gray-4);
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--dark);
}

/* ===== FOOTER ===== */
.footer {
  background: var(--dark);
  color: rgba(255,255,255,0.45);
  text-align: center;
  padding: 14px;
  font-size: 0.78rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .main-content { padding: 16px; }
  .page-header { flex-direction: column; gap: 12px; }
  .navbar-menu { display: none; }
  .form-row { grid-template-columns: 1fr; }
  .chat-layout { height: calc(100vh - var(--nav-h) - 32px); }
  .message { max-width: 90%; }
  .login-card { padding: 30px 22px; }
  .brand-sub { display: none; }
}
