/* GLOBAL BASE STYLES */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Roboto', sans-serif;
  font-weight: 300;
  background: #000;
  color: #fff;
  overflow: auto;
  transition: background 0.3s, color 0.3s;
}
a { color: #fff; }
/* Sidebar Toggle Controls */
#sidebar-toggle-open {
  position: fixed;
  top: 10px;
  left: 10px;
  background: #333;
  color: #fff;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 20px;
  border-radius: 3px;
  z-index: 1100;
  display: none;
  box-shadow: 0 2px 8px rgba(150,150,150,0.5);
}
#sidebar-toggle-close {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 20px;
  color: #fff;
  cursor: pointer;
  display: none;
}
/* Main Layout */
#container {
  display: flex;
  height: 100vh;
  margin-top: 50px;
  transition: all 0.3s ease;
}
#sidebar {
  background: #000;
  border: 1px solid #333;
  border-radius: 3px;
  padding: 10px;
  overflow-y: auto;
  width: 210px; /* Previously 300px */
  margin: 8px; /* Previously 20px */
  box-shadow: 0 2px 8px rgba(150,150,150,0.5);
  transition: all 0.3s ease;
  position: relative;
}
#main-cards {
  flex: 1;
  overflow-y: auto;
  padding: 8px; /* Previously 20px */
  transition: all 0.3s ease;
}
/* Sidebar Cards */
details.card {
  margin-bottom: 12px;
  border: 1px solid #333;
  background: #000;
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(150,150,150,0.5);
}
details.card summary {
  padding: 10px;
  background: #000;
  border: none;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  list-style: none;
  position: relative;
}
details.card summary::-webkit-details-marker { display: none; }
details.card summary::after {
  content: '▼';
  position: absolute;
  right: 10px;
  font-size: 12px;
  transition: transform 0.2s ease;
}
details.card[open] summary::after { transform: rotate(-180deg); }
details.card > *:not(summary) {
  padding: 10px;
  border-top: 1px solid #333;
  background: #000;
}
/* Large Cards */
.large-card {
  border: 2px solid #333;
  background: #000;
  border-radius: 3px;
  margin-bottom: 20px;
  padding: 0;
  box-shadow: 0 2px 4px rgba(150,150,150,0.5);
  overflow: hidden;
}
.large-card h2 {
  padding: 10px;
  margin: 0;
  background: #111;
  border-bottom: 1px solid #333;
  font-size: 70%;
}
/* Game1 Production Styles */
#game1-root .game1-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 500px; /* Adjust as needed */
  padding: 0;
  position: relative;
}
#game1-root .game1-card {
  background: #161b22;
  box-shadow: none;
  border: 1px solid #000;
  border-radius: 8px;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}
/* Navigation in Game1 Card */
#game1-root .nav-buttons {
  display: none;
}
#game1-root .nav-buttons button {
  padding: 10px 18px;
  margin: 5px 10px;
  font-size: 1em;
  font-weight: 500;
  background: #21262d;
  color: #c9d1d9;
  border: 1px solid #30363d;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}
#game1-root .nav-buttons button:hover:not(:disabled) {
  background: #30363d;
  border-color: #8b949e;
}
#game1-root .nav-buttons button:disabled {
  background: #161b22;
  color: #444c56;
  border-color: #30363d;
  cursor: not-allowed;
}
/* Simulation Interface Styles */
.sim-param-container {
  width: 100%;
  border: 1px solid #333;
  border-radius: 3px;
  padding: 10px;
  margin-bottom: 10px;
  background: #000;
  box-shadow: 0 2px 4px rgba(150,150,150,0.5);
  cursor: pointer;
}
.sim-param-container p { font-size: 14px; }
#sim-plots { margin-top: 20px; }
#sim-plots canvas { width: 100% !important; height: 300px !important; }
/* Regional Summary Table Styles */
#resources-table table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  color: #fff;
}
#resources-table th, #resources-table td {
  padding: 8px;
  border: 1px solid #555;
  text-align: center;
}
#resources-table th { background-color: #111; }
/* Responsive Adjustments */
@media (max-width:768px) {
  /* Hide hamburger in mobile */
  #sidebar-toggle-open { display: none !important; }
  
  /* Set drawer default to 15% viewport height and fixed at bottom */
  #sidebar {
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 15vh; /* 15% of viewport height */
    margin: 0;
    border-radius: 2pt 2pt 0 0;
    border-top: 2px solid #555;
    transition: height 0.3s ease;
    z-index: 1000;
    touch-action: none;
  }
  
  /* Remove expanded/collapsed classes in mobile if any */
  #container.sidebar-collapsed #main-cards { margin: 0; padding: 20px; }
  
  #drawer-handle {
    width: 40px;
    height: 4px;
    background: #555;
    border-radius: 2px;
    margin: 8px auto;
    cursor: grab;
  }
  #main-cards .large-card { width: 100%; margin: 10px auto; }
  .large-card h2 { font-size: 80%; }
  body { font-size: 14px; }
  /* Add bottom margin to main content so plots aren't hidden by the drawer */
  #main-cards {
    margin-bottom: 30vh;
  }
  .graph-container {
    width: 95% !important;
    margin: 0 auto;
  }
  /* Force regional outcome rows to stack vertically */
  #regional-outcomes .regional-top-row,
  #regional-outcomes .regional-bottom-row {
    flex-direction: column !important;
    align-items: center;
  }
  /* Optionally, adjust each graph container's height */
  #regional-outcomes .graph-container {
    height: auto !important;
    min-height: 300px;
  }
}
/* Adjust iframe to fully fill its container */
#game1-root .game1-card iframe {
  width: 100%;
  height: 100%;
  border: none;
}
/* Sidebar toggle button (hamburger) */
#sidebar-toggle-open {
  display: block;
}

/* Sidebar collapsed state */
#sidebar.collapsed {
  width: 0;
  padding: 0;
  overflow: hidden;
  border: none;
  box-shadow: none;
}

/* Main content full width when sidebar is collapsed */
#container.sidebar-collapsed #main-cards {
  flex: 1;
  margin: 0;
  padding: 20px;
}

#game1-root .fullscreen-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 2000;
}
#game1-root .fullscreen-overlay iframe {
  width: 100%;
  height: 100%;
  border: none;
}
#game1-root .fullscreen-overlay .close-button {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #333;
  color: #fff;
  border: none;
  font-size: 20px;
  padding: 5px 10px;
  cursor: pointer;
  border-radius: 3px;
  z-index: 2100;
}
#game1-root .fullscreen-button {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: #333;
  color: #fff;
  border: none;
  font-size: 14px;
  padding: 5px 10px;
  cursor: pointer;
  border-radius: 3px;
}

/* Form and Input Styles */
input[type="text"], input[type="number"], select {
  background: #111;
  color: #fff;
  border: 1px solid #444;
  border-radius: 3px;
  padding: 5px 8px;
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  width: 100%;
  max-width: 300px;
}

input[type="text"]:focus, input[type="number"]:focus, select:focus {
  border-color: #666;
  outline: none;
  box-shadow: 0 0 3px rgba(200, 200, 200, 0.3);
}

.save-btn, .save-all-btn {
  margin-top: 0;
  min-width: 60px;
}

.action-buttons {
  margin-top: 20px;
  padding: 10px;
  display: flex;
  justify-content: center;
  gap: 8px;
}

.action-buttons button {
  margin: 0 10px;
  padding: 8px 16px;
}

/* Common Button Styles */
.btn {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 3px;
  border: none;
  font-size: 0.9em;
  cursor: pointer;
  text-decoration: none;
  background-color: #333;
  color: #fff;
}

.btn:hover {
  background-color: #444;
}

/* Color scheme for different button types */
.btn-edit {
  background-color: #20B2AA; /* Teal */
}

.btn-edit:hover {
  background-color: #48D1CC;
}

.btn-setup {
  background-color: #8e44ad; /* Purple */
}

.btn-setup:hover {
  background-color: #9b59b6;
}

.btn-copy {
  background-color: #16a085; /* Dark Teal */
}

.btn-copy:hover {
  background-color: #1abc9c;
}

.btn-delete {
  background-color: #c0392b; /* Red */
}

.btn-delete:hover {
  background-color: #e74c3c;
}

.btn-danger {
  background-color: #c0392b; /* Red */
  color: white;
}

.btn-danger:hover {
  background-color: #e74c3c;
}

.btn-create {
  background-color: #27ae60; /* Green */
  color: white;
}

.btn-create:hover {
  background-color: #2ecc71;
}

.btn-save {
  background-color: #2980b9; /* Blue */
  color: white;
}

.btn-save:hover {
  background-color: #3498db;
}

.btn-action {
  background-color: #d35400; /* Dark Orange */
  color: white;
}

.btn-action:hover {
  background-color: #e67e22;
}

.btn-back {
  background-color: #7f8c8d; /* Gray */
  color: white;
}

.btn-back:hover {
  background-color: #95a5a6;
}

.primary-btn {
  padding: 8px 16px;
  background-color: #27ae60;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.primary-btn:hover {
  background-color: #2ecc71;
}

/* Common Table Styles */
.management-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
}

.management-table th,
.management-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid #444;
}

.management-table th {
  background-color: #111;
  font-weight: 500;
}

.management-table tr:hover {
  background-color: #111;
}

.empty-message {
  text-align: center;
  padding: 20px;
  color: #777;
}

/* Status Badge Styles */
.status-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.8em;
  font-weight: 500;
}

.status-created {
  background-color: #2c3e50;
  color: #fff;
}

.status-running {
  background-color: #27ae60;
  color: #fff;
}

.status-paused {
  background-color: #f39c12;
  color: #000;
}

.status-completed {
  background-color: #7f8c8d;
  color: #fff;
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
}

.modal-content {
  background-color: #191919;
  margin: 10% auto;
  padding: 0;
  border-radius: 5px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  width: 80%;
  max-width: 500px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid #333;
}

.modal-header h3 {
  margin: 0;
}

.close-modal {
  color: #aaa;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}

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

.modal-body {
  padding: 20px;
}

/* Form Styles */
.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 8px;
  background-color: #333;
  border: 1px solid #444;
  border-radius: 3px;
  color: #fff;
}

.form-group textarea {
  min-height: 100px;
  resize: vertical;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

p.warning {
  color: #e74c3c;
  font-weight: bold;
}

/* Common Layout Utilities */
.mt-4 {
  margin-top: 20px;
}

.inline-form {
  display: inline;
}

.button-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.management-controls {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
  background-color: #191919;
}

/* Edit Form Styles */
.edit-form {
  max-width: 100%;
}

.form-section {
  margin-bottom: 25px;
  padding: 15px;
  background-color: #111;
  border-radius: 5px;
}

.form-section h3 {
  margin-top: 0;
  margin-bottom: 15px;
  font-size: 1.2em;
  color: #ccc;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 15px;
}

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

.checkbox-group input[type="checkbox"] {
  margin-right: 10px;
  width: auto;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  margin-bottom: 0;
}

/* Detail View Styles */
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.detail-section {
  margin-bottom: 30px;
  background-color: #111;
  padding: 15px;
  border-radius: 5px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 15px;
}

.detail-item {
  display: flex;
  flex-direction: column;
}

.detail-label {
  font-weight: bold;
  font-size: 0.9em;
  color: #888;
  margin-bottom: 5px;
}

.detail-value {
  font-size: 1.1em;
}

.detail-description {
  margin-top: 20px;
}

.detail-description h4 {
  margin-bottom: 10px;
  color: #888;
}