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

:root {
  --primary-color: #4CAF50;
  --primary-dark: #388E3C;
  --primary-light: #C8E6C9;
  --text-primary: #212121;
  --text-secondary: #757575;
  --bg-primary: #FAFAFA;
  --bg-secondary: #F5F5F5;
  --border-color: #BDBDBD;
  --error-color: #F44336;
  --success-color: #4CAF50;
}

html, body {
  width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

/* ========== Typography ========== */
h1, h2, h3, h4, h5, h6 {
  font-weight: 500;
  line-height: 1.2;
}

h1 { font-size: 2.5rem; margin-bottom: 1.5rem; }
h2 { font-size: 2rem; margin-bottom: 1.2rem; }
h3 { font-size: 1.5rem; margin-bottom: 1rem; }
h4 { font-size: 1.25rem; margin-bottom: 0.8rem; }

p {
  line-height: 1.6;
  margin-bottom: 1rem;
}

/* ========== Buttons ========== */
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  user-select: none;
  -webkit-user-select: none;
}

button:hover, .button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

button:active, .button:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.button-primary {
  background-color: var(--primary-color);
  color: white;
}

.button-primary:hover {
  background-color: var(--primary-dark);
}

.button-secondary {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.button-secondary:hover {
  background-color: #EEEEEE;
}

.button-small {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

/* ========== Forms ========== */
input, select, textarea {
  padding: 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

/* ========== Layout ========== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

.grid {
  display: grid;
  gap: 2rem;
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.flex-column {
  flex-direction: column;
  align-items: stretch;
}

.gap-1 { gap: 1rem; }
.gap-2 { gap: 2rem; }

/* ========== Cards ========== */
.card {
  background: white;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
  h1 { font-size: 2rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.25rem; }

  .container {
    padding: 1rem;
  }

  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }

  .flex {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }
}

/* ========== Utilities ========== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }
.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 2rem; }
.p-1 { padding: 1rem; }
.p-2 { padding: 2rem; }
.hidden { display: none; }
.opacity-50 { opacity: 0.5; }

/* ========== Header bar (title + lang toggle) ========== */
.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.header-bar h1 {
  margin-bottom: 0;
}

/* Hub filter section */
.filters {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.filter-search {
  width: 100%;
}
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.chip-row-sub {
  padding-left: 0.25rem;
}
.chip {
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: white;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.chip:hover {
  background: var(--bg-secondary);
  transform: none;
  box-shadow: none;
}
.chip-active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-dark);
}
.chip-active:hover {
  background: var(--primary-dark);
}
.chip-sub {
  font-size: 0.8125rem;
  padding: 0.3rem 0.75rem;
}
.howto-list {
  margin-left: 1.5rem;
  margin-bottom: 1.5rem;
}
.howto-list:last-child {
  margin-bottom: 0;
}

/* Back-to-hub link used on each app page */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.back-link:hover {
  color: var(--primary-color);
  background: var(--bg-secondary);
}

/* Toast (shared by hub and apps) */
.toast {
  position: fixed;
  left: 50%;
  bottom: 2rem;
  transform: translateX(-50%);
  background: rgba(33, 33, 33, 0.92);
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: 6px;
  font-size: 0.9rem;
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  max-width: 90vw;
  text-align: center;
}
.toast.toast-visible {
  opacity: 1;
}