:root {
  --logo-bg: #f5f5f5; /* light mode background */
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: #f5f5f5;
  color: #333;
  line-height: 1.6;
  min-height: 100vh;
  padding-bottom: 50px;
}

body.dark-mode {
  background: #1a1a1a;
  color: #e0e0e0;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

header {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  margin-bottom: 20px;
  overflow: hidden;
}

body.dark-mode header {
  background: #2a2a2a;
}

/* Header layout */
.app-header {
  width: 100%;
}

.header-toggle {
  display: flex;
  align-items: center;
  width: 100%;
  border: none;
  background: none;
  cursor: pointer;
  padding: 10px;
}

.header-left {
  background: var(--logo-bg);
  padding: 5px;
  border-radius: 12px; /* optional for nicer framing */
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}

.header-center {
  flex: 1; /* this makes the title take remaining space */
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}

/* Logo */
.app-logo {
  width: 90px;
  height: 90px;
  object-fit: contain;
}

/* Title styling */
.app-title {
  font-size: 1.8rem;
  font-weight: bold;
  white-space: nowrap;
}

/* Toggle icon on the right */
.toggle-icon {
  font-size: 1.2rem;
  margin-left: 8px;
}

.header-toggle:hover {
  background: rgba(0,0,0,0.05);
}

body.dark-mode .header-toggle:hover {
  background: rgba(255,255,255,0.05);
}

.header-content {
  padding: 0 20px 20px;
  max-height: 800px;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
}

.header-content.collapsed {
  max-height: 0;
  padding: 0 20px;
}

.auth-view {
  margin-bottom: 15px;
}

.nick-input {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.nick-input input[type="text"] {
  flex: 2;
  min-width: 150px;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

.nick-input input[type="password"] {
  flex: 1 1 100%;
  min-width: 150px;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

body.dark-mode .nick-input input {
  background: #333;
  border-color: #444;
  color: #e0e0e0;
}

.generate-btn {
  padding: 10px 15px;
  background: #6c757d;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
}

.generate-btn:hover:not(:disabled) {
  background: #5a6268;
}

.primary-btn {
  flex: 1;
  min-width: 120px;
  padding: 10px 20px;
  background: #007bff;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
}

.primary-btn:hover:not(:disabled) {
  background: #0056b3;
}

.primary-btn:disabled {
  background: #6c757d;
  cursor: not-allowed;
  opacity: 0.6;
}

.link-btn {
  background: none;
  border: none;
  color: #007bff;
  cursor: pointer;
  font-size: 14px;
  text-decoration: underline;
  padding: 5px 0;
}

.link-btn:hover {
  color: #0056b3;
}

body.dark-mode .link-btn {
  color: #4da3ff;
}

body.dark-mode .link-btn:hover {
  color: #80bdff;
}

.nick-display {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 15px;
  margin-bottom: 15px;
}

body.dark-mode .nick-display {
  background: #333;
  border-color: #444;
}

.current-nick-info {
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.label {
  font-size: 14px;
  color: #666;
}

body.dark-mode .label {
  color: #999;
}

.nick-value {
  font-size: 16px;
  font-weight: bold;
  color: #007bff;
}

body.dark-mode .nick-value {
  color: #4da3ff;
}

.nick-status {
  font-size: 12px;
  color: #666;
}

body.dark-mode .nick-status {
  color: #999;
}

.nick-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.nick-actions input[type="password"] {
  flex: 1 1 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  margin-bottom: 5px;
}

body.dark-mode .nick-actions input[type="password"] {
  background: #2a2a2a;
  border-color: #444;
  color: #e0e0e0;
}

.register-btn {
  padding: 8px 16px;
  background: #28a745;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
}

.register-btn:hover {
  background: #218838;
}

.secondary-btn {
  padding: 8px 16px;
  background: #6c757d;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
}

.secondary-btn:hover {
  background: #5a6268;
}

.info-box {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 15px;
  margin-top: 15px;
}

body.dark-mode .info-box {
  background: #333;
  border-color: #444;
}

.hint-text {
  font-size: 14px;
  color: #666;
  margin-bottom: 10px;
}

.hint-text:last-child {
  margin-bottom: 0;
}

body.dark-mode .hint-text {
  color: #999;
}

#status {
  margin-top: 10px;
}

.status {
  padding: 10px;
  border-radius: 4px;
  font-size: 14px;
}

.status.success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.status.error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.post-form {
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  margin-bottom: 20px;
}

body.dark-mode .post-form {
  background: #2a2a2a;
}

.post-form textarea {
  width: 100%;
  min-height: 100px;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 10px;
}

body.dark-mode .post-form textarea {
  background: #333;
  border-color: #444;
  color: #e0e0e0;
}

.post-form button {
  padding: 10px 20px;
  background: #28a745;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.post-form button:hover {
  background: #218838;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 15px;
  min-height: 200px;
}

.message {
  background: white;
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

body.dark-mode .message {
  background: #2a2a2a;
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 10px;
}

.message-nick {
  font-weight: bold;
  color: #007bff;
  font-size: 14px;
}

.registered-badge {
  color: #4CAF50;
  font-weight: bold;
  margin-left: 4px;
  font-size: x-small;
}

body.dark-mode .message-nick {
  color: #4da3ff;
  font-size: 14px;
}

.message-time {
  font-size: 12px;
  color: #666;
}

body.dark-mode .message-time {
  color: #999;
}

.edited-indicator {
  font-style: italic;
  color: #999;
  font-size: 11px;
}

.deleted-nick {
  color: #999 !important;
  font-style: italic;
}

.deleted-content {
  color: #999;
  font-style: italic;
}

.message-content {
  margin-bottom: 10px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.message-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.message-actions button {
  padding: 6px 12px;
  background: #f0f0f0;
  color: #333;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  user-select: none;
}

body.dark-mode .message-actions button {
  background: #444;
  color: #e0e0e0;
}

.message-actions button:hover {
  background: #e0e0e0;
}

body.dark-mode .message-actions button:hover {
  background: #555;
}

.toggle-replies-button {
  background: #6c757d !important;
  color: white !important;
}

.toggle-replies-button:hover {
  background: #5a6268 !important;
}

.delete-button {
  background: #dc3545 !important;
  color: white !important;
}

.delete-button:hover {
  background: #c82333 !important;
}

.replies {
  margin-top: 15px;
  margin-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.replies.hidden {
  display: none;
}

.reply {
  background: #f8f9fa;
  padding: 12px;
  border-radius: 6px;
  border-left: 3px solid #007bff;
}

body.dark-mode .reply {
  background: #333;
  border-left-color: #4da3ff;
}

.reply-box {
  margin-top: 15px;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 6px;
}

body.dark-mode .reply-box {
  background: #333;
}

.reply-input {
  width: 100%;
  min-height: 60px;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 10px;
}

body.dark-mode .reply-input {
  background: #2a2a2a;
  border-color: #444;
  color: #e0e0e0;
}

.reply-box-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.reply-box-actions button {
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.cancel-reply-button {
  background: #6c757d;
  color: white;
}

.cancel-reply-button:hover {
  background: #5a6268;
}

.submit-reply-button {
  background: #28a745;
  color: white;
}

.submit-reply-button:hover {
  background: #218838;
}

.edit-box {
  margin: 10px 0;
}

.edit-input {
  width: 100%;
  min-height: 80px;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 10px;
}

body.dark-mode .edit-input {
  background: #333;
  border-color: #444;
  color: #e0e0e0;
}

.edit-box-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.edit-box-actions button {
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.cancel-edit-button {
  background: #6c757d;
  color: white;
}

.cancel-edit-button:hover {
  background: #5a6268;
}

.submit-edit-button {
  background: #007bff;
  color: white;
}

.submit-edit-button:hover {
  background: #0056b3;
}

.delete-confirm {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px;
  background: #fff3cd;
  border-radius: 4px;
  margin-top: 10px;
}

body.dark-mode .delete-confirm {
  background: #664d03;
}

.delete-confirm-text {
  flex: 1;
  font-weight: bold;
  color: #856404;
}

body.dark-mode .delete-confirm-text {
  color: #ffda6a;
}

.delete-confirm button {
  padding: 6px 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.cancel-delete-button {
  background: #6c757d;
  color: white;
}

.cancel-delete-button:hover {
  background: #5a6268;
}

.confirm-delete-button {
  background: #dc3545;
  color: white;
}

.confirm-delete-button:hover {
  background: #c82333;
}

.loading {
  text-align: center;
  padding: 20px;
  color: #666;
  min-height: 60px;
}

body.dark-mode .loading {
  color: #999;
}

@media (max-width: 600px) {
  .container {
    padding: 10px;
  }
  
  /* Make header content stacked instead of horizontal */
  .app-header {
    flex-direction: column;
    align-items: stretch;
  }

  .header-toggle {
    padding: 12px 15px;
    font-size: 16px;
  }

  .header-left,
  .header-center,
  .header-right {
    justify-content: center;
    margin-bottom: 8px;
  }

  .app-logo {
    width: 60px;
    height: 60px;
  }

  .app-title {
    font-size: 1.4rem;
    text-align: center;
  }

  /* Collapse the arrow icon smaller */
  .toggle-icon {
    font-size: 1rem;
    margin-left: 5px;
  }

  .nick-input {
    flex-direction: column;
  }
  
  .nick-input input,
  .nick-input button {
    width: 100%;
    flex: 1 1 auto;
  }
  
  .nick-actions {
    flex-direction: column;
  }
  
  .nick-actions button {
    width: 100%;
  }
  
  .replies {
    margin-left: 10px;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --logo-bg: #8e8d8d;
  }
}

/* Default (light mode) */
.app-title {
  color: #222; /* lub #000, jak wolisz */
}

.toggle-icon {
  color: #555;
}

/* Dark mode */
body.dark-mode .app-title {
  color: #fff;
}

body.dark-mode .toggle-icon {
  color: #ccc;
}