/* =========
   VARIABLES
   ========= */
:root {
  --la593-yellow: #ffdd00;
  --bg: #f3f4f6;
  --bg-alt: #ffffff;
  --border-subtle: #e5e7eb;
  --text-main: #111827;
  --text-muted: #6b7280;
  --accent: #111827;
  --danger: #ef4444;
  --success: #10b981;
  --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.12);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-full: 999px;
}

/* =========
   GLOBAL
   ========= */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
  color: var(--text-main);
  background: radial-gradient(circle at top left, #fefce8, #f9fafb);
}

.hidden {
  display: none !important;
}

/* =========
   LOGIN
   ========= */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 24px;
  box-shadow: var(--shadow-soft);
  padding: 28px 26px 24px;
  border: 1px solid rgba(17, 24, 39, 0.04);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.logo-dot {
  width: 26px;
  height: 26px;
  border-radius: 9px;
  background: linear-gradient(135deg, #111827, var(--la593-yellow));
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

.logo-text {
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-size: 15px;
}

.login-card h1 {
  font-size: 22px;
  margin: 0 0 6px;
}

.login-subtitle {
  margin: 0 0 22px;
  font-size: 14px;
  color: var(--text-muted);
}

.login-card label {
  display: block;
  font-size: 13px;
  margin-bottom: 10px;
  color: #4b5563;
}

.login-card input {
  width: 100%;
  padding: 10px 11px;
  margin-top: 4px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  font-size: 14px;
  outline: none;
  transition: border 0.15s ease, box-shadow 0.15s ease;
}

.login-card input:focus {
  border-color: #111827;
  box-shadow: 0 0 0 1px rgba(17, 24, 39, 0.1);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  margin-top: 6px;
  border-radius: var(--radius-full);
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #111827, #000000);
  color: white;
  font-weight: 600;
  font-size: 14px;
  transition: transform 0.1s ease, box-shadow 0.1s ease, opacity 0.1s ease;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.32);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.2);
}

.login-hint {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

/* =========
   APP LAYOUT
   ========= */

#app-shell {
  display: grid;
  grid-template-columns: 280px 320px minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  background: #020617;
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
  padding: 16px 16px 12px;
  border-right: 1px solid rgba(148, 163, 184, 0.25);
}

.sidebar-header {
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-sub {
  font-size: 11px;
  color: #9ca3af;
}

.sidebar-section {
  margin-top: 14px;
}

.sidebar-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #9ca3af;
  margin: 0 0 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(148, 163, 184, 0.7);
}

.status-pill.online {
  border-color: rgba(52, 211, 153, 0.75);
  color: #bbf7d0;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #22c55e;
}

.status-caption {
  margin: 6px 0 0;
  font-size: 11px;
  color: #9ca3af;
}

.chip {
  display: inline-flex;
  padding: 4px 10px;
  margin: 0 6px 6px 0;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: transparent;
  color: #e5e7eb;
  font-size: 11px;
  cursor: pointer;
}

.chip-active {
  background: #fefce8;
  color: #111827;
  border-color: #facc15;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid rgba(148, 163, 184, 0.25);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.user-email {
  font-size: 12px;
  color: #e5e7eb;
  word-break: break-all;
}

.btn-ghost {
  border-radius: var(--radius-full);
  padding: 6px 10px;
  font-size: 12px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.5);
  color: #e5e7eb;
  cursor: pointer;
}

/* Inbox (columna central) */
.inbox {
  background: #f9fafb;
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
}

.inbox-header {
  padding: 14px 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.inbox-header h2 {
  font-size: 16px;
  margin: 0 0 2px;
}

.muted {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}

.inbox-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-icon {
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-alt);
  width: 30px;
  height: 30px;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.inbox-search {
  padding: 0 16px 10px;
}

.inbox-search input {
  width: 100%;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  padding: 8px 12px;
  font-size: 13px;
}

.thread-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 12px;
}

.thread-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 9px 10px;
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.05s ease;
}

.thread-item:hover {
  background: #eef2ff;
}

.thread-active {
  background: #e0f2fe;
}

.thread-main {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: calc(100% - 80px);
}

.thread-avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: #111827;
  color: white;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.thread-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.thread-name {
  font-size: 13px;
  font-weight: 600;
}

.thread-time {
  font-size: 11px;
  color: var(--text-muted);
}

.thread-preview {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}

.thread-tags {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
}

.tag {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
}

.tag-open {
  background: #ecfdf3;
  color: #15803d;
  border-color: #bbf7d0;
}

.tag-done {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

/* Chat (columna derecha) */
.chat {
  display: flex;
  flex-direction: column;
  background: #f3f4f6;
}

.chat-header {
  padding: 12px 16px;
  background: #ffffff;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-contact {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-avatar {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: #111827;
  color: white;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.chat-name {
  font-size: 14px;
  font-weight: 600;
}

.chat-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.btn-outline {
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  padding: 6px 12px;
  font-size: 12px;
  background: #ffffff;
  cursor: pointer;
}

.chat-messages {
  flex: 1;
  padding: 14px 16px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg-row {
  display: flex;
}

.msg {
  max-width: 70%;
  padding: 9px 10px 6px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.4;
  position: relative;
}

.msg-in {
  background: #ffffff;
  border-bottom-left-radius: 4px;
  margin-right: auto;
}

.msg-out {
  background: #111827;
  color: white;
  border-bottom-right-radius: 4px;
  margin-left: auto;
}

.msg-bot {
  background: #fefce8;
  border: 1px solid #facc15;
  margin-right: auto;
  border-bottom-left-radius: 4px;
}

.msg-time {
  display: block;
  font-size: 10px;
  margin-top: 4px;
  color: rgba(55, 65, 81, 0.8);
}

.msg-out .msg-time {
  color: rgba(209, 213, 219, 0.9);
}

.chat-input-area {
  padding: 8px 12px 10px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(243, 244, 246, 0.96);
  backdrop-filter: blur(8px);
}

.chat-toolbar {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-input-wrapper {
  flex: 1;
}

.chat-input-wrapper textarea {
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--border-subtle);
  padding: 8px 10px;
  font-size: 13px;
  resize: none;
  min-height: 38px;
  max-height: 100px;
}

.btn-send {
  min-width: 80px;
}

/* =========
   RESPONSIVE
   ========= */

@media (max-width: 960px) {
  #app-shell {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .chat {
    display: none; /* en móvil podríamos alternar más adelante */
  }
}

@media (max-width: 720px) {
  #app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .inbox {
    border-right: none;
  }
}
