/* ============================================================
   Hookah Tracker – Custom Styles
   Minimal, modern design with Tailwind CSS
   ============================================================ */

/* ----- Global ----------------------------------------------- */
* {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  overflow-x: hidden;
}

/* iOS safe area support */
.safe-area-top {
  padding-top: env(safe-area-inset-top);
}

/* ----- Scrollbar -------------------------------------------- */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(150, 150, 160, 0.2);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(150, 150, 160, 0.35);
}

/* ----- Inputs ---------------------------------------------- */
.input-field {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  outline: none;
  transition: all 0.15s ease;
  background: #f1f5f9;
  border: 1px solid transparent;
  color: #1e293b;
}

.input-field::placeholder {
  color: #94a3b8;
}

.input-field:focus {
  border-color: rgba(249, 115, 22, 0.5);
  box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.15);
}

.dark .input-field {
  background: rgba(255, 255, 255, 0.04);
  color: #f1f5f9;
}

.dark .input-field::placeholder {
  color: #64748b;
}

/* ----- Buttons --------------------------------------------- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: white;
  background: #f97316;
  transition: all 0.15s ease;
  cursor: pointer;
  border: none;
}

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

.btn-primary:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #64748b;
  background: #f1f5f9;
  transition: all 0.15s ease;
  cursor: pointer;
  border: none;
}

.btn-secondary:hover {
  background: #e2e8f0;
}

.dark .btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: #94a3b8;
}

.dark .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: white;
  background: #ef4444;
  transition: all 0.15s ease;
  cursor: pointer;
  border: none;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.375rem 0.5rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #94a3b8;
  background: transparent;
  transition: all 0.15s ease;
  cursor: pointer;
  border: none;
}

.btn-icon:hover {
  background: #f1f5f9;
  color: #64748b;
}

.dark .btn-icon:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #cbd5e1;
}

/* ----- Form collapse --------------------------------------- */
.form-body {
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.2s ease;
}

.form-body.collapsed {
  max-height: 0 !important;
  opacity: 0;
}

/* ----- Dashboard Stat Cards -------------------------------- */
.stat-card {
  background: white;
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: 0.75rem;
  padding: 1rem;
  transition: all 0.2s ease;
}

.stat-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  border-color: #cbd5e1;
}

.dark .stat-card {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.06);
}

.dark .stat-card:hover {
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* ----- Cards ----------------------------------------------- */
.tobacco-card {
  background: white;
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: 0.75rem;
  padding: 1rem;
  transition: all 0.2s ease;
}

.tobacco-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  border-color: #cbd5e1;
}

.dark .tobacco-card {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.06);
}

.dark .tobacco-card:hover {
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* List items */
.tobacco-list-item {
  background: white;
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  transition: all 0.2s ease;
}

.tobacco-list-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  border-color: #cbd5e1;
}

.dark .tobacco-list-item {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.06);
}

.dark .tobacco-list-item:hover {
  border-color: rgba(255, 255, 255, 0.1);
}

/* ----- Card animations ------------------------------------- */
@keyframes cardSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-enter {
  animation: cardSlideIn 0.25s ease forwards;
}

@keyframes cardSlideOut {
  from { opacity: 1; transform: scale(1); max-height: 300px; }
  to   { opacity: 0; transform: scale(0.95); max-height: 0; margin: 0; padding: 0; }
}

.card-exit {
  animation: cardSlideOut 0.25s ease forwards;
  overflow: hidden;
}

@keyframes listSlideIn {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: translateX(0); }
}

.list-enter {
  animation: listSlideIn 0.25s ease forwards;
}

/* ----- Modal ----------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-box {
  position: relative;
  width: 100%;
  max-width: 28rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  background: white;
  border: 1px solid rgba(226, 232, 240, 0.6);
  border-radius: 0.75rem;
  padding: 1.25rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  animation: modalSlideIn 0.2s ease;
}

.dark .modal-box {
  background: #172032;
  border-color: rgba(255, 255, 255, 0.06);
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ----- Toast ----------------------------------------------- */
.toast {
  position: fixed;
  bottom: max(1.25rem, env(safe-area-inset-bottom, 1.25rem));
  right: 1.25rem;
  left: 1.25rem;
  z-index: 60;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: toastIn 0.25s ease, toastOut 0.25s ease 2.5s forwards;
}

@media (min-width: 640px) {
  .toast {
    left: auto;
    max-width: 20rem;
  }
}

.toast-success {
  background: #16a34a;
  color: white;
}

.toast-error {
  background: #dc2626;
  color: white;
}

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

@keyframes toastOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* ----- Stars ----------------------------------------------- */
.star-btn {
  color: #d1d5db;
  cursor: pointer;
  transition: transform 0.1s ease;
  background: none;
  border: none;
  padding: 0;
  line-height: 1;
}

.star-btn:hover {
  transform: scale(1.15);
}

.dark .star-btn {
  color: #374151;
}

/* ----- View Toggle ----------------------------------------- */
.view-toggle-btn {
  padding: 0.375rem 0.5rem;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.15s ease;
  background: none;
  border: none;
}

.view-toggle-btn:hover {
  color: #64748b;
  background: #f1f5f9;
}

.dark .view-toggle-btn:hover {
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.06);
}

.view-toggle-btn.active {
  color: #f97316;
  background: rgba(249, 115, 22, 0.08);
}

/* ----- Empty State Float ----------------------------------- */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.empty-float {
  animation: float 3s ease-in-out infinite;
}

/* ----- line-clamp ------------------------------------------ */
.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ----- Focus visible --------------------------------------- */
:focus-visible {
  outline: 2px solid #f97316;
  outline-offset: 2px;
  border-radius: 6px;
}

/* ----- Image Upload ---------------------------------------- */
.image-dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: 0.5rem;
  padding: 0.75rem;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80px;
}

.image-dropzone:hover,
.image-dropzone.dragover {
  border-color: #f97316;
  background: rgba(249, 115, 22, 0.04);
}

.dark .image-dropzone {
  border-color: rgba(255, 255, 255, 0.1);
}

.dark .image-dropzone:hover,
.dark .image-dropzone.dragover {
  border-color: #f97316;
  background: rgba(249, 115, 22, 0.06);
}

.image-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
}

.image-preview {
  max-height: 160px;
  max-width: 100%;
  border-radius: 0.375rem;
  object-fit: contain;
}

.image-remove-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ef4444;
  color: white;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 2px solid white;
  padding: 0;
  transition: background 0.15s ease;
}

.image-remove-btn:hover {
  background: #dc2626;
}

.dark .image-remove-btn {
  border-color: #172032;
}

/* ----- Sidebar --------------------------------------------- */
.sidebar-nav-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #64748b;
  text-decoration: none;
  transition: all 0.15s ease;
  cursor: pointer;
}

.sidebar-nav-link:hover {
  background: #f1f5f9;
  color: #1e293b;
}

.dark .sidebar-nav-link {
  color: #94a3b8;
}

.dark .sidebar-nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
}

.sidebar-nav-link.active {
  background: rgba(249, 115, 22, 0.1);
  color: #f97316;
  font-weight: 600;
}

.dark .sidebar-nav-link.active {
  background: rgba(249, 115, 22, 0.1);
  color: #f97316;
}

/* ----- Mobile Sidebar -------------------------------------- */
@media (max-width: 639px) {
  .sidebar-mobile {
    position: fixed;
    top: 3.5rem; /* header height */
    left: 0;
    height: calc(100vh - 3.5rem);
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .sidebar-mobile.open {
    transform: translateX(0);
  }
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  top: 3.5rem;
  z-index: 35;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.sidebar-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* ----- Navigation ------------------------------------------ */
.nav-link {
  color: #94a3b8;
  text-decoration: none;
  cursor: pointer;
}

.nav-link:hover {
  color: #64748b;
  background: #f1f5f9;
}

.nav-link.active {
  color: #f97316;
  background: rgba(249, 115, 22, 0.08);
}

.dark .nav-link {
  color: #64748b;
}

.dark .nav-link:hover {
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.06);
}

.dark .nav-link.active {
  color: #f97316;
  background: rgba(249, 115, 22, 0.1);
}

/* ----- Timeline -------------------------------------------- */
.timeline-post {
  background: white;
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: 0.75rem;
  padding: 1rem;
  transition: all 0.2s ease;
}

.timeline-post:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  border-color: #cbd5e1;
}

.dark .timeline-post {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.06);
}

.dark .timeline-post:hover {
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

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

.post-enter {
  animation: postSlideIn 0.25s ease forwards;
}

/* ----- Achievement Badges ---------------------------------- */
.achievement-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.125rem;
  padding: 0.75rem 0.5rem;
  border-radius: 0.75rem;
  text-align: center;
  transition: all 0.2s ease;
}

.achievement-badge.unlocked {
  background: rgba(249, 115, 22, 0.06);
  border: 1px solid rgba(249, 115, 22, 0.2);
}

.achievement-badge.unlocked:hover {
  border-color: rgba(249, 115, 22, 0.4);
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.1);
}

.dark .achievement-badge.unlocked {
  background: rgba(249, 115, 22, 0.08);
  border-color: rgba(249, 115, 22, 0.15);
}

.dark .achievement-badge.unlocked:hover {
  border-color: rgba(249, 115, 22, 0.3);
}

.achievement-badge.locked {
  background: rgba(148, 163, 184, 0.04);
  border: 1px dashed rgba(148, 163, 184, 0.2);
}

.dark .achievement-badge.locked {
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.06);
}

/* ----- Card Image ------------------------------------------ */
.tobacco-card-image {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 0.5rem 0.5rem 0 0;
  /* margin: -1rem -1rem 0.75rem -1rem; */
  margin: auto;
  padding-bottom: 5px;
  width: calc(100% + 2rem);
}

@media (min-width: 640px) {
  .tobacco-card-image {
    height: 160px;
  }
}
