/* ============================================================
   Discord Ticket Portal — Modern Dark Blue Theme
   Clean • Professional • Smooth
   ============================================================ */

:root {
  --bg-deep: #060a1a;
  --bg-mid: #0c1228;
  --blue-900: #0d1b4a;
  --blue-700: #1a2a6c;
  --blue-500: #2b4acb;
  --blue-400: #4a6cf7;
  --blue-300: #7b93ff;
  --accent: #5b8aff;
  --text: #e8ecff;
  --text-muted: #9aa3c7;
  --glass: rgba(16, 24, 56, 0.72);
  --glass-border: rgba(120, 140, 255, 0.18);
  --success: #3dd68c;
  --danger: #ff6b8a;
  --radius: 16px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* ---------- Background layers ---------- */
.bg-layer {
  position: fixed;
  inset: 0;
  background: linear-gradient(
    160deg,
    #050814 0%,
    #0a1028 25%,
    #0f1a40 50%,
    #12204e 75%,
    #0a1535 100%
  );
  z-index: -2;
}

.bg-fade {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(40, 70, 180, 0.22) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 80%, rgba(30, 50, 140, 0.18) 0%, transparent 50%),
    radial-gradient(ellipse 50% 40% at 10% 70%, rgba(50, 80, 200, 0.12) 0%, transparent 50%);
  z-index: -1;
  pointer-events: none;
}

/* ---------- Pixel Cat Canvas ---------- */
#pixel-cat {
  position: fixed;
  bottom: 18px;
  left: 0;
  width: 64px;
  height: 48px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  z-index: 1;
  pointer-events: none;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
}

/* ---------- App layout ---------- */
#app {
  width: 100%;
  max-width: 480px;
  padding: 24px;
  z-index: 10;
}

.view {
  display: none;
  animation: fadeIn 0.35s ease;
}

.view.active {
  display: block;
}

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

/* ---------- Glass card ---------- */
.glass {
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
}

.chat-card {
  display: flex;
  flex-direction: column;
  height: min(620px, 85vh);
  padding: 0;
  overflow: hidden;
}

/* ---------- Auth / Create views ---------- */
.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.logo-icon {
  font-size: 28px;
  color: var(--blue-300);
  filter: drop-shadow(0 0 12px rgba(91, 138, 255, 0.5));
}

.logo h1 {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 28px;
  line-height: 1.45;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.header-row h2 {
  font-size: 1.35rem;
  font-weight: 600;
}

/* ---------- Forms ---------- */
.input-group {
  margin-bottom: 18px;
}

.input-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

.optional {
  font-weight: 400;
  opacity: 0.7;
}

input[type="text"],
input[type="email"],
textarea {
  width: 100%;
  background: rgba(8, 12, 32, 0.65);
  border: 1px solid rgba(100, 120, 220, 0.25);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--blue-400);
  box-shadow: 0 0 0 3px rgba(74, 108, 247, 0.2);
}

textarea {
  resize: vertical;
  min-height: 100px;
}

.hint {
  margin-top: 18px;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  opacity: 0.85;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s, box-shadow 0.2s;
  outline: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn.primary {
  width: 100%;
  background: linear-gradient(135deg, var(--blue-500), var(--blue-400));
  color: #fff;
  padding: 13px 20px;
  box-shadow: 0 4px 18px rgba(74, 108, 247, 0.35);
}

.btn.primary:hover {
  background: linear-gradient(135deg, #3a5ce0, #5a7cff);
  box-shadow: 0 6px 24px rgba(74, 108, 247, 0.45);
}

.btn.ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 6px 10px;
  font-size: 1.1rem;
}

.btn.ghost:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.btn.small {
  font-size: 0.85rem;
  padding: 6px 12px;
}

.send-btn {
  width: auto !important;
  padding: 10px 14px !important;
  border-radius: 10px;
}

/* ---------- Chat view ---------- */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--glass-border);
  background: rgba(10, 16, 40, 0.5);
}

.ticket-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 10px var(--success);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.ticket-info h3 {
  font-size: 1rem;
  font-weight: 600;
}

.ticket-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(100, 120, 220, 0.3) transparent;
}

.messages::-webkit-scrollbar {
  width: 6px;
}
.messages::-webkit-scrollbar-thumb {
  background: rgba(100, 120, 220, 0.35);
  border-radius: 3px;
}

.msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.92rem;
  line-height: 1.45;
  animation: msgIn 0.25s ease;
}

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

.msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--blue-500), var(--blue-400));
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg.staff {
  align-self: flex-start;
  background: rgba(30, 40, 80, 0.85);
  border: 1px solid rgba(100, 120, 220, 0.2);
  border-bottom-left-radius: 4px;
}

.msg.system {
  align-self: center;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-style: italic;
  max-width: 100%;
  text-align: center;
  padding: 4px 0;
}

.msg .author {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  margin-bottom: 3px;
  opacity: 0.85;
  letter-spacing: 0.02em;
}

.msg.user .author { color: rgba(255,255,255,0.75); }
.msg.staff .author { color: var(--blue-300); }

.message-form {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--glass-border);
  background: rgba(8, 12, 30, 0.55);
}

.message-form input {
  flex: 1;
  background: rgba(8, 12, 32, 0.7);
  border: 1px solid rgba(100, 120, 220, 0.25);
  border-radius: 10px;
  padding: 11px 14px;
  color: var(--text);
  font-size: 0.92rem;
  outline: none;
}

.message-form input:focus {
  border-color: var(--blue-400);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(20, 28, 60, 0.95);
  border: 1px solid var(--glass-border);
  color: var(--text);
  padding: 12px 22px;
  border-radius: 10px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 100;
  box-shadow: var(--shadow);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  border-color: rgba(255, 107, 138, 0.4);
  color: #ffb3c1;
}

/* ---------- Responsive ---------- */
@media (max-width: 520px) {
  #app {
    padding: 16px;
  }
  .glass {
    padding: 24px 20px;
  }
  .chat-card {
    height: min(580px, 88vh);
  }
}
