:root {
  --tm-primary: #667eea;
  --tm-secondary: #764ba2;
  --tm-text: #1f2933;
  --tm-muted: #475569;
  --tm-background: rgba(255, 255, 255, 0.95);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: var(--tm-text);
  /* Glassy gradient background for entire app */
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  min-height: 100vh;
}

body[data-logo-only="true"] {
  position: relative;
}

a {
  text-decoration: none;
  color: inherit;
}

a:hover {
  text-decoration: none;
}

.tm-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.tm-header {
  background: var(--tm-background);
  backdrop-filter: blur(20px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.tm-header.tm-header--logo-only {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  background: transparent;
  box-shadow: none;
  border-bottom: none;
}

.tm-header.tm-header--logo-only .tm-nav {
  justify-content: flex-start;
  padding-top: 1.5rem;
}

.tm-header.tm-header--logo-only .tm-nav-links,
.tm-header.tm-header--logo-only .tm-auth-buttons {
  display: none !important;
}

.tm-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding: 1rem 0;
}

.tm-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
}

.tm-logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(45deg, var(--tm-primary), var(--tm-secondary));
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 6px 18px rgba(102, 126, 234, 0.32);
}

.tm-logo-icon::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  top: 6px;
  left: 6px;
}

.tm-logo-icon::after {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  background: #fff;
  border-radius: 2px;
  bottom: 6px;
  right: 6px;
}

.tm-logo-text {
  font-size: 1.8rem;
  background: linear-gradient(45deg, var(--tm-primary), var(--tm-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tm-nav-links {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin: 0;
  padding: 0;
}

.tm-nav-links a {
  color: #334155;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  transition: all 0.25s ease;
}

.tm-nav-links a:hover {
  background: rgba(102, 126, 234, 0.12);
  color: var(--tm-primary);
  transform: translateY(-1px);
}

.tm-nav-links a.active {
  background: linear-gradient(45deg, var(--tm-primary), var(--tm-secondary));
  color: #fff;
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.28);
}

.tm-auth-buttons {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.btn {
  padding: 0.75rem 1.5rem;
  border-radius: 25px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.8);
  color: var(--tm-text);
  border: 2px solid rgba(102, 126, 234, 0.25);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.25);
}

.btn-primary {
  background: linear-gradient(45deg, var(--tm-primary), var(--tm-secondary));
  color: #fff;
  border: none;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.35);
}

.btn-primary:hover {
  box-shadow: 0 12px 28px rgba(102, 126, 234, 0.45);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.85);
  color: #334155;
  border: 2px solid rgba(102, 126, 234, 0.3);
}

.btn-secondary:hover {
  background: rgba(102, 126, 234, 0.12);
  color: var(--tm-primary);
  border-color: rgba(102, 126, 234, 0.4);
}

@media (max-width: 960px) {
  .tm-nav {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .tm-nav-links {
    flex-wrap: wrap;
    justify-content: center;
  }

  .tm-auth-buttons {
    justify-content: center;
  }
}

@media (max-width: 640px) {
  .tm-logo-text {
    font-size: 1.5rem;
  }

  .tm-nav-links {
    gap: 0.75rem;
  }

  .tm-nav-links a {
    padding: 0.45rem 0.85rem;
  }

  .btn {
    width: 100%;
    max-width: 220px;
  }

  .tm-auth-buttons {
    flex-direction: column;
    gap: 0.75rem;
  }
}

.tm-footer {
  display: none;
  padding: 2rem 1.5rem;
  margin: 0 1.5rem 1.5rem;
}

@media (min-width: 768px) {
  .tm-footer {
    display: block;
  }
}

.tm-footer .tm-container {
  max-width: 1200px;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border-radius: 20px;
  padding: 2.5rem 2rem 1.5rem;
  box-shadow: 0 8px 32px rgba(31, 38, 135, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.tm-footer .footer-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

.tm-footer .footer-section h3 {
  margin-bottom: 1rem;
  color: white;
  font-weight: 600;
}

.tm-footer .footer-section p {
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.938rem;
  line-height: 1.6;
}

.tm-footer .footer-section ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tm-footer .footer-section ul li {
  margin-bottom: 0.5rem;
}

.tm-footer .footer-section ul li a {
  color: rgba(255, 255, 255, 0.75);
  transition: color 0.2s ease;
  font-size: 0.938rem;
}

.tm-footer .footer-section ul li a:hover {
  color: white;
}

.tm-footer .footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  padding-top: 1rem;
  text-align: center;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.875rem;
}

.tm-avatar-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.tm-avatar-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.2s;
}

.tm-avatar-button:hover {
  transform: scale(1.05);
}

.tm-avatar-image {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(45deg, var(--tm-primary), var(--tm-secondary));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.3);
  transition: border-color 0.2s;
}

.tm-avatar-button:hover .tm-avatar-image {
  border-color: rgba(255, 255, 255, 0.6);
}

.tm-avatar-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tm-avatar-label,
.tm-avatar-caret {
  display: none;
}

.tm-avatar-dropdown {
  position: absolute;
  top: calc(100% + 0.75rem);
  right: 0;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  min-width: 200px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease;
  z-index: 1000;
  overflow: hidden;
}

.tm-avatar-dropdown:not([hidden]) {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.tm-avatar-dropdown[hidden] {
  display: none;
}

.tm-avatar-dropdown a,
.tm-avatar-dropdown button {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  color: #1e293b;
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  transition: background 0.2s;
}

.tm-avatar-dropdown a:first-child {
  border-radius: 12px 12px 0 0;
}

.tm-avatar-dropdown button:last-child {
  border-radius: 0 0 12px 12px;
  border-top: 1px solid #e2e8f0;
  color: #ef4444;
}

.tm-avatar-dropdown a:hover,
.tm-avatar-dropdown button:hover {
  background: #f1f5f9;
}

@media (max-width: 640px) {
  .tm-avatar-button {
    padding-right: 0.75rem;
  }
}

/* Loading Spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(102, 126, 234, 0.2);
  border-top-color: var(--tm-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
}

/* Chat Dropdown Menu (Messenger-style) */
.chat-dropdown-menu {
  position: fixed;
  background: white;
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.1);
  min-width: 280px;
  max-width: 320px;
  z-index: 1000;
  padding: 8px 0;
  animation: dropdownFadeIn 0.2s ease-out;
}

@keyframes dropdownFadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dropdown-section {
  padding: 4px 0;
}

.dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 15px;
  color: #1c1e21;
  text-align: left;
  transition: background-color 0.1s;
}

.dropdown-item:hover {
  background-color: #f2f3f5;
}

.dropdown-item.danger {
  color: #dc2626;
}

.dropdown-item.danger:hover {
  background-color: #fee2e2;
}

.dropdown-icon {
  font-size: 18px;
  width: 20px;
  text-align: center;
}

.dropdown-divider {
  height: 1px;
  background: #e4e6eb;
  margin: 4px 0;
}

.settings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  border-bottom: 1px solid #e5e7eb;
}

.settings-item:last-child {
  border-bottom: none;
}

.settings-item h4 {
  margin: 0 0 0.25rem 0;
  font-size: 0.938rem;
  font-weight: 500;
}

.btn-danger {
  background-color: #dc2626;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background-color 0.2s;
}

.btn-danger:hover {
  background-color: #b91c1c;
}

/* ===== Tool Pages Styling (Huddles-style) ===== */
body[data-tool-page="true"],
body.tool-page-bg {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  background-attachment: fixed !important;
  color: white !important;
  padding-top: 120px !important;
  font-family: 'Inter', sans-serif;
}

/* Hide elements on tool pages */
body[data-tool-page="true"] .tm-footer,
body[data-tool-page="true"] #tm-footer,
body.tool-page-bg .tm-footer,
body.tool-page-bg #tm-footer {
  display: none !important;
}

body[data-tool-page="true"] .glassy-nav-links,
body.tool-page-bg .glassy-nav-links {
  display: none !important;
}

/* Glassy containers for tool pages */
body[data-tool-page="true"] .bg-white,
body[data-tool-page="true"] [class*="bg-slate"],
body[data-tool-page="true"] [class*="bg-gray"],
body.tool-page-bg .bg-white,
body.tool-page-bg [class*="bg-slate"],
body.tool-page-bg [class*="bg-gray"] {
  background: rgba(255, 255, 255, 0.2) !important;
  backdrop-filter: blur(10px) !important;
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
}

/* White text for tool pages */
body[data-tool-page="true"] *,
body[data-tool-page="true"] .text-gray-600,
body[data-tool-page="true"] .text-gray-700,
body[data-tool-page="true"] .text-gray-800,
body[data-tool-page="true"] .text-slate-600,
body[data-tool-page="true"] .text-slate-700,
body.tool-page-bg *,
body.tool-page-bg .text-gray-600,
body.tool-page-bg .text-gray-700,
body.tool-page-bg .text-gray-800,
body.tool-page-bg .text-slate-600,
body.tool-page-bg .text-slate-700 {
  color: white !important;
}

/* Yellow accents for tool pages */
body[data-tool-page="true"] .text-indigo-600,
body[data-tool-page="true"] .text-blue-600,
body.tool-page-bg .text-indigo-600,
body.tool-page-bg .text-blue-600 {
  color: #fbbf24 !important;
}

body[data-tool-page="true"] .border-indigo-500,
body[data-tool-page="true"] .ring-indigo-500,
body.tool-page-bg .border-indigo-500,
body.tool-page-bg .ring-indigo-500 {
  border-color: #fbbf24 !important;
  --tw-ring-color: #fbbf24 !important;
}
