/* S-Tier List Maker Styles */

/* ============================== */
/* GOOGLE FONTS IMPORT */
@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap");

/* ============================== */
/* CSS VARIABLES */
:root {
  /* Base Colors */
  --bg-primary: #050505;
  --bg-secondary: #0f0f0f;
  --bg-tertiary: #1a1a1a;
  /* Text Colors */
  --text-primary: #f5f5f5;
  --text-secondary: #b3b3b3;
  /* Border Colors */
  --border-color: #2a2a2a;
  --border-hover: #404040;
  /* Effects */
  --shadow: rgba(0, 0, 0, 0.6);
  /* Accent Colors */
  --accent-primary: #4d4d4d;
  --accent-primary-light: #666666;
  --accent-primary-dark: #333333;
  --accent-danger: #942b2b;
  /* Panel Colors (Replaces Glass) */
  --panel-bg: #0f0f0f;
  --panel-border: #2a2a2a;
}

/* ============================== */
/* BASE STYLES */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
body {
  font-family:
    "Space Grotesk",
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Oxygen,
    Ubuntu,
    Cantarell,
    sans-serif;
  background-color: #0a0a0a;
  background-image: linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 30px 30px;
  background-position: center top;
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
}
.container {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
::selection {
  background-color: #ffffff;
  color: #0a0a0a;
}

/* ============================== */
/* HEADER */
header {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  padding: 24px 16px;
  text-align: center;
  border-bottom: 4px solid var(--accent-primary);
  box-shadow: 0 4px 12px var(--shadow);
}
header h1 {
  font-size: 2.75rem;
  margin-bottom: 12px;
  color: var(--text-primary);
  font-weight: 900;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
header p {
  color: var(--text-secondary);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}

/* ============================== */
/* CONTROLS SECTION */
.controls {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  padding: 16px;
  box-shadow: 0 2px 8px var(--shadow);
}
.control-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

/* ============================== */
/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid transparent;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  justify-content: center;
  transition:
    opacity 0.15s ease,
    background 0.15s ease,
    border-color 0.15s ease;
  white-space: nowrap;
}
.btn-icon {
  display: inline-flex;
  align-items: center;
}
.btn-label {
  display: inline-flex;
  align-items: center;
}
.btn svg {
  width: 18px;
  height: 18px;
}
.btn:hover {
  opacity: 0.85;
}
.btn:active {
  opacity: 0.7;
}
.btn-primary,
.btn-secondary,
.btn-success {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-color);
  box-shadow: 0 1px 3px var(--shadow);
}
.btn-primary:hover,
.btn-secondary:hover,
.btn-success:hover {
  background: var(--border-hover);
  border-color: var(--accent-primary-light);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-danger {
  background: var(--accent-danger);
  color: #fff;
  border-color: #ff4d4d;
  box-shadow: 0 1px 3px var(--shadow);
}
.btn-danger:hover {
  background: #ff3333;
  border-color: #ff6666;
}

/* ============================== */
/* TIER LIST */
.tier-list {
  border: 1px solid var(--panel-border);
  overflow: hidden;
  background: var(--panel-bg);
  box-shadow: 0 4px 12px var(--shadow);
}
.tier-row {
  display: flex;
  min-height: 80px;
  border-bottom: 1px solid var(--border-color);
}
.tier-row:last-child {
  border-bottom: none;
}
.tier-label {
  min-width: 100px;
  width: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: bold;
  cursor: pointer;
  user-select: none;
  border-right: 1px solid var(--border-color);
  color: #4d4343;
  text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.3);
  padding: 8px;
  word-break: break-word;
  text-align: center;
  transition: filter 0.15s ease;
}
.tier-label:hover {
  filter: brightness(0.9);
}
.tier-label:focus {
  outline: 2px solid var(--accent-primary);
  outline-offset: -2px;
}
.tier-content {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  align-content: flex-start;
  gap: 1px;
  padding: 1px;
  min-height: 82px;
}
.tier-content.drag-over {
  background: rgba(255, 255, 255, 0.04);
}
.tier-controls {
  width: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-left: 5px solid;
  background: var(--bg-secondary);
}
.tier-controls button {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    opacity 0.15s ease;
}
.tier-controls button:hover {
  background: var(--border-hover);
  border-color: var(--accent-primary-light);
}
.tier-controls svg {
  width: 20px;
  height: 20px;
  display: block;
}

/* ============================== */
/* TIER ITEMS */
.tier-item {
  width: 80px;
  height: 80px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  cursor: move;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: border-color 0.15s ease;
}
.tier-item:hover {
  border-color: var(--accent-primary);
}
.tier-item:active,
.tier-item.dragging {
  cursor: grabbing;
}
.tier-item.dragging {
  opacity: 0.4;
}
.tier-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.tier-item.text-item {
  padding: 6px;
  text-align: center;
  font-weight: 600;
  line-height: 1.2;
  word-break: break-word;
  overflow-wrap: anywhere;
  hyphens: auto;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================== */
/* ITEMS POOL */
.items-pool-container {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  padding: 24px;
  box-shadow: 0 4px 12px var(--shadow);
}
.items-pool-container h3 {
  margin-bottom: 10px;
  color: var(--text-primary);
  font-size: 1.1rem;
  font-weight: 700;
}
.items-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  min-height: 86px;
  padding: 1px;
  background: var(--bg-tertiary);
  border: 2px dashed var(--border-color);
  transition:
    background 0.15s ease,
    border-color 0.15s ease;
}
.items-pool.drag-over {
  background: var(--border-hover);
  border-color: var(--text-secondary);
}
.items-pool:empty::before {
  content: "Drop items here or add images/text above";
  display: block;
  width: 100%;
  text-align: center;
  color: var(--text-primary);
  font-style: italic;
  padding: 50px 0;
}
.tier-actions {
  display: flex;
  justify-content: flex-end;
}
.btn-full-width {
  width: 100%;
}

/* ============================== */
/* SCROLLBAR (CUSTOM) */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: #0a0a0a;
  border-left: 1px solid var(--border-color);
}
::-webkit-scrollbar-thumb {
  background: #333;
  border: 2px solid #0a0a0a;
  border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* ============================== */
/* MODAL */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}
.modal.hiding {
  animation: fadeOut 0.15s ease forwards;
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}
.modal-content {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  padding: 32px;
  min-width: 400px;
  max-width: 90%;
  animation: slideUp 0.15s ease;
  box-shadow: 0 8px 32px var(--shadow);
}
.modal.hiding .modal-content {
  animation: slideDown 0.15s ease forwards;
}
@keyframes slideUp {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes slideDown {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}
.modal-content h3 {
  margin-bottom: 15px;
  font-size: 1.3rem;
  font-weight: 700;
}
.form-group {
  margin-bottom: 12px;
}
.form-group label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-primary);
  font-weight: 600;
}
.modal-content input[type="text"],
.modal-content input[type="color"] {
  width: 100%;
  padding: 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 0;
  color: var(--text-primary);
  font-size: 1rem;
  transition: all 0.2s ease;
}
.modal-content input[type="text"]:focus,
.modal-content input[type="color"]:focus {
  outline: none;
  border-color: var(--text-secondary);
  background: var(--bg-secondary);
}
.modal-content input[type="color"] {
  height: 40px;
  cursor: pointer;
}
.modal-content input[type="color"]:hover {
  border-color: var(--border-hover);
}
.modal-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 15px;
}
#tierModalDelete {
  margin-right: auto;
}
#confirmMessage {
  margin-bottom: 15px;
  color: var(--text-primary);
  font-size: 1rem;
  line-height: 1.4;
}

/* ============================== */
/* APP FOOTER */
.app-footer {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  padding: 24px;
  box-shadow: 0 4px 12px var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.app-footer p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 500;
}
.pizza-btn {
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.05em;
}

/* ============================== */
/* RESPONSIVE DESIGN */
@media (max-width: 768px) {
  body {
    padding: 6px;
  }
  .container {
    gap: 6px;
  }
  header {
    padding: 16px 12px;
  }
  .controls {
    padding: 10px;
  }
  .items-pool-container {
    padding: 12px;
  }
  .tier-label {
    min-width: 56px;
    width: 56px;
    font-size: 1.1rem;
  }
  .tier-item {
    width: 56px;
    height: 56px;
  }
  header h1 {
    font-size: 1.75rem;
  }
  .control-group {
    flex-direction: column;
    gap: 10px;
  }
  .btn {
    width: 100%;
    justify-content: space-between;
    padding: 14px 16px;
    font-size: 1rem;
  }
  .btn-label {
    order: 1;
  }
  .btn-icon {
    order: 2;
    margin-left: 12px;
  }
  .modal-content {
    min-width: auto;
    width: 95%;
    padding: 20px;
  }
  .modal-buttons {
    flex-direction: column;
  }
  #tierModalDelete {
    margin-right: 0;
    order: 3;
  }
  .tier-row {
    min-height: 58px;
  }
  .tier-content {
    min-height: 58px;
    padding: 1px;
  }
  .items-pool {
    min-height: 62px;
    padding: 1px;
  }
  .items-pool:empty::before {
    padding: 20px 0;
  }
  .tier-controls {
    width: 36px;
    flex-direction: column;
    gap: 2px;
  }
  .tier-controls button {
    margin-left: 1px;
    width: 26px;
    height: 26px;
  }
  .tier-controls svg {
    width: 16px;
    height: 16px;
  }
  .tier-actions {
    justify-content: center;
  }
  .app-footer {
    flex-direction: column;
    text-align: center;
    padding: 16px;
    gap: 12px;
  }
  .pizza-btn {
    width: 100%;
    justify-content: center;
  }
}

/* ============================== */
/* PRINT STYLES */
@media print {
  .controls,
  .items-pool-container {
    display: none !important;
  }
}

/* ============================== */
/* UTILITY ANIMATIONS */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
