/* ============================================================
   Czat v2 – Spring / Easter Theme
   ============================================================
   All colours, shadows and radii are driven by CSS variables
   defined in :root so the entire palette can be changed from
   one place.
   ============================================================ */

@import url("open-iconic/font/css/open-iconic-bootstrap.min.css");

/* ── 1. Design tokens ────────────────────────────────────── */
:root {
  /* Primary green palette */
  --c-primary: #3d8b5e;
  --c-primary-dark: #2e6b48;
  --c-primary-light: #6bb38e;
  --c-primary-xlight: #ebf5ef;

  /* Warm spring /Easter accent */
  --c-accent: #e8a045;
  --c-accent-light: #fff3dc;

  /* Backgrounds */
  --c-bg: #f4faf6;
  --c-surface: #ffffff;
  --c-surface-2: #f0f7f2;

  /* Text */
  --c-text: #1a2e24;
  --c-text-muted: #6a8f7a;
  --c-text-inv: #ffffff;

  /* Borders */
  --c-border: #c5ddc9;
  --c-border-light: #e0efe3;

  /* Status indicators */
  --c-online: #4caf50;
  --c-offline: #bdbdbd;
  --c-unread: #ef5350;

  /* Message bubbles */
  --c-msg-mine: #d4edda;
  --c-msg-mine-border: #a8d5b7;
  --c-msg-other: #fff8e7;
  --c-msg-other-border: #e8ddb9;

  /* Shadows */
  --shadow-xs: 0 1px 3px rgba(61, 139, 94, 0.08);
  --shadow-sm: 0 2px 8px rgba(61, 139, 94, 0.12);
  --shadow-md: 0 4px 16px rgba(61, 139, 94, 0.16);
  --shadow-lg: 0 8px 32px rgba(61, 139, 94, 0.22);

  /* Border radii */
  --r-sm: 6px;
  --r-md: 12px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-pill: 100px;

  /* Layout */
  --topbar-h: 60px;
  --sidebar-w: 260px;

  /* Typography */
  --font: "Poppins", sans-serif;
}

/* ── 2. Base reset ───────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: var(--font);
  background-color: var(--c-bg);
  color: var(--c-text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1:focus {
  outline: none;
}

/* ── 3. Utility classes ──────────────────────────────────── */
.bg-primary-czat {
  background-color: var(--c-primary) !important;
}
.bg-surface-2 {
  background-color: var(--c-surface-2) !important;
}
.text-primary-czat {
  color: var(--c-primary) !important;
}
.text-muted-czat {
  color: var(--c-text-muted) !important;
}
.border-czat {
  border-color: var(--c-border) !important;
}

/* ── 4. Authentication pages (Login / Register) ──────────── */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: linear-gradient(
    135deg,
    var(--c-primary-xlight) 0%,
    #fefdf8 50%,
    var(--c-accent-light) 100%
  );
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--c-surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.auth-card__header {
  background: linear-gradient(135deg, var(--c-primary-dark), var(--c-primary));
  padding: 2rem 2rem 1.5rem;
  text-align: center;
}

.auth-card__logo {
  width: 56px;
  height: 56px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: var(--r-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin-bottom: 0.75rem;
}

.auth-card__title {
  color: var(--c-text-inv);
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}

.auth-card__subtitle {
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.85rem;
  margin: 0.25rem 0 0;
}

.auth-card__body {
  padding: 1.75rem 2rem;
}

.auth-card__footer {
  padding: 0.75rem 2rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--c-border-light);
}

/* ── 5. Form controls ────────────────────────────────────── */
.form-label {
  font-weight: 500;
  color: var(--c-text);
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}

.form-control {
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 0.55rem 0.85rem;
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--c-text);
  background: var(--c-surface);
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.form-control:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(61, 139, 94, 0.15);
  outline: none;
}

.form-control::placeholder {
  color: var(--c-text-muted);
}

.valid.modified:not([type="checkbox"]) {
  border-color: var(--c-primary-light);
}

.invalid {
  border-color: var(--c-unread) !important;
}

.validation-message {
  color: var(--c-unread);
  font-size: 0.78rem;
  margin-top: 0.25rem;
}

/* ── 6. Buttons ──────────────────────────────────────────── */
.btn {
  font-family: var(--font);
  font-weight: 500;
  border-radius: var(--r-pill);
  padding: 0.45rem 1.2rem;
  font-size: 0.875rem;
  transition:
    background-color 0.18s,
    transform 0.1s,
    box-shadow 0.18s;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

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

.btn-primary,
.btn-czat-primary {
  background-color: var(--c-primary);
  color: var(--c-text-inv);
  box-shadow: var(--shadow-xs);
}

.btn-primary:hover,
.btn-czat-primary:hover {
  background-color: var(--c-primary-dark);
  box-shadow: var(--shadow-sm);
  color: var(--c-text-inv);
}

.btn-outline-czat {
  background: transparent;
  border: 1.5px solid var(--c-primary);
  color: var(--c-primary);
}

.btn-outline-czat:hover {
  background-color: var(--c-primary-xlight);
  color: var(--c-primary-dark);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--r-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--c-text-muted);
  cursor: pointer;
  transition:
    background-color 0.15s,
    color 0.15s;
}

.btn-icon:hover {
  background-color: var(--c-primary-xlight);
  color: var(--c-primary);
}

.btn-danger-soft {
  background-color: #fdecea;
  color: #c62828;
  border: none;
}

.btn-danger-soft:hover {
  background-color: #f8c0bc;
  color: #b71c1c;
}

.btn-accent {
  background-color: var(--c-accent);
  color: var(--c-text-inv);
}

.btn-accent:hover {
  background-color: #d08a30;
  color: var(--c-text-inv);
}

/* ── 7. Chat app shell ───────────────────────────────────── */
.chat-shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Top bar */
.chat-topbar {
  height: var(--topbar-h);
  background: linear-gradient(135deg, var(--c-primary-dark), var(--c-primary));
  color: var(--c-text-inv);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  gap: 1rem;
  z-index: 10;
}

.chat-topbar__logo {
  font-size: 1.25rem;
  font-weight: 700;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chat-topbar__logo-icon {
  width: 34px;
  height: 34px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--r-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.chat-topbar__user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  margin-left: auto;
}

.chat-topbar__badge {
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--r-pill);
  padding: 0.2rem 0.65rem;
  font-size: 0.78rem;
}

/* Body */
.chat-body {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* ── 8. Panels (chats list / users list) ─────────────────── */
.panel {
  width: 240px;
  min-width: 200px;
  background: var(--c-surface);
  border-right: 1px solid var(--c-border-light);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.panel--right {
  border-right: none;
  border-left: 1px solid var(--c-border-light);
}

.panel__header {
  padding: 0.85rem 1rem 0.6rem;
  border-bottom: 1px solid var(--c-border-light);
  flex-shrink: 0;
}

.panel__title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
  color: var(--c-text-muted);
  margin: 0 0 0.5rem;
}

.panel__search {
  position: relative;
}

.panel__search-input {
  width: 100%;
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-pill);
  padding: 0.35rem 0.75rem 0.35rem 2rem;
  font-size: 0.82rem;
  background: var(--c-surface-2);
  color: var(--c-text);
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.panel__search-input:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(61, 139, 94, 0.12);
  outline: none;
}

.panel__search-icon {
  position: absolute;
  left: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--c-text-muted);
  font-size: 0.8rem;
  pointer-events: none;
}

.panel__list {
  flex: 1;
  overflow-y: auto;
  padding: 0.25rem 0;
}

.panel__list::-webkit-scrollbar {
  width: 4px;
}
.panel__list::-webkit-scrollbar-track {
  background: transparent;
}
.panel__list::-webkit-scrollbar-thumb {
  background: var(--c-border);
  border-radius: 4px;
}

/* ── 9. User row item ────────────────────────────────────── */
.user-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 1rem;
  cursor: pointer;
  transition: background-color 0.15s;
  position: relative;
}

.user-item:hover {
  background-color: var(--c-primary-xlight);
}

.user-item--active {
  background-color: var(--c-primary-xlight);
  border-right: 3px solid var(--c-primary);
}

.user-item__info {
  flex: 1;
  min-width: 0;
}

.user-item__name {
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--c-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-item__meta {
  font-size: 0.73rem;
  color: var(--c-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── 10. Avatar bubble ───────────────────────────────────── */
.avatar {
  flex-shrink: 0;
  border-radius: var(--r-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--c-text-inv);
  position: relative;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.avatar--sm {
  width: 32px;
  height: 32px;
  font-size: 0.72rem;
}
.avatar--md {
  width: 40px;
  height: 40px;
  font-size: 0.9rem;
}
.avatar--lg {
  width: 52px;
  height: 52px;
  font-size: 1.15rem;
}

.avatar__status {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  border-radius: var(--r-pill);
  border: 2px solid var(--c-surface);
}

.avatar__status--online {
  background-color: var(--c-online);
}
.avatar__status--offline {
  background-color: var(--c-offline);
}

/* ── 11. Message area ────────────────────────────────────── */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--c-bg);
}

.chat-area__empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--c-text-muted);
  text-align: center;
  padding: 2rem;
}

.chat-area__empty-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.chat-area__header {
  height: 56px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border-light);
  padding: 0 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
}

.chat-area__header-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--c-text);
  flex: 1;
}

.chat-area__header-status {
  font-size: 0.75rem;
  color: var(--c-text-muted);
}

.messages-list {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.messages-list::-webkit-scrollbar {
  width: 5px;
}
.messages-list::-webkit-scrollbar-track {
  background: transparent;
}
.messages-list::-webkit-scrollbar-thumb {
  background: var(--c-border);
  border-radius: 4px;
}

/* Message bubbles */
.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 0.4rem;
  max-width: 72%;
}

.msg-row--mine {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.msg-row--other {
  align-self: flex-start;
}

.msg-bubble {
  padding: 0.5rem 0.85rem;
  border-radius: var(--r-lg);
  font-size: 0.875rem;
  line-height: 1.45;
  word-break: break-word;
  position: relative;
  box-shadow: var(--shadow-xs);
}

.msg-bubble--mine {
  background: var(--c-msg-mine);
  border: 1px solid var(--c-msg-mine-border);
  border-bottom-right-radius: var(--r-sm);
  color: var(--c-text);
}

.msg-bubble--other {
  background: var(--c-msg-other);
  border: 1px solid var(--c-msg-other-border);
  border-bottom-left-radius: var(--r-sm);
  color: var(--c-text);
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.25rem;
  font-size: 0.7rem;
  color: var(--c-text-muted);
}

.msg-row--mine .msg-meta {
  justify-content: flex-end;
}

.msg-read-icon {
  font-size: 0.7rem;
  color: var(--c-primary-light);
}

/* Date separator */
.msg-date-sep {
  align-self: center;
  background: var(--c-surface);
  border: 1px solid var(--c-border-light);
  border-radius: var(--r-pill);
  padding: 0.2rem 0.85rem;
  font-size: 0.72rem;
  color: var(--c-text-muted);
  margin: 0.6rem 0;
  box-shadow: var(--shadow-xs);
}

/* Typing indicator */
.typing-indicator {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0.55rem 0.75rem;
  background: var(--c-surface);
  border: 1px solid var(--c-border-light);
  border-radius: var(--r-lg) var(--r-lg) var(--r-lg) var(--r-sm);
  box-shadow: var(--shadow-xs);
  margin-top: 0.3rem;
}

.typing-dot {
  width: 7px;
  height: 7px;
  background: var(--c-primary-light);
  border-radius: 50%;
  animation: typing-bounce 1.2s infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}
.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

/* ── 12. Message input bar ───────────────────────────────── */
.chat-input-bar {
  background: var(--c-surface);
  border-top: 1px solid var(--c-border-light);
  padding: 0.65rem 0.85rem;
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  flex-shrink: 0;
}

.chat-input-bar__field {
  flex: 1;
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-xl);
  padding: 0.5rem 1rem;
  font-family: var(--font);
  font-size: 0.875rem;
  resize: none;
  min-height: 40px;
  max-height: 120px;
  overflow-y: auto;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
  color: var(--c-text);
  background: var(--c-surface-2);
}

.chat-input-bar__field:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(61, 139, 94, 0.12);
  outline: none;
  background: var(--c-surface);
}

.chat-input-bar__counter {
  font-size: 0.7rem;
  color: var(--c-text-muted);
  text-align: right;
  flex-shrink: 0;
  align-self: flex-end;
  padding-bottom: 0.5rem;
  min-width: 42px;
}

.chat-input-bar__counter--warn {
  color: var(--c-accent);
}
.chat-input-bar__counter--over {
  color: var(--c-unread);
}

.btn-send {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--r-pill);
  background: var(--c-primary);
  color: var(--c-text-inv);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition:
    background-color 0.18s,
    transform 0.1s;
  box-shadow: var(--shadow-sm);
}

.btn-send:hover {
  background-color: var(--c-primary-dark);
}
.btn-send:active {
  transform: scale(0.92);
}
.btn-send:disabled {
  background-color: var(--c-border);
  cursor: not-allowed;
  box-shadow: none;
}

/* Emoji picker toggle */
.btn-emoji {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--r-pill);
  background: transparent;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  transition: transform 0.15s;
  align-self: flex-end;
  flex-shrink: 0;
  color: var(--c-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.btn-emoji:hover {
  transform: scale(1.2);
  color: var(--c-accent);
}

/* Emoji picker panel */
.emoji-picker {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: 0.5rem;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  max-width: 260px;
  margin-bottom: 0.5rem;
}

.emoji-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    background-color 0.12s,
    transform 0.1s;
  line-height: 1;
}

.emoji-btn:hover {
  background: var(--c-primary-xlight);
  transform: scale(1.2);
}

/* ── 13. Loading spinner ─────────────────────────────────── */
.loading-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  color: var(--c-text-muted);
  font-size: 0.82rem;
}

/* ── 14. Alert / toast strip ─────────────────────────────── */
.alert-strip {
  padding: 0.45rem 0.85rem;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid transparent;
  flex-shrink: 0;
}

.alert-strip--danger {
  background: #fdecea;
  color: #c62828;
  border-color: #f5c6c6;
}
.alert-strip--info {
  background: var(--c-accent-light);
  color: #7a5700;
  border-color: #e8c97b;
}
.alert-strip--success {
  background: var(--c-primary-xlight);
  color: var(--c-primary-dark);
  border-color: var(--c-border);
}

/* ── 15. Scrollbar global ────────────────────────────────── */
*::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: var(--c-border);
  border-radius: 4px;
}

/* ── 16. Blazor framework error UI ───────────────────────── */
#blazor-error-ui {
  background: #fff3cd;
  border-top: 2px solid var(--c-accent);
  bottom: 0;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.12);
  display: none;
  left: 0;
  padding: 0.6rem 1.25rem 0.7rem;
  position: fixed;
  width: 100%;
  z-index: 1000;
  font-size: 0.875rem;
}

#blazor-error-ui .dismiss {
  cursor: pointer;
  position: absolute;
  right: 0.75rem;
  top: 0.45rem;
  font-size: 1.1rem;
}

.blazor-error-boundary {
  background: #b32121;
  padding: 1rem 1rem 1rem 3.7rem;
  color: white;
  border-radius: var(--r-md);
}

.blazor-error-boundary::after {
  content: "Wystąpił błąd.";
}

/* ── 17. Responsive layout ───────────────────────────────── */
@media (max-width: 768px) {
  .panel {
    width: 180px;
    min-width: 160px;
  }

  .panel__search-input {
    font-size: 0.78rem;
  }

  .msg-row {
    max-width: 85%;
  }

  .chat-topbar__badge {
    display: none;
  }
}

@media (max-width: 576px) {
  /* On mobile, show only the active view */
  .panel {
    display: none;
  }
  .panel--visible-mobile {
    display: flex;
  }
  .chat-area {
    display: flex;
  }
}
