/* === Polkadot Brand: CSS Variables === */
:root {
  /* Typography */
  --font-body: 'DM Sans', sans-serif;
  --font-display: 'DM Serif Display', serif;

  /* Grey Scale */
  --grey-50:  #FAFAF9;
  --grey-100: #F5F5F4;
  --grey-200: #E7E5E4;
  --grey-300: #D6D3D1;
  --grey-400: #A8A29E;
  --grey-500: #78716C;
  --grey-600: #57534E;
  --grey-800: #292524;
  --grey-900: #1C1917;
  --grey-950: #0F0F0F;

  /* Accent */
  --pink: #FF2867;

  /* Semantic (Light Mode) */
  --bg: var(--grey-50);
  --surface: #FFFFFF;
  --text: var(--grey-900);
  --text-muted: var(--grey-600);
  --border: var(--grey-200);
  --accent: var(--pink);
  --accent-hover: #E6164F;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  --space-4xl: 6rem;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
  --shadow-xl: 0 20px 50px rgba(0,0,0,0.12);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;

  /* Sidebar */
  --sidebar-width: 220px;
  --sidebar-collapsed-width: 60px;
}

/* Dark Mode (class-based) */
:root.dark {
  --bg: var(--grey-950);
  --surface: var(--grey-900);
  --text: var(--grey-50);
  --text-muted: var(--grey-400);
  --border: var(--grey-800);
  --accent-hover: #FF5088;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.4);
}

/* === Base Styles === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  line-height: 1.2;
  font-weight: 600;
}

h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 2.5rem;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--text); }

button, .btn {
  font-family: var(--font-body);
  font-weight: 500;
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.875rem;
}

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn-primary:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  border-color: var(--text-muted);
}

.btn-danger {
  color: var(--accent);
}
.btn-danger:hover {
  border-color: var(--accent);
}

input, textarea, select {
  font-family: var(--font-body);
  font-size: 1rem;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition-fast);
  width: 100%;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}
textarea {
  resize: vertical;
}

/* === Layout === */
#app {
  display: flex;
  min-height: 100vh;
}

.app-content {
  flex: 1;
  min-width: 0;
  padding: var(--space-xl);
  max-width: 900px;
  transition: margin-left var(--transition-normal);
}

@media (max-width: 768px) {
  .app-content {
    padding: var(--space-md);
  }
}

/* === Sidebar === */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  transition: width var(--transition-normal);
  overflow: hidden;
  flex-shrink: 0;
  z-index: 100;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  border-bottom: 1px solid var(--border);
  min-height: 60px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--text);
  font-weight: 600;
  font-size: 1rem;
  white-space: nowrap;
}
.sidebar-logo:hover { color: var(--text); }
.sidebar-logo svg { flex-shrink: 0; }

.sidebar-toggle {
  background: none;
  border: none;
  padding: var(--space-xs);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}
.sidebar-toggle:hover {
  color: var(--text);
  background: var(--bg);
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  justify-content: flex-start;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.sidebar-link:hover {
  color: var(--text);
  background: var(--bg);
}
.sidebar-link.router-link-exact-active {
  color: var(--text);
  background: var(--bg);
  font-weight: 600;
}
.sidebar-link svg { flex-shrink: 0; }

.sidebar-footer {
  padding: var(--space-sm);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-label {
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--transition-fast);
}

/* Collapsed state */
.sidebar.collapsed { width: var(--sidebar-collapsed-width); }
.sidebar.collapsed .sidebar-label { opacity: 0; width: 0; pointer-events: none; }
.sidebar.collapsed .sidebar-link {
  width: 40px; height: 40px;
  padding: 0; justify-content: center; align-items: center; gap: 0;
}
/* Mobile */
@media (max-width: 768px) {
  .sidebar:not(.expanded) { width: var(--sidebar-collapsed-width); }
  .sidebar:not(.expanded) .sidebar-label { opacity: 0; width: 0; pointer-events: none; }
  .sidebar:not(.expanded) .sidebar-link {
    width: 40px; height: 40px;
    padding: 0; justify-content: center; gap: 0;
  }
  .sidebar.expanded {
    position: fixed; z-index: 200;
    box-shadow: var(--shadow-lg);
    width: var(--sidebar-width);
  }
}

/* === Home View === */
.home-header {
  margin-bottom: var(--space-xl);
}

.search-bar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-sm) var(--space-md);
  transition: border-color var(--transition-fast);
}
.search-bar:focus-within {
  border-color: var(--accent);
}
.search-bar svg {
  color: var(--text-muted);
  flex-shrink: 0;
}
.search-bar input {
  border: none;
  padding: 0;
  background: transparent;
  flex: 1;
}
.search-bar input:focus {
  outline: none;
  border-color: transparent;
}

.filter-row {
  display: flex;
  gap: var(--space-xs);
  margin-top: var(--space-md);
  flex-wrap: wrap;
}

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: var(--space-xs) var(--space-sm);
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.filter-btn:hover {
  border-color: var(--text-muted);
  color: var(--text);
}
.filter-btn.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

/* === Tasting Grid === */
.tasting-grid {
  display: grid;
  gap: var(--space-md);
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.tasting-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition-normal);
  color: var(--text);
  text-decoration: none;
  display: block;
}
.tasting-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  color: var(--text);
}

.tasting-card-photo {
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--grey-100);
}
:root.dark .tasting-card-photo {
  background: var(--grey-800);
}
.tasting-card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.tasting-card-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.tasting-card-body {
  padding: var(--space-md);
}

.tasting-card-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.tasting-card-brewery {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
}

.tasting-card-rating {
  display: flex;
  gap: 2px;
  margin-bottom: var(--space-xs);
}

.star { color: var(--grey-300); }
.star.filled { color: var(--grey-600); }
:root.dark .star { color: var(--grey-600); }
:root.dark .star.filled { color: var(--grey-300); }

.tasting-card-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* === Detail View === */
.detail-view {
  max-width: 700px;
}

.detail-photo {
  width: 100%;
  max-height: 400px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--space-xl);
}
.detail-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  max-height: 400px;
}

.detail-content {
  padding: 0;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.detail-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 2rem;
  margin-bottom: 2px;
}

.detail-brewery {
  font-size: 1.1rem;
  color: var(--text-muted);
}

.detail-actions {
  display: flex;
  gap: var(--space-sm);
  flex-shrink: 0;
}

.detail-rating {
  display: flex;
  gap: 4px;
  margin-bottom: var(--space-xl);
}

.detail-notes {
  margin-bottom: var(--space-xl);
}
.detail-notes h3 {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
}
.detail-notes p {
  line-height: 1.8;
  white-space: pre-wrap;
}

.detail-date {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* === Form View === */
.form-view {
  max-width: 600px;
}

.tasting-form h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 2rem;
  margin-bottom: var(--space-xl);
}

.form-group {
  margin-bottom: var(--space-lg);
}
.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: var(--space-xs);
  color: var(--text-muted);
}

.star-input {
  display: flex;
  gap: var(--space-xs);
}
.star-btn {
  background: none;
  border: none;
  padding: var(--space-xs);
  cursor: pointer;
  color: var(--grey-300);
  transition: all var(--transition-fast);
}
.star-btn.active { color: var(--grey-600); }
:root.dark .star-btn { color: var(--grey-600); }
:root.dark .star-btn.active { color: var(--grey-300); }
.star-btn:hover { transform: scale(1.15); }

.upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-2xl);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-muted);
  text-align: center;
}
.upload-area:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.photo-preview {
  position: relative;
}
.photo-preview img {
  width: 100%;
  max-height: 300px;
  object-fit: cover;
  border-radius: var(--radius-lg);
  display: block;
  margin-bottom: var(--space-sm);
}

.form-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: flex-end;
  margin-top: var(--space-xl);
}

.error-msg {
  color: var(--accent);
  font-size: 0.875rem;
  margin-top: var(--space-md);
}

/* === Login View === */
.login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  width: 100%;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl);
  max-width: 400px;
  width: 100%;
}

.login-logo {
  margin-bottom: var(--space-md);
  color: var(--text);
}
.login-card h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.75rem;
  margin-bottom: var(--space-xs);
}
.login-subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: var(--space-xl);
}

/* === Empty & Loading States === */
.empty-state, .loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-4xl) var(--space-xl);
  color: var(--text-muted);
  gap: var(--space-md);
}
.empty-state h2 {
  font-family: var(--font-display);
  font-weight: 400;
  color: var(--text);
}

/* === Overlay === */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
}

.overlay-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  max-width: 400px;
  width: 100%;
}
.overlay-card h3 {
  margin-bottom: var(--space-sm);
}
.overlay-card p {
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.6;
}
.overlay-card ol {
  margin: var(--space-md) 0;
  padding-left: var(--space-lg);
  color: var(--text-muted);
  font-size: 0.875rem;
}
.overlay-card li {
  margin-bottom: var(--space-xs);
}

/* === Display Mode Utilities === */
@media (display-mode: standalone) {
  .hide-in-pwa { display: none !important; }
}
@media not (display-mode: standalone) {
  .hide-in-browser { display: none !important; }
}

/* === Animations === */
.fade-in {
  opacity: 0;
  transform: translateY(12px);
  animation: fadeIn 0.4s ease forwards;
}
.fade-in:nth-child(2) { animation-delay: 0.1s; }
.fade-in:nth-child(3) { animation-delay: 0.2s; }

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