/* --- Base Styles --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  font-size: 16px; /* Base font size */
}
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #f8f9fa;
  margin: 0;
  transition: margin-right 0.3s ease-in-out; /* For sidebar push effect */
}
h2, h3, h4 {
  margin-bottom: 0.8em;
  color: #444;
  font-weight: 600;
}
ul {
  list-style: none;
  padding-left: 0;
}
li {
  margin-bottom: 0.5em;
}
button, input, textarea, label {
  font-family: inherit;
  font-size: inherit;
}
a {
  color: #007bff;
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
.error-message {
  color: #dc3545;
  font-style: italic;
}
.empty-view-message {
  color: #6c757d;
  font-style: italic;
  padding: 10px;
  text-align: center;
}

/* --- Top Navigation --- */
.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background-color: #ffffff;
  border-bottom: 1px solid #dee2e6;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-wrap: wrap;
  gap: 10px;
}
.tabs {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin; /* Firefox */
  scrollbar-color: #ced4da #f8f9fa;
  padding-bottom: 5px;
}
.tabs::-webkit-scrollbar {
  height: 5px;
}
.tabs::-webkit-scrollbar-track {
  background: #f8f9fa;
}
.tabs::-webkit-scrollbar-thumb {
  background-color: #ced4da;
  border-radius: 10px;
  border: 1px solid #f8f9fa;
}
.tabs button.tab-link {
  padding: 10px 15px;
  margin-right: 5px;
  cursor: pointer;
  border: none;
  background-color: transparent;
  font-size: 1rem;
  border-bottom: 3px solid transparent;
  transition: border-color 0.3s ease, color 0.3s ease;
  white-space: nowrap;
  color: #495057;
}
.tabs button.tab-link:hover {
  color: #0056b3;
}
.tabs button.tab-link.active {
  border-bottom-color: #007bff;
  color: #007bff;
  font-weight: 600;
}
.controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.btn {
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  border: 1px solid #ced4da;
  background-color: #f1f3f5;
  border-radius: 4px;
  font-size: 0.9rem;
  transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  line-height: 1.5;
}
.btn:hover {
  background-color: #e9ecef;
  border-color: #adb5bd;
}
.btn:focus-visible {
  outline: 2px solid #007bff;
  outline-offset: 2px;
}
.btn-secondary {
  background-color: #007bff;
  color: white;
  border-color: #007bff;
}
.btn-secondary:hover {
  background-color: #0056b3;
  border-color: #004085;
}
.btn:disabled {
  background-color: #e9ecef;
  border-color: #ced4da;
  color: #6c757d;
  cursor: not-allowed;
  opacity: 0.7;
}
.mode-switch {
  display: flex;
  align-items: center;
  font-size: 0.9rem;
  border: 1px solid #ced4da;
  border-radius: 4px;
  overflow: hidden;
}
.mode-switch label {
  padding: 0.5rem 0.6rem;
  cursor: pointer;
  background-color: #f8f9fa;
  transition: background-color 0.3s ease;
  user-select: none;
}
.mode-switch label:has(input:checked) {
  background-color: #cfe2ff;
  color: #052c65;
}
.mode-switch input[type="radio"] {
  display: none;
}

/* --- Profile Menu Dropdown --- */
.profile-menu-container {
  position: relative;
}
.profile-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  background-color: white;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  min-width: 160px;
  z-index: 110;
  margin-top: 5px;
}
.profile-dropdown a {
  display: block;
  padding: 10px 15px;
  color: #333;
  text-decoration: none;
  font-size: 0.9rem;
}
.profile-dropdown a:hover {
  background-color: #f8f9fa;
}
.profile-menu-container:hover .profile-dropdown,
.profile-menu-btn:focus + .profile-dropdown,
.profile-dropdown:focus-within {
  display: block;
}
.profile-menu-btn i {
  margin-left: 5px;
  transition: transform 0.2s;
  display: inline-block;
}
.profile-menu-container:hover .profile-menu-btn i {
  transform: rotate(180deg);
}

/* --- Main Content Area & Tabs --- */
.main-container {
  display: flex;
}
main {
  padding: 20px;
  flex-grow: 1;
  transition: margin-right 0.3s ease-in-out; /* For sidebar push */
  min-width: 0; /* Prevent content expansion issues */
}
.tab-content {
  display: none;
  padding: 20px;
  background-color: #fff;
  border-radius: 5px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
  margin-top: 15px;
}
.tab-content.active {
  display: block;
  animation: fadeIn 0.5s ease-in-out;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* --- Tools Section --- */
.tools-section {
  margin-bottom: 30px;
  border-bottom: 1px solid #eee;
  padding-bottom: 20px;
}
.tools-scroll {
  overflow-x: auto;
  padding-bottom: 10px;
  max-width: 100%;
}
.tools-container {
  display: flex;
  gap: 15px;
  padding-top: 5px;
  min-width: min-content;
}
/* Base Tool Card Styles */
.tool-card {
  width: 150px;
  height: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 15px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  border: 1px solid transparent;
  transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.tool-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
/* Tool Type Specific */
.tool-card.tool-exercise {
  background-color: #e0f7fa;
  border-color: #b2ebf2;
  color: #00796b;
}
.tool-card.tool-exercise:hover {
  background-color: #c0f0f5;
}
.tool-card.tool-exploration {
  background-color: #e8f5e9;
  border-color: #c8e6c9;
  color: #2e7d32;
  justify-content: space-between;
  padding-top: 30px;
  padding-bottom: 25px;
}
.tool-card.tool-exploration:hover {
  background-color: #d8f0d9;
}
.tool-card.tool-inspiration {
  background-color: #fffde7;
  border-color: #fff9c4;
  color: #f57f17;
}
.tool-card.tool-inspiration:hover {
  background-color: #fffbea;
}
/* Lock Icon */
.tool-lock-icon {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 0.85em;
  color: rgba(0, 0, 0, 0.3);
}
/* Progress Bar */
.tool-progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 6px;
  background-color: rgba(0, 0, 0, 0.1);
  border-radius: 8px 8px 0 0;
  overflow: hidden;
}
.tool-progress {
  height: 100%;
  background-color: #4caf50;
  transition: width 0.3s ease;
}
.tool-time-label {
  position: absolute;
  bottom: 8px;
  right: 10px;
  font-size: 0.75em;
  font-weight: bold;
  color: rgba(0, 0, 0, 0.5);
  background-color: rgba(255, 255, 255, 0.6);
  padding: 1px 5px;
  border-radius: 3px;
}

/* Tools Expand */
.tools-section.expanded .tools-scroll {
  max-height: 350px;
  overflow-y: auto;
}
.tools-section.expanded .tools-container {
  flex-wrap: wrap;
  min-width: auto;
}
.expand-tools-btn {
  display: none;
  margin: 10px auto 0;
  padding: 5px 10px;
  font-size: 0.85rem;
  cursor: pointer;
  border: 1px solid #ccc;
  background-color: #f8f8f8;
  border-radius: 4px;
}
.expand-tools-btn:hover {
  background-color: #eee;
}

/* --- Main View Area & Switcher --- */
.main-view-area {
  margin-top: 20px;
}
.view-switcher {
  margin-bottom: 20px;
  text-align: right;
}
.view-switcher .view-btn {
  background: #f8f9fa;
  border: 1px solid #ced4da;
  padding: 8px 12px;
  margin-left: 5px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 1.1rem;
  line-height: 1;
  color: #555;
  transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}
.view-switcher .view-btn:hover {
  background: #e9ecef;
}
.view-switcher .view-btn.active {
  background: #007bff;
  color: white;
  border-color: #0056b3;
}
.view-switcher .view-btn:focus-visible {
  outline: 2px solid #007bff;
  outline-offset: 1px;
}

/* Generic .view container */
.view {
  display: none;
}
.view.active {
  display: block;
  animation: fadeIn 0.5s ease-in-out;
}

/* BOARD & ZONES (Flex Wrapping) */
.board {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem; /* spacing between zones horizontally and vertically */
  align-items: flex-start; 
  justify-content: flex-start; 
  background: linear-gradient(to bottom right, #ebf8ff, #f3e8ff);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
  min-height: 100vh;
  overflow: auto; /* vertical scroll if the board has many rows */
}

.zone {
  /* If you want strictly 16rem wide, never shrinking: */
  flex: 0 0 16rem;
  /* Or if you prefer some shrinking: flex: 0 1 16rem; */
  min-height: 16rem;
  border-radius: 50%;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  transition: all 0.3s ease;
  background-color: rgba(191,219,254,0.4);
  margin-bottom: 1rem;
}
.zone h3 {
  font-weight: 600;
  font-size: 0.875rem;
  text-align: center;
  margin-bottom: 1rem;
}
.add-button {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  background-color: #3b82f6;
  color: white;
  border: none;
  cursor: pointer;
}

/* Cards inside zones */
.card {
  margin-bottom: 0.5rem;
  width: 12rem;
  padding: 0.75rem;
  background-color: #fff;
  border-radius: 0.5rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
  cursor: move;
  opacity: 0;
  transform: translateY(20px) rotate(var(--tilt));
  animation: fadeInUp 0.5s forwards;
}
@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0) rotate(var(--tilt));
  }
}
.card.dragging {
  transform: rotate(-2deg) scale(1.02);
}

/* View 2: Cards (Grid of item-cards) */
.view-cards.active {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}
.item-card {
  background-color: #fff;
  border: 1px solid #e0e0e0;
  padding: 18px 20px;
  border-radius: 6px;
  font-size: 1.05rem;
  flex: 1 1 280px;
  min-width: 250px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.07);
  transition: box-shadow 0.2s ease;
}
.item-card:hover {
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
.item-card-content {
  flex-grow: 1;
  margin-right: 15px;
  overflow-wrap: break-word;
  word-break: break-word;
}
.item-card span.category-label {
  font-weight: 600;
  color: #555;
  margin-right: 8px;
  display: block;
  margin-bottom: 4px;
  font-size: 0.9em;
}
.item-card span.item-text {
  color: #212529;
}

/* View 3: Slideshow */
.slideshow-container {
  position: relative;
  background-color: #f8f9fa;
  min-height: 200px;
  text-align: center;
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid #eee;
  display: flex;
  align-items: center;
  justify-content: center;
}
.slideshow-container .slide {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 25px 60px;
  min-height: 150px;
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  color: #fff;
  opacity: 0;
  transition: opacity 0.6s ease-in-out;
}
.slideshow-container .slide.active {
  display: flex;
  opacity: 1;
  z-index: 1;
}
.slide-content-wrapper {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
  background-color: rgba(0, 0, 0, 0.3);
  padding: 20px;
  border-radius: 5px;
  max-width: 80%;
}
.slideshow-container .slide span.category-label {
  font-weight: 400;
  display: block;
  font-size: 0.9em;
  margin-bottom: 8px;
  text-transform: uppercase;
  opacity: 0.9;
}
.slideshow-container .slide span.item-text {
  font-size: 1.4em;
  font-weight: 700;
  line-height: 1.4;
  overflow-wrap: break-word;
  word-break: break-word;
}
.slide-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 8px;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.3s ease;
  background-color: rgba(0, 0, 0, 0.4);
  padding: 5px 8px;
  border-radius: 4px;
  z-index: 5;
}
.slideshow-container .slide.active:hover .slide-controls {
  visibility: visible;
  opacity: 1;
}
.slide-controls button {
  background: none;
  border: none;
  color: #fff;
  font-size: 1rem;
  opacity: 0.8;
}
.slide-controls button:hover {
  opacity: 1;
}
.slide-nav {
  cursor: pointer;
  position: absolute;
  top: 50%;
  width: auto;
  padding: 16px 12px;
  margin-top: -25px;
  color: #fff;
  font-weight: bold;
  font-size: 24px;
  transition: 0.3s ease;
  border-radius: 0 4px 4px 0;
  user-select: none;
  background-color: rgba(0, 0, 0, 0.3);
  border: none;
  z-index: 10;
}
.slide-nav.next {
  right: 0;
  border-radius: 4px 0 0 4px;
}
.slide-nav.prev {
  left: 0;
  border-radius: 0 4px 4px 0;
}
.slide-nav:hover {
  background-color: rgba(0, 0, 0, 0.5);
}

/* Slide Themes */
.slide-theme-1 {
  background-image: linear-gradient(45deg, #2980b9, #6dd5fa);
}
.slide-theme-2 {
  background-image: linear-gradient(to right, #ff512f, #dd2476);
}
.slide-theme-3 {
  background-image: linear-gradient(120deg, #f6d365 0%, #fda085 100%);
  color: #3a1c1e;
  text-shadow: 1px 1px 2px rgba(255,255,255,0.3);
}
.slide-theme-4 {
  background-image: linear-gradient(to top, #48c6ef 0%, #6f86d6 100%);
}

/* View 4: Table */
.view-table.active {
  display: block;
  overflow-x: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 15px;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  overflow: hidden;
  font-size: 0.95rem;
}
.data-table th, .data-table td {
  border-bottom: 1px solid #dee2e6;
  padding: 12px 15px;
  text-align: left;
  vertical-align: middle;
}
.data-table th {
  background-color: #f8f9fa;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}
.data-table td {
  background-color: #fff;
}
.data-table tbody tr:nth-child(even) td {
  background-color: #fdfdff;
}
.data-table tbody tr:hover td {
  background-color: #f1f3f5;
}
.data-table td.item-text {
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
  min-width: 150px;
}
.data-table th[data-sortable] {
  cursor: pointer;
  user-select: none;
}
.data-table th[data-sortable]:hover {
  background-color: #e9ecef;
}
.data-table th .sort-icon {
  display: inline-block;
  width: 1em;
  text-align: center;
  margin-left: 5px;
  opacity: 0.4;
  transition: opacity 0.2s ease;
  color: #6c757d;
}
.data-table th[data-sort-dir] .sort-icon {
  opacity: 1;
  color: #007bff;
}
.data-table td:last-child {
  width: 90px;
  text-align: right;
  white-space: nowrap;
}

/* Item Controls (Edit/Delete) */
.item-controls {
  display: flex;
  gap: 10px;
  margin-left: 10px;
  align-items: center;
}
.item-controls button {
  background: none;
  border: none;
  color: #6c757d;
  cursor: pointer;
  font-size: 1rem;
  padding: 3px;
  line-height: 1;
  transition: color 0.2s ease;
}
.item-controls button:hover {
  color: #007bff;
}
.item-controls .delete-btn:hover {
  color: #dc3545;
}
.item-controls button i {
  pointer-events: none;
  display: block;
}

/* Draggable items base style */
[draggable="true"] {
  user-select: none;
}

/* --- Modals --- */
.modal {
  display: none;
  position: fixed;
  z-index: 1050;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  background-color: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease-out;
}
.modal-content {
  background-color: #fff;
  padding: 30px;
  border-radius: 6px;
  box-shadow: 0 5px 15px rgba(0,0,0,0.2);
  width: 90%;
  max-width: 550px;
  position: relative;
  margin: 1.75rem auto;
  animation: slideIn 0.3s ease-out;
}
@keyframes slideIn {
  from {
    transform: translateY(-30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
.modal .close-btn {
  position: absolute;
  top: 10px;
  right: 15px;
  color: #aaa;
  font-size: 30px;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
  background: none;
  border: none;
  padding: 5px;
}
.modal .close-btn:hover,
.modal .close-btn:focus {
  color: #333;
}
.modal h3 {
  margin-top: 0;
  margin-bottom: 25px;
  font-size: 1.3rem;
}
.modal input[type="text"],
.modal textarea {
  width: 100%;
  padding: 12px;
  margin-bottom: 20px;
  border: 1px solid #ced4da;
  border-radius: 4px;
  font-size: 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.modal input[type="text"]:focus,
.modal textarea:focus {
  border-color: #86b7fe;
  outline: 0;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}
.modal textarea {
  resize: vertical;
  min-height: 80px;
}
.modal-actions {
  text-align: right;
  margin-top: 15px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
#modal-next-btn {
  /* displayed for exploration steps if needed */
}

/* Prevent body scroll when modal is open */
body.modal-open {
  overflow: hidden;
  padding-right: var(--scrollbar-width, 0px);
}

/* --- Guided Mode Sidebar --- */
#guided-sidebar {
  position: fixed;
  right: 0;
  top: 0;
  padding-top: 70px;
  height: 100%;
  width: 300px;
  background-color: #f8f9fa;
  border-left: 1px solid #dee2e6;
  transform: translateX(100%);
  transition: transform 0.3s ease-in-out;
  z-index: 95;
  padding: 20px;
  padding-top: 80px;
  overflow-y: auto;
  box-shadow: -2px 0 5px rgba(0,0,0,0.1);
}
#guided-sidebar.show {
  transform: translateX(0);
}
#guided-sidebar h3 {
  margin-bottom: 20px;
  font-size: 1.15rem;
  color: #495057;
}
#guided-sidebar ul {
  list-style: none;
  padding: 0;
}
#guided-sidebar li {
  background-color: #fff;
  border: 1px solid #eee;
  padding: 12px 15px;
  margin-bottom: 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: background-color 0.2s, box-shadow 0.2s ease;
}
#guided-sidebar li:hover {
  background-color: #e9ecef;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
#close-sidebar-btn {
  position: absolute;
  top: 70px;
  right: 15px;
  background: none;
  border: none;
  font-size: 26px;
  color: #6c757d;
  cursor: pointer;
  line-height: 1;
  padding: 5px;
}
#close-sidebar-btn:hover {
  color: #343a40;
}
body.sidebar-open-push main {
  margin-right: 300px;
}
@media (max-width: 992px) {
  .top-nav {
    flex-direction: column;
    align-items: stretch;
  }
  .tabs {
    order: 1;
    width: 100%;
    justify-content: flex-start;
    padding-bottom: 10px;
  }
  .controls {
    order: 2;
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }
  .mode-switch {
    order: 1;
  }
  .profile-menu-container {
    order: 2;
  }
  body.sidebar-open-push main,
  body main {
    margin-right: 0 !important;
  }
  #guided-sidebar {
    z-index: 1060;
  }
  body.sidebar-open-overlay::before {
    content: '';
    position: fixed;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.4);
    z-index: 90;
    transition: opacity 0.3s ease-in-out;
    opacity: 1;
  }
  body:not(.sidebar-open-overlay)::before {
    opacity: 0;
    pointer-events: none;
  }
}
@media (max-width: 576px) {
  main,
  .tab-content {
    padding: 15px;
  }
  h2 {
    font-size: 1.4rem;
  }
  .tabs button.tab-link {
    font-size: 0.9rem;
    padding: 8px 10px;
  }
  .controls {
    gap: 8px;
    justify-content: center;
  }
  .btn {
    font-size: 0.85rem;
    padding: 0.4rem 0.7rem;
  }
  .mode-switch label {
    padding: 0.4rem 0.5rem;
  }
  .item-card {
    flex-basis: 100%;
  }
  #guided-sidebar {
    width: 85%;
  }
  .modal-content {
    padding: 20px;
    max-width: 95%;
  }
  .modal h3 {
    font-size: 1.1rem;
    margin-bottom: 20px;
  }
  .modal input[type="text"],
  .modal textarea {
    padding: 10px;
    font-size: 0.95rem;
  }
}
