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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #f5f5f5;
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 250px;
  background: linear-gradient(135deg, #434343 0%, #000000 100%);
  color: white;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 10px rgba(0,0,0,0.2);
  overflow-y: auto;
}

.profile-section {
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  background: rgba(0,0,0,0.3);
}

.profile-label {
  font-size: 0.85em;
  opacity: 0.7;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.profile-dropdown {
  width: 100%;
  padding: 10px;
  background: rgba(255,255,255,0.1);
  color: white;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  cursor: pointer;
  font-size: 1em;
  transition: all 0.3s;
}

.profile-dropdown:hover {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.3);
}

.profile-dropdown option {
  background: #434343;
  color: white;
}

.nav-menu {
  flex: 1;
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-item {
  padding: 12px 20px;
  cursor: pointer;
  transition: all 0.3s;
  border-left: 4px solid transparent;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.95em;
}

.nav-item:hover {
  background: rgba(255,255,255,0.1);
}

.nav-item.active {
  background: rgba(102, 126, 234, 0.2);
  border-left-color: #667eea;
  color: #667eea;
}

.nav-icon {
  font-size: 1.2em;
  width: 20px;
  text-align: center;
}

/* Main Content */
.main-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 20px 30px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header h1 {
  font-size: 1.8em;
  margin: 0;
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 30px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: white;
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  max-width: 400px;
  width: 90%;
}

.modal-content h2 {
  color: #434343;
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: #434343;
  font-weight: 500;
}

.form-group input {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 1em;
}

.form-group input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.button-group {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1em;
  transition: all 0.3s;
  font-weight: 500;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
  background: #e0e0e0;
  color: #434343;
}

.btn-secondary:hover {
  background: #d0d0d0;
}

.page-content {
  background: white;
  border-radius: 12px;
  padding: 30px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.page-content h2 {
  color: #434343;
  margin-bottom: 20px;
  font-size: 1.8em;
}

.page-description {
  color: #666;
  font-size: 0.95em;
  margin-bottom: 25px;
  padding: 15px;
  background: #f0f1ff;
  border-left: 4px solid #667eea;
  border-radius: 4px;
  line-height: 1.5;
}

.placeholder {
  color: #999;
  text-align: center;
  padding: 40px;
  font-style: italic;
}

/* Bonuses Page */
.bonuses-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
}

.bonuses-list {
  background: #f8f9ff;
  border-radius: 8px;
  padding: 20px;
  max-height: 600px;
  overflow-y: auto;
}

.bonuses-list h3 {
  color: #667eea;
  margin-bottom: 15px;
  font-size: 1.2em;
}

.bonus-item {
  background: white;
  padding: 12px;
  margin-bottom: 8px;
  border-radius: 6px;
  border-left: 4px solid #667eea;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 10px;
}

.bonus-item:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transform: translateX(5px);
}

.bonus-item.selected {
  background: #e8ecff;
  border-left-color: #764ba2;
}

.bonus-item-info {
  flex: 1;
  min-width: 0;
}

.bonus-name {
  font-weight: bold;
  color: #434343;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bonus-description {
  font-size: 0.8em;
  color: #999;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-style: italic;
}

.bonus-rules-count {
  font-size: 0.75em;
  color: #999;
  white-space: nowrap;
  background: #f0f0f0;
  padding: 3px 8px;
  border-radius: 3px;
  flex-shrink: 0;
}

.bonus-form {
  background: white;
  border-radius: 8px;
  padding: 20px;
  max-height: 600px;
  overflow-y: auto;
}

.bonus-form h3 {
  color: #667eea;
  margin-bottom: 15px;
  font-size: 1.2em;
}

.bonus-form-group {
  margin-bottom: 15px;
}

.bonus-form-group label {
  display: block;
  margin-bottom: 5px;
  color: #434343;
  font-weight: 500;
  font-size: 0.95em;
}

.bonus-form-group input,
.bonus-form-group textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.95em;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

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

.bonus-form-group input:focus,
.bonus-form-group textarea:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.bonus-rules {
  margin: 20px 0;
  padding: 15px;
  background: #f8f9ff;
  border-radius: 6px;
  border: 1px solid #e0e0ff;
}

.bonus-rules h4 {
  color: #434343;
  margin-bottom: 12px;
  font-size: 1em;
}

.bonus-rule {
  background: white;
  padding: 12px;
  margin-bottom: 10px;
  border-radius: 4px;
  border-left: 3px solid #667eea;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.bonus-rule:last-child {
  margin-bottom: 0;
}

.bonus-rule-details {
  flex: 1;
}

.bonus-rule-conditions {
  font-size: 0.85em;
  color: #666;
  margin-bottom: 5px;
}

.bonus-rule-values {
  font-size: 0.9em;
  color: #667eea;
  font-weight: 500;
}

.bonus-rule-toggle {
  background: #667eea;
  color: white;
  border: none;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85em;
  font-weight: bold;
  min-width: 32px;
}

.bonus-rule-toggle:hover {
  background: #764ba2;
}

.bonus-rule-edit {
  background: #667eea;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85em;
}

.bonus-rule-edit:hover {
  background: #764ba2;
}

.bonus-rule-delete {
  background: #ef4444;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85em;
}

.bonus-rule-delete:hover {
  background: #dc2626;
}

.bonus-rule.editing {
  background: #fff8e1;
  border-left-color: #fbbf24;
}

.bonus-rule.disabled {
  opacity: 0.6;
  background: #f5f5f5;
  border-left-color: #ccc;
}

.bonus-rule.disabled .bonus-rule-values {
  text-decoration: line-through;
  color: #999;
}

.health-stat {
  color: #10b981;
}

.strength-stat {
  color: #ef4444;
}

.add-rule-btn {
  background: #667eea;
  color: white;
  border: none;
  padding: 10px 15px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.95em;
  margin-top: 10px;
}

.add-rule-btn:hover {
  background: #764ba2;
}

.rule-input-group {
  background: #f8f9ff;
  padding: 15px;
  border-radius: 6px;
  margin-top: 15px;
  border: 1px solid #e0e0ff;
}

.rule-input-group h4 {
  color: #434343;
  margin-bottom: 12px;
  font-size: 1em;
}

.rule-input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.rule-input-row .bonus-form-group {
  margin-bottom: 0;
}

.rule-input-row input {
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.9em;
}

.rule-input-row input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.feature-select {
  width: 100%;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  max-height: 120px;
}

.feature-select:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.feature-select option {
  padding: 5px;
}

.selected-features {
  margin-top: 8px;
  padding: 8px;
  background: #f0f1ff;
  border-radius: 4px;
  min-height: 20px;
  font-size: 0.9em;
}

.selected-features:empty {
  display: none;
}

.form-buttons {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.form-buttons .btn {
  flex: 1;
}

.btn-delete {
  background: #ef4444;
  color: white;
}

.btn-delete:hover {
  background: #dc2626;
}

/* Army Page */
.bonus-tag {
  display: inline-block;
  background: #667eea;
  color: white;
  padding: 6px 12px;
  border-radius: 20px;
  margin-right: 8px;
  margin-bottom: 8px;
  font-size: 0.9em;
  align-items: center;
  gap: 8px;
}

.bonus-tag-remove {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 1.2em;
  padding: 0;
  margin-left: 6px;
  vertical-align: middle;
}

.bonus-tag-remove:hover {
  opacity: 0.8;
}

.troops-section {
  margin-top: 20px;
}

.troops-section h4 {
  color: #434343;
  margin-bottom: 15px;
  font-size: 1em;
}

.category-section {
  background: #f8f9ff;
  padding: 15px;
  border-radius: 6px;
  margin-bottom: 15px;
  border-left: 4px solid #667eea;
}

.category-section h5 {
  color: #667eea;
  margin-bottom: 12px;
  font-size: 0.95em;
  font-weight: 600;
}

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

.level-group {
  background: white;
  padding: 12px;
  border-radius: 6px;
  border: 1px solid #ddd;
}

.level-title {
  font-weight: bold;
  color: #667eea;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e0e0e0;
  font-size: 0.9em;
}

.troop-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 0.85em;
}

.troop-row:last-child {
  border-bottom: none;
}

.troop-name {
  color: #434343;
  flex: 1;
  margin-right: 10px;
}

.troop-count {
  width: 70px;
  padding: 5px;
  border: 1px solid #ddd;
  border-radius: 3px;
  font-size: 0.85em;
}

.troop-count:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.bonus-selector-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
}

.bonus-selector-content {
  background: white;
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  max-width: 400px;
  max-height: 500px;
  overflow-y: auto;
}

.bonus-selector-content h3 {
  color: #434343;
  margin-bottom: 20px;
}

.bonus-selector-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bonus-selector-item {
  padding: 12px;
  background: #f8f9ff;
  border: 1px solid #667eea;
  border-radius: 6px;
  cursor: pointer;
  color: #434343;
  transition: all 0.2s;
}

.bonus-selector-item:hover {
  background: #667eea;
  color: white;
  transform: translateX(5px);
}

/* Mobile Responsiveness */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 1.5em;
  cursor: pointer;
  padding: 10px 15px;
  margin-right: 15px;
}

.sidebar-toggle:hover {
  opacity: 0.8;
}

@media (max-width: 768px) {
  body {
    flex-direction: column;
  }

  .sidebar {
    position: fixed;
    left: -250px;
    top: 0;
    height: 100vh;
    width: 250px;
    z-index: 999;
    transition: left 0.3s ease;
  }

  .sidebar.open {
    left: 0;
  }

  .sidebar-toggle {
    display: block;
  }

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

  .header h1 {
    font-size: 1.4em;
    flex: 1;
    text-align: center;
  }

  .main-container {
    width: 100%;
    height: 100vh;
  }

  .content {
    padding: 20px;
  }

  .page-content {
    padding: 20px;
  }

  .page-content h2 {
    font-size: 1.5em;
  }

  /* Bonuses Page - Stack vertically on mobile */
  .bonuses-container {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .bonuses-list {
    max-height: none;
  }

  .bonus-form {
    max-height: none;
  }

  /* Army Page - Make level grid more compact */
  .level-container {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* Squads/Bonuses - Stack vertically on mobile */
  .squads-container {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .squads-list {
    max-height: none;
  }

  .squad-form {
    max-height: none;
  }

  /* Tables should be scrollable on mobile */
  .simulations-table {
    font-size: 0.85em;
  }

  .simulations-table table {
    min-width: 600px;
  }

  /* Modal adjustments for mobile */
  .modal-content {
    width: 95%;
    max-width: 100%;
    padding: 20px;
  }

  .bonus-selector-content {
    width: 95%;
    max-width: 100%;
    max-height: 70vh;
  }

  /* Button sizing for touch */
  .btn,
  .bonus-rule-edit,
  .bonus-rule-delete,
  .add-rule-btn {
    padding: 10px 15px;
    font-size: 0.95em;
  }

  /* Simulation page - stack scenarios vertically on mobile */
  [style*="grid-template-columns: 1fr 1fr"] {
    display: flex !important;
    flex-direction: column !important;
    gap: 20px !important;
  }

  /* Simulations table - switch from table to cards on mobile */
  .simulations-container {
    overflow-x: auto;
  }

  .simulations-table-desktop {
    display: none !important;
  }

  .simulations-list-mobile {
    display: flex;
    flex-direction: column;
    gap: 15px;
  }

  .simulation-card {
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  }

  .simulation-field {
    margin-bottom: 12px;
  }

  .simulation-field:last-of-type {
    margin-bottom: 12px;
  }

  .simulation-label {
    font-size: 0.85em;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  .simulation-select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: inherit;
  }

  .simulation-value {
    padding: 8px 0;
    color: #434343;
    font-weight: 500;
  }

  .simulation-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
  }

  .simulation-actions .btn {
    flex: 1;
    padding: 8px 10px;
    font-size: 0.85em;
  }
}

@media (min-width: 769px) {
  .simulations-list-mobile {
    display: none !important;
  }

  .simulations-table-desktop {
    display: table !important;
  }

  .simulations-container {
    overflow-x: visible;
  }
}
