/* =====================================================
   Rebuilding the World - Map System Styles
   ===================================================== */

:root {
  --gold: #f4cf8b;
  --deep-purple: #311c35;
  --black: #000;
  --dark-bg: #1a1a1a;
  --border-color: #f4cf8b;
  --success: #4caf50;
  --warning: #ff9800;
  --error: #f44336;
  --info: #2196f3;
  --font-main: 'Raleway', sans-serif;
}

/* =====================================================
   RESET & BASE
   ===================================================== */

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

html, body {
  width: 100vw;
  height: 100vh;
  font-family: var(--font-main);
  background-color: var(--black);
  color: var(--gold);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* =====================================================
   HEADER
   ===================================================== */

header {
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.3));
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--gold);
  z-index: 1000;
}

header h1 {
  font-size: 2rem;
  color: var(--gold);
}

#menu-button {
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--gold);
  font-size: 1.5rem;
  padding: 0.25rem 0.75rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

#menu-button:hover {
  background: var(--gold);
  color: var(--black);
}

/* =====================================================
   NAVIGATION
   ===================================================== */

nav#dropdown-menu {
  background-color: var(--deep-purple);
  border-bottom: 1px solid var(--gold);
}

nav#dropdown-menu ul {
  list-style: none;
  display: flex;
  gap: 2rem;
  padding: 0.8rem 2rem;
  flex-wrap: wrap;
}

nav#dropdown-menu a {
  color: var(--gold);
  text-decoration: none;
  text-transform: uppercase;
  font-weight: 500;
  transition: color 0.3s ease;
}

nav#dropdown-menu a:hover {
  color: #fff;
  text-shadow: 0 0 8px var(--gold);
}

/* =====================================================
   MAP CONTAINER
   ===================================================== */

#game-map {
  flex: 1;
  width: 100%;
  touch-action: none;
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: linear-gradient(135deg, #0a1929 0%, #1a2332 50%, #0a1929 100%);
}

canvas {
  display: block;
  z-index: 1;
  position: relative;
}

/* =====================================================
   MAP UI CONTROLS
   ===================================================== */

#map-ui-controls {
  position: fixed;
  top: calc(7.5em + 2vh);
  left: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
  max-height: calc(100vh - 15vh);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 6px;
}

#map-ui-controls::-webkit-scrollbar {
  width: 6px;
}

#map-ui-controls::-webkit-scrollbar-track {
  background: rgba(49, 28, 53, 0.3);
  border-radius: 3px;
}

#map-ui-controls::-webkit-scrollbar-thumb {
  background: var(--gold);
  border-radius: 3px;
}

#zoom-controls,
#layer-controls,
#admin-controls,
#player-controls {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.control-group {
  background: rgba(49, 28, 53, 0.95);
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--gold);
}

.control-group h3 {
  font-size: 0.9rem;
  margin-bottom: 8px;
  color: var(--gold);
  text-transform: uppercase;
  border-bottom: 1px solid var(--gold);
  padding-bottom: 4px;
}

#map-ui-controls button,
#zoom-controls button,
#layer-controls button,
#admin-controls button,
#player-controls button {
  background: var(--deep-purple);
  color: var(--gold);
  border: 1px solid var(--gold);
  border-radius: 10px;
  font-size: 1rem;
  font-weight: bold;
  box-shadow: 0 0 8px rgba(244, 207, 139, 0.3);
  transition: all 0.3s ease;
  cursor: pointer;
}

#zoom-controls button {
  width: 50px;
  height: 40px;
  padding: 0;
  text-align: center;
}

#layer-controls button,
#admin-controls button,
#player-controls button {
  min-width: 130px;
  padding: 10px 16px;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
}

#map-ui-controls button:hover,
#zoom-controls button:hover,
#layer-controls button:hover,
#admin-controls button:hover,
#player-controls button:hover {
  background: var(--gold);
  color: var(--black);
  transform: scale(1.05);
  border-color: var(--gold);
}

#map-ui-controls button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

#map-ui-controls button.active {
  background: var(--gold);
  color: var(--black);
  box-shadow: 0 0 12px rgba(244, 207, 139, 0.6);
}

/* =====================================================
   BRUSH CONTROLS
   ===================================================== */

.brush-size-buttons {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.brush-size-buttons button {
  flex: 1;
  padding: 8px 12px;
  min-width: 0;
}

.resource-modifiers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

.resource-modifiers .form-group {
  margin-bottom: 0.5rem;
}

.resource-modifiers label {
  font-size: 0.9rem;
}

.resource-modifiers input[type="number"] {
  padding: 0.5rem;
  font-size: 0.9rem;
}

/* =====================================================
   LOADING SCREEN
   ===================================================== */

#map-loader {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.95);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  transition: opacity 1s ease;
}

.diamond-wrapper {
  position: relative;
  width: 120px;
  height: 120px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.diamond-frame {
  width: 80px;
  height: 80px;
  border: 2px solid var(--gold);
  position: relative;
  animation: pulseGlow 2s ease-in-out infinite;
  transform: rotate(45deg);
}

.glow-trace {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 2px solid var(--gold);
  box-shadow: 0 0 10px var(--gold);
  animation: glowTravel 2s linear infinite;
  transform: rotate(45deg);
  z-index: 1;
}

.diamond-line.left,
.diamond-line.right {
  position: absolute;
  top: 50%;
  width: 50px;
  height: 2px;
  background-color: var(--gold);
  z-index: 0;
}

.diamond-line.left {
  right: 100%;
  transform: translateY(-50%);
}

.diamond-line.right {
  left: 100%;
  transform: translateY(-50%);
}

.inner-diamond-bar {
  position: absolute;
  width: 20px;
  height: 20px;
  background-color: var(--gold);
  box-shadow: 0 0 6px var(--gold);
  transform: rotate(45deg);
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  z-index: 2;
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 8px var(--gold); }
  50% { box-shadow: 0 0 20px var(--gold); }
}

@keyframes glowTravel {
  0% { clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%); opacity: 0.1; }
  50% { opacity: 1; }
  100% { opacity: 0.1; }
}

.loading-text {
  margin-top: 3rem;
  font-size: 1.2rem;
  color: var(--gold);
  text-align: center;
  max-width: 300px;
}

/* =====================================================
   MODALS & PANELS
   ===================================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

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

.modal-content {
  background: var(--deep-purple);
  border: 2px solid var(--gold);
  border-radius: 12px;
  padding: 2rem;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 0 30px rgba(244, 207, 139, 0.5);
}

.modal-content h2 {
  color: var(--gold);
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--gold);
  padding-bottom: 0.5rem;
}

.modal-close {
  float: right;
  background: transparent;
  border: none;
  color: var(--gold);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  margin: -1rem -1rem 0 0;
}

.modal-close:hover {
  color: #fff;
}

/* =====================================================
   TILE INFO PANEL
   ===================================================== */

#tile-info-modal {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  background: rgba(49, 28, 53, 0.95);
  border: 1px solid var(--gold);
  border-radius: 10px;
  padding: 1rem;
  color: var(--gold);
  font-size: 0.85rem;
  font-family: var(--font-main);
  width: 300px;
  height: 220px;
  overflow-y: auto;
  z-index: 10001;
  box-shadow: 0 0 10px rgba(244, 207, 139, 0.4);
  display: none;
  transition: opacity 0.3s ease;
}

#tile-info-modal h2 {
  font-size: 1rem;
  font-family: var(--font-main);
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--gold);
  padding-bottom: 0.25rem;
}

#tile-info-modal .info-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

#tile-info-modal .info-label {
  font-weight: bold;
}

#tile-info-modal .info-value {
  text-align: right;
}

/* =====================================================
   FORMS
   ===================================================== */

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--gold);
  font-weight: bold;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--gold);
  border-radius: 6px;
  color: var(--gold);
  font-family: var(--font-main);
  font-size: 0.95rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #fff;
  box-shadow: 0 0 8px rgba(244, 207, 139, 0.5);
}

.form-group input[type="color"] {
  height: 50px;
  cursor: pointer;
}

.form-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

.btn {
  padding: 0.75rem 1.5rem;
  background: var(--deep-purple);
  color: var(--gold);
  border: 1px solid var(--gold);
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn:hover {
  background: var(--gold);
  color: var(--black);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(244, 207, 139, 0.4);
}

.btn.btn-secondary {
  background: transparent;
  border: 1px solid rgba(244, 207, 139, 0.5);
}

.btn.btn-danger {
  border-color: var(--error);
  color: var(--error);
}

.btn.btn-danger:hover {
  background: var(--error);
  color: #fff;
}

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

/* =====================================================
   COLOR PICKER
   ===================================================== */

.color-picker-wrapper {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.color-preview {
  width: 50px;
  height: 50px;
  border: 2px solid var(--gold);
  border-radius: 6px;
  cursor: pointer;
}

/* =====================================================
   NOTIFICATIONS
   ===================================================== */

#notification-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 10002;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 400px;
}

.notification {
  background: var(--deep-purple);
  border: 2px solid var(--gold);
  border-radius: 8px;
  padding: 1rem;
  color: var(--gold);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  animation: slideIn 0.3s ease;
}

.notification.success {
  border-color: var(--success);
}

.notification.error {
  border-color: var(--error);
}

.notification.warning {
  border-color: var(--warning);
}

.notification.info {
  border-color: var(--info);
}

@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* =====================================================
   FOOTER
   ===================================================== */

footer {
  background-color: var(--deep-purple);
  text-align: center;
  padding: 1rem;
  border-top: 2px solid var(--gold);
}

#discord-button {
  color: var(--gold);
  background-color: transparent;
  border: 1px solid var(--gold);
  padding: 0.6rem 1.2rem;
  border-radius: 9999px;
  text-decoration: none;
  font-weight: bold;
  transition: all 0.3s ease;
  display: inline-block;
}

#discord-button:hover {
  background-color: var(--gold);
  color: var(--black);
  transform: scale(1.05);
}

/* =====================================================
   UTILITY CLASSES
   ===================================================== */

.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.text-success {
  color: var(--success);
}

.text-error {
  color: var(--error);
}

.text-warning {
  color: var(--warning);
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

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

@media (max-width: 768px) {
  header h1 {
    font-size: 1.5rem;
  }

  nav#dropdown-menu ul {
    gap: 1rem;
    padding: 0.6rem 1rem;
  }

  #map-ui-controls {
    left: 10px;
    top: calc(6em + 2vh);
  }

  .modal-content {
    padding: 1.5rem;
    width: 95%;
  }

  #tile-info-modal {
    max-width: 280px;
    font-size: 0.8rem;
  }
}
