/* css/styles.css */

/* ── Variables ─────────────────────────────────────────────────────────── */
:root {
  --copper: #b57e69;
  --copper-light: #c99785;
  --copper-dark: #8b5e4b;
  --cream: #f8f7f4;
  --cream-dark: #ede9e3;
  --canvas-bg: #f0ede8;
  --charcoal: #181818;
  --gray: #7c7c7c;
  --gray-light: #d4cfc9;
  --white: #ffffff;
  --danger: #c0392b;
  --success: #27ae60;
  --warn: #e67e22;

  --sidebar-w: 240px;
  --prop-panel-w: 220px;
  --toolbar-h: 48px;
  --tabs-h: 40px;

  --radius: 6px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  --transition: 0.15s ease;
}

/* ── Reset ─────────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html,
body {
  height: 100%;
  overflow: hidden;
}
body {
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  color: var(--charcoal);
  background: var(--cream);
}
button {
  cursor: pointer;
  border: none;
  background: none;
  font: inherit;
}
input,
select,
textarea {
  font: inherit;
}
a {
  color: inherit;
  text-decoration: none;
}

/* ── Typography ────────────────────────────────────────────────────────── */
h1 {
  font-size: 1.5rem;
  font-weight: 600;
}
h2 {
  font-size: 1.1rem;
  font-weight: 600;
}
h3 {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray);
}

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  transition:
    background var(--transition),
    transform var(--transition);
}
.btn:active {
  transform: scale(0.97);
}
.btn-primary {
  background: var(--copper);
  color: var(--white);
}
.btn-primary:hover {
  background: var(--copper-dark);
}
.btn-secondary {
  background: var(--cream-dark);
  color: var(--charcoal);
  border: 1px solid var(--gray-light);
}
.btn-secondary:hover {
  background: var(--gray-light);
}
.btn-danger {
  background: var(--danger);
  color: var(--white);
}
.btn-icon {
  padding: 6px;
  border-radius: var(--radius);
}
.btn-icon:hover {
  background: var(--cream-dark);
}
.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

/* Tool buttons in designer toolbar */
.btn-tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 5px 10px;
  border-radius: var(--radius);
  font-size: 10px;
  color: var(--gray);
  transition:
    background var(--transition),
    color var(--transition);
}
.btn-tool:hover {
  background: var(--cream-dark);
  color: var(--charcoal);
}
.btn-tool.active {
  background: var(--copper);
  color: var(--white);
}
.btn-tool svg {
  width: 16px;
  height: 16px;
}

/* ── Form ──────────────────────────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.field label {
  font-size: 11px;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field input,
.field select {
  border: 1px solid var(--gray-light);
  border-radius: var(--radius);
  padding: 6px 8px;
  background: var(--white);
  color: var(--charcoal);
  transition: border-color var(--transition);
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--copper);
}
.field-row {
  display: flex;
  gap: 8px;
}
.field-row .field {
  flex: 1;
}

/* ── Index page ────────────────────────────────────────────────────────── */
.page-index {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: auto;
}
.page-index .topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: var(--white);
  border-bottom: 1px solid var(--cream-dark);
  box-shadow: var(--shadow);
  flex-shrink: 0;
}
.page-index .logo {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--copper-dark);
}
.page-index .content {
  flex: 1;
  padding: 32px 24px;
  overflow: auto;
}
.section {
  margin-bottom: 40px;
}
.section-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}
.page-index .content {
  max-width: 1200px;
}

/* ── Cards ─────────────────────────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.card {
  background: var(--white);
  border-radius: 10px;
  border: 1px solid var(--cream-dark);
  padding: 16px;
  cursor: pointer;
  transition:
    box-shadow var(--transition),
    transform var(--transition);
}
.card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.card-thumb {
  width: 100%;
  height: 120px;
  background: var(--canvas-bg);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.card-thumb .no-thumb {
  color: var(--gray-light);
  font-size: 2.5rem;
}
.card-name {
  font-weight: 600;
  margin-bottom: 4px;
}
.card-meta {
  font-size: 12px;
  color: var(--gray);
}
.card-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
.card-actions .btn {
  flex: 1;
  justify-content: center;
  font-size: 12px;
}
.card-add {
  border: 2px dashed var(--gray-light);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--gray);
  min-height: 160px;
}
.card-add:hover {
  border-color: var(--copper);
  color: var(--copper);
}

/* ── App shell (designer + planner) ────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-rows: var(--toolbar-h) 1fr;
  grid-template-columns: var(--sidebar-w) 1fr var(--prop-panel-w);
  height: 100vh;
  overflow: hidden;
}

/* Toolbar */
.toolbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 12px;
  background: var(--white);
  border-bottom: 1px solid var(--cream-dark);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  z-index: 10;
}
.toolbar .toolbar-logo {
  font-weight: 700;
  color: var(--copper-dark);
  margin-right: 8px;
}
.toolbar .divider {
  width: 1px;
  height: 28px;
  background: var(--cream-dark);
  margin: 0 4px;
}
.toolbar .toolbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}
.toolbar .breadcrumb {
  font-size: 12px;
  color: var(--gray);
}
.toolbar .breadcrumb strong {
  color: var(--charcoal);
}

/* Sidebar */
.sidebar {
  background: var(--white);
  border-right: 1px solid var(--cream-dark);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.sidebar-section {
  padding: 12px;
  border-bottom: 1px solid var(--cream-dark);
}
.sidebar-section h3 {
  margin-bottom: 8px;
}

/* Canvas area */
.canvas-area {
  position: relative;
  background: var(--canvas-bg);
  overflow: hidden;
}
.canvas-area canvas {
  display: block;
}

/* Variant tabs (bottom of canvas in planner) */
.variant-tabs-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--tabs-h);
  display: flex;
  align-items: flex-end;
  padding: 0 12px;
  gap: 4px;
  z-index: 5;
}
.variant-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 8px 8px 0 0;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: var(--cream-dark);
  color: var(--gray);
  border: 1px solid var(--gray-light);
  border-bottom: none;
  transition:
    background var(--transition),
    color var(--transition);
}
.variant-tab.active {
  background: var(--white);
  color: var(--charcoal);
}
.variant-tab-del {
  font-size: 11px;
  color: var(--gray);
  padding: 0 2px;
}
.variant-tab-del:hover {
  color: var(--danger);
}
.variant-tab-add {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 8px 8px 0 0;
  font-size: 18px;
  line-height: 1;
  color: var(--gray);
  cursor: pointer;
  background: none;
  border: 1px dashed var(--gray-light);
  border-bottom: none;
}
.variant-tab-add:hover {
  color: var(--copper);
  border-color: var(--copper);
}

/* Properties panel */
.prop-panel {
  background: var(--white);
  border-left: 1px solid var(--cream-dark);
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.prop-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.prop-empty {
  color: var(--gray);
  font-size: 12px;
  text-align: center;
  padding: 24px 0;
}

/* Capacity bar */
.cap-bar-wrap {
  background: var(--cream-dark);
  border-radius: 99px;
  height: 8px;
  overflow: hidden;
}
.cap-bar {
  height: 100%;
  border-radius: 99px;
  transition:
    width 0.3s,
    background 0.3s;
}
.cap-bar.ok {
  background: var(--success);
}
.cap-bar.warn {
  background: var(--warn);
}
.cap-bar.over {
  background: var(--danger);
}
.cap-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--gray);
}

/* Inventory item */
.inv-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: var(--radius);
  border: 1px solid var(--cream-dark);
  margin-bottom: 6px;
  cursor: grab;
  background: var(--white);
  transition: box-shadow var(--transition);
  user-select: none;
}
.inv-item:hover {
  box-shadow: var(--shadow);
}
.inv-swatch {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  flex-shrink: 0;
}
.inv-name {
  font-size: 12px;
  font-weight: 500;
  flex: 1;
}
.inv-qty {
  font-size: 11px;
  color: var(--gray);
}
.inv-qty.depleted {
  color: var(--danger);
  font-weight: 600;
}

/* Venue element items */
.venue-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: var(--radius);
  border: 1px solid var(--cream-dark);
  margin-bottom: 4px;
  cursor: grab;
  background: var(--white);
  font-size: 12px;
  font-weight: 500;
  transition: box-shadow var(--transition);
  user-select: none;
}
.venue-item:hover {
  box-shadow: var(--shadow);
}
.venue-icon {
  font-size: 18px;
  line-height: 1;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--white);
  border-radius: 12px;
  padding: 24px;
  min-width: 340px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}
.modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  background: var(--charcoal);
  color: var(--white);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  box-shadow: var(--shadow);
  animation:
    t-in 0.2s ease,
    t-out 0.3s ease 2.7s forwards;
}
.toast.success {
  background: var(--success);
}
.toast.error {
  background: var(--danger);
}
@keyframes t-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes t-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
    transform: translateY(12px);
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 5px;
}
::-webkit-scrollbar-thumb {
  background: var(--gray-light);
  border-radius: 99px;
}

/* Utils */
.hidden {
  display: none !important;
}
.flex-1 {
  flex: 1;
}
.mt-8 {
  margin-top: 8px;
}
.text-gray {
  color: var(--gray);
}
.text-small {
  font-size: 12px;
}
.text-center {
  text-align: center;
}

/* ── Sidebar toggle button (hidden on desktop) ────────────────────────── */
.btn-sidebar-toggle,
.btn-prop-toggle {
  display: none;
}
/* Drawer backdrop — always out of flow */
.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  top: var(--toolbar-h);
  background: rgba(0, 0, 0, 0.25);
  z-index: 35;
}
.drawer-backdrop.visible {
  display: block;
}

/* ── Responsive ───────────────────────────────────────────────────────── */

/* Tablet — sidebars become overlay drawers */
@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: var(--toolbar-h);
    bottom: 0;
    width: var(--sidebar-w);
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
  }
  .sidebar.open {
    transform: translateX(0);
  }

  .prop-panel {
    position: fixed;
    right: 0;
    top: var(--toolbar-h);
    bottom: 0;
    width: var(--prop-panel-w);
    z-index: 40;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    box-shadow: -2px 0 12px rgba(0, 0, 0, 0.15);
  }
  .prop-panel.open {
    transform: translateX(0);
  }

  /* Show toggle buttons */
  .btn-sidebar-toggle,
  .btn-prop-toggle {
    display: inline-flex;
  }

  /* Toolbar wraps */
  .toolbar {
    flex-wrap: wrap;
    min-height: var(--toolbar-h);
    height: auto;
    padding: 4px 8px;
    gap: 3px;
  }
  .toolbar .divider {
    display: none;
  }
  .toolbar .breadcrumb {
    order: 10;
    width: 100%;
    padding: 2px 0;
    font-size: 11px;
  }
}

/* Mobile — more compact */
@media (max-width: 600px) {
  :root {
    --sidebar-w: 200px;
    --prop-panel-w: 200px;
    --toolbar-h: 42px;
  }

  .page-index .topbar {
    padding: 8px 12px;
  }
  .page-index .content {
    padding: 16px 12px;
  }
  .section {
    margin-bottom: 24px;
  }
  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
  }
  .card {
    padding: 12px;
  }
  .card-thumb {
    height: 80px;
    margin-bottom: 8px;
  }
  .modal {
    min-width: auto;
    max-width: 95vw;
    padding: 16px;
  }
  .toast-container {
    bottom: 12px;
    right: 12px;
    left: 12px;
  }
  .toast {
    font-size: 12px;
  }
  .btn-tool {
    padding: 4px 6px;
    font-size: 9px;
  }
  .toolbar .toolbar-logo {
    font-size: 13px;
    margin-right: 4px;
  }
}
