/**
 * Global Directory Styles
 * Shared styles for sections.html and themes.html
 */

/* import not working, simply include file in the html as link 
@import url('../prototyper/css/prototyper-tokens.css'); */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--proto-font-family);
  background: var(--proto-bg-dark);
  color: var(--proto-text-primary);
  min-height: 100vh;
}

/* Scrollbar Styles - All sidebar scrollable areas */
.custom-select-options::-webkit-scrollbar{
  width: 0.5rem;
}

.custom-select-options::-webkit-scrollbar-track {
  background: transparent;
}

.custom-select-options::-webkit-scrollbar-thumb {
  background: var(--proto-bg-dark-lightest);
  border-radius: var(--proto-radius-full);
  border: 2px solid transparent;
  background-clip: padding-box;
}

.custom-select-options::-webkit-scrollbar-thumb:hover {
  background: var(--proto-primary);
  background-clip: padding-box;
}

/* ========================================
   LAYOUT
   ======================================== */

.global-directory {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ========================================
   TOPBAR
   ======================================== */

.global-topbar {
  border-bottom: 1px solid var(--proto-border);
  padding: 1.6rem 3.2rem;
  display: flex;
  align-items: center;
  gap: 2.4rem;
  background: var(--proto-bg-dark);
  position: sticky;
  top: 0;
  z-index: 100;
}

.global-topbar-left {
  display: flex;
  align-items: center;
  gap: 1.6rem;
}

.btn-back {
  padding: 0.8rem;
  background: transparent;
  border: 1px solid var(--proto-border);
  color: var(--proto-text-primary);
  border-radius: var(--proto-radius-m);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-back:hover {
  background: var(--proto-bg-hover);
  border-color: var(--proto-primary);
}

.btn-back i {
  width: 2rem;
  height: 2rem;
}

.global-title {
  font-size: var(--proto-text-xl);
  font-weight: 600;
  color: var(--proto-text-primary);
}

.global-search {
  flex: 1;
  max-width: 480px;
  position: relative;
}

.global-search input {
  width: 100%;
  padding: 1rem 1.6rem 1rem 4.2rem;
  background: var(--proto-bg);
  border: 1px solid var(--proto-border);
  border-radius: var(--proto-radius-m);
  color: var(--proto-text-primary);
  font-size: var(--proto-text-s);
  font-family: var(--proto-font-family);
  transition: all 0.2s;
}

.global-search input:focus {
  outline: none;
  border-color: var(--proto-primary);
}

.global-search::before {
  content: '';
  position: absolute;
  left: 1.6rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.8rem;
  height: 1.8rem;
  background: var(--proto-text-muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ========================================
   MAIN CONTENT
   ======================================== */

.global-main {
  padding: 3.2rem;
  flex: 1;
}

/* ========================================
   FILTERS
   ======================================== */

.global-filters {
  margin-bottom: 2.4rem;
  display: flex;
  gap: 1.2rem;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 0.8rem 1.6rem;
  background: transparent;
  border: 1px solid var(--proto-border);
  color: var(--proto-text-secondary);
  border-radius: var(--proto-radius-m);
  font-size: var(--proto-text-s);
  font-weight: 500;
  font-family: var(--proto-font-family);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.filter-btn:hover {
  background: var(--proto-bg-hover);
  border-color: var(--proto-primary);
  color: var(--proto-text-primary);
}

.filter-btn.active {
  background: var(--proto-primary);
  border-color: var(--proto-primary);
  color: white;
}

.filter-btn i {
  width: 1.6rem;
  height: 1.6rem;
}

/* ========================================
   ITEMS GRID
   ======================================== */

.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(480px, 1fr));
  gap: 2.4rem;
}

/* ========================================
   SECTION CARD
   ======================================== */

.section-card,
.theme-card {
  border: 1px solid var(--proto-border);
  border-radius: var(--proto-radius-l);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  transition: all 0.2s;
  overflow: hidden;
  background: var(--proto-bg);
}

.section-card:hover,
.theme-card:hover {
  border-color: var(--proto-primary);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.card-preview {
  position: relative;
  width: 100%;
  height: 280px;
  background: var(--proto-bg);
  border-bottom: 1px solid var(--proto-border);
  overflow: hidden;
}

.card-preview iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: white;
}

.theme-preview {
  padding: 3.2rem;
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
  align-items: flex-start;
}

.theme-preview h3 {
  font-size: var(--proto-text-l);
  margin: 0;
}

.theme-preview p {
  font-size: var(--proto-text-s);
  margin: 0;
  line-height: 1.6;
}

.theme-preview .btn-preview {
  padding: 0.8rem 1.6rem;
  border-radius: var(--proto-radius-m);
  font-size: var(--proto-text-s);
  font-weight: 600;
  cursor: pointer;
  border: none;
}

.theme-preview-card {
  width: 100%;
  padding: 2rem;
  border-radius: var(--proto-radius-m);
  border: 1px solid;
  box-shadow: var(--shadow-m);
}

.card-content {
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.2rem;
}

.card-info {
  flex: 1;
}

.card-title {
  font-size: var(--proto-text-l);
  font-weight: 600;
  color: var(--proto-text-primary);
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.card-title i {
  width: 2rem;
  height: 2rem;
  color: var(--proto-primary);
}

.card-description {
  font-size: var(--proto-text-s);
  color: var(--proto-text-secondary);
  line-height: 1.6;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.tag {
  padding: 0.4rem 0.8rem;
  background: var(--proto-bg-hover);
  color: var(--proto-text-muted);
  border-radius: var(--proto-radius-s);
  font-size: var(--proto-text-xs);
  font-weight: 500;
}

.card-actions {
  display: flex;
  gap: 0.8rem;
}

.btn-icon {
  padding: 0.8rem;
  background: transparent;
  border: 1px solid var(--proto-border);
  color: var(--proto-text-muted);
  cursor: pointer;
  border-radius: var(--proto-radius-s);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  position: relative;
}

.btn-icon:hover {
  background: var(--proto-bg-hover);
  color: var(--proto-text-primary);
  border-color: var(--proto-primary);
}

.btn-icon i {
  width: 1.8rem;
  height: 1.8rem;
}

/* Tooltip */
.btn-icon[title]:hover::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 0.8rem);
  left: 50%;
  transform: translateX(-50%);
  padding: 0.6rem 1.2rem;
  background: var(--proto-bg-dark);
  color: var(--proto-text-primary);
  border: 1px solid var(--proto-border);
  border-radius: var(--proto-radius-s);
  font-size: var(--proto-text-xs);
  white-space: nowrap;
  z-index: 1000;
  box-shadow: var(--proto-shadow-l);
}

.btn-primary-action {
  padding: 1rem 1.6rem;
  background: var(--proto-primary);
  color: white;
  border: none;
  border-radius: var(--proto-radius-m);
  font-size: var(--proto-text-s);
  font-weight: 600;
  font-family: var(--proto-font-family);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.btn-primary-action:hover {
  background: var(--proto-primary-hover);
}

.btn-primary-action i {
  width: 1.8rem;
  height: 1.8rem;
}

/* ========================================
   MODAL
   ======================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--proto-bg-dark);
  border: 1px solid var(--proto-border);
  border-radius: var(--proto-radius-l);
  padding: 3.2rem;
  max-width: 1440px;
  width: 90%;
  min-height: 600px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.9);
  transition: transform 0.2s;
}

.modal-overlay.active .modal {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2.4rem;
}

.modal-title {
  font-size: var(--proto-text-xl);
  font-weight: 600;
  color: var(--proto-text-primary);
}

.modal-close {
  padding: 0.6rem;
  background: transparent;
  border: none;
  color: var(--proto-text-muted);
  cursor: pointer;
  border-radius: var(--proto-radius-s);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.modal-close:hover {
  background: var(--proto-bg-hover);
  color: var(--proto-text-primary);
}

.modal-close i {
  width: 2rem;
  height: 2rem;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 2.4rem;
}

.modal-preview {
  width: 100%;
  height: 480px;
  border: 1px solid var(--proto-border);
  border-radius: var(--proto-radius-m);
  overflow: hidden;
  background: white;
}

.modal-preview iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.code-section {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

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

.code-label {
  font-size: var(--proto-text-m);
  font-weight: 600;
  color: var(--proto-text-primary);
}

.code-actions {
  display: flex;
  gap: 0.8rem;
}

.btn-code-action {
  padding: 0.6rem 1.2rem;
  background: transparent;
  border: 1px solid var(--proto-border);
  color: var(--proto-text-secondary);
  border-radius: var(--proto-radius-s);
  font-size: var(--proto-text-xs);
  font-weight: 500;
  font-family: var(--proto-font-family);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.btn-code-action:hover {
  background: var(--proto-bg-hover);
  border-color: var(--proto-primary);
  color: var(--proto-text-primary);
}

.btn-code-action i {
  width: 1.4rem;
  height: 1.4rem;
}

.code-block {
  background: var(--proto-bg);
  border: 1px solid var(--proto-border);
  border-radius: var(--proto-radius-m);
  padding: 1.6rem;
  max-height: 400px;
  overflow-y: auto;
  font-family: 'Courier New', monospace;
  font-size: 1.3rem;
  line-height: 1.6;
  color: var(--proto-text-primary);
  white-space: pre-wrap;
  word-break: break-all;
}

/* ========================================
   CUSTOM SELECT
   ======================================== */

.custom-select-wrapper {
  position: relative;
  width: 100%;
}

.custom-select {
  width: 100%;
  padding: 1.2rem 1.6rem;
  background: var(--proto-bg-dark);
  border: 1px solid var(--proto-border);
  border-radius: var(--proto-radius-m);
  color: var(--proto-text-primary);
  font-size: var(--proto-text-s);
  font-family: var(--proto-font-family);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.custom-select:hover {
  border-color: var(--proto-bg-dark);
}

.custom-select-options {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  right: 0;
  background: var(--proto-bg-dark);
  border: 1px solid var(--proto-border);
  border-radius: var(--proto-radius-m);
  max-height: 300px;
  overflow-y: auto;
  z-index: 100;
  display: none;
  box-shadow: var(--proto-shadow-l);
}

.custom-select-wrapper.open .custom-select-options {
  display: block;
}

.custom-select-option {
  padding: 1.2rem 1.6rem;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  gap: 1.2rem;
}

.custom-select-option:hover {
  background: var(--proto-bg-hover);
}

.project-color-dot {
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ========================================
   FORM ELEMENTS
   ======================================== */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.form-label {
  font-size: var(--proto-text-s);
  font-weight: 600;
  color: var(--proto-text-primary);
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.checkbox-group input[type="checkbox"] {
  width: 1.8rem;
  height: 1.8rem;
  cursor: pointer;
}

.checkbox-group label {
  font-size: var(--proto-text-s);
  color: var(--proto-text-secondary);
  cursor: pointer;
}

.modal-footer {
  display: flex;
  gap: 1.2rem;
  justify-content: flex-end;
  margin-top: 2.4rem;
  padding-top: 2.4rem;
  border-top: 1px solid var(--proto-border);
}

.btn-secondary {
  padding: 1rem 2rem;
  background: transparent;
  color: var(--proto-text-primary);
  border: 1px solid var(--proto-border);
  border-radius: var(--proto-radius-m);
  font-size: var(--proto-text-s);
  font-weight: 600;
  font-family: var(--proto-font-family);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--proto-bg-hover);
}

.btn-primary {
  padding: 1rem 2rem;
  background: var(--proto-primary);
  color: white;
  border: none;
  border-radius: var(--proto-radius-m);
  font-size: var(--proto-text-s);
  font-weight: 600;
  font-family: var(--proto-font-family);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:hover {
  background: var(--proto-primary-hover);
}

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

/* ========================================
   EMPTY STATE
   ======================================== */

.empty-state {
  text-align: center;
  padding: 8rem 2rem;
  color: var(--proto-text-muted);
}

.empty-state-icon {
  font-size: 6.4rem;
  margin-bottom: 2.4rem;
  opacity: 0.3;
}

.empty-state-title {
  font-size: var(--proto-text-xl);
  font-weight: 600;
  color: var(--proto-text-primary);
  margin-bottom: 0.8rem;
}

.empty-state-description {
  font-size: var(--proto-text-m);
  margin-bottom: 2.4rem;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
  .items-grid {
    grid-template-columns: 1fr;
  }

  .global-topbar {
    padding: 1.6rem;
    flex-direction: column;
    align-items: stretch;
  }

  .global-main {
    padding: 1.6rem;
  }

  .modal {
    width: 95%;
    padding: 2rem;
  }
}
