/* ============================================
   MOBILE BUILDER VIEW STYLES
   ============================================ */

.mobile-builder-view {
  height: 100%;
  background: #111;
  color: white;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ============================================
   MISSION LIST
   ============================================ */

.mobile-builder-list {
  padding: 16px;
}

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

.list-header h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
}

.loading-state,
.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: #888;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.empty-icon {
  font-size: 48px;
  opacity: 0.5;
}

.mission-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mission-card {
  background: #1a1a1a;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 0;
  border: 1px solid #333;
  cursor: pointer;
  transition: all 0.2s;
}

.mission-card:hover {
  border-color: #555;
}

.mission-card:active {
  background: #222;
}

.mission-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.mission-card-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.mission-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

.badge-blue {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}

.badge-yellow {
  background: rgba(234, 179, 8, 0.2);
  color: #fde047;
}

.mission-card-route {
  font-size: 13px;
  color: #888;
  margin-bottom: 12px;
}

.mission-card-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 12px;
  padding: 12px;
  background: #111;
  border-radius: 8px;
}

.stat {
  text-align: center;
}

.stat-label {
  display: block;
  font-size: 10px;
  color: #666;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.stat-value {
  display: block;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}

.mission-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #666;
}

.tap-hint {
  color: #3b82f6;
}

.last-run {
  color: #888;
}

.mission-card-actions {
  display: flex;
  gap: 8px;
}

.mission-card-actions button {
  flex: 1;
}

/* ============================================
   MISSION DETAILS VIEW
   ============================================ */

.mobile-details-view {
  padding: 16px;
  padding-bottom: 100px;
}

.details-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.details-header h2 {
  margin: 0;
  font-size: 20px;
}

.back-btn {
  background: #333;
  border: none;
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}

.details-card {
  background: #1a1a1a;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid #333;
}

.details-card h3 {
  margin: 0 0 16px 0;
  font-size: 16px;
  color: #aaa;
  border-bottom: 1px solid #333;
  padding-bottom: 8px;
}

/* Map card in details */
.map-card {
  padding: 0;
  overflow: hidden;
}

.details-map {
  height: 200px;
  background: #111;
}

.details-map > div {
  height: 100% !important;
  width: 100% !important;
}

.map-loading {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  font-size: 14px;
}

.route-info-bar {
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
  background: #1a1a1a;
  font-size: 12px;
  color: #888;
  border-top: 1px solid #333;
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.stat-box {
  background: #111;
  padding: 16px 12px;
  border-radius: 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-icon {
  font-size: 20px;
}

.stat-big {
  font-size: 24px;
  font-weight: 700;
  color: #fff;
}

.stat-unit {
  font-size: 11px;
  color: #666;
  text-transform: uppercase;
}

/* Settings rows */
.settings-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #222;
  font-size: 14px;
}

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

.settings-row span:first-child {
  color: #888;
}

.settings-row span:last-child {
  color: #fff;
  font-weight: 500;
}

/* Action row in details */
.action-row {
  display: flex;
  gap: 8px;
}

.action-row button {
  flex: 1;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.detail-item {
  background: #111;
  padding: 10px;
  border-radius: 6px;
}

.detail-label {
  display: block;
  font-size: 10px;
  color: #666;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.detail-value {
  display: block;
  font-size: 15px;
  font-weight: 500;
  color: #fff;
}

.details-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-execute {
  font-size: 16px;
  padding: 14px;
}

/* ============================================
   SCHEDULE FORM & LIST
   ============================================ */

.schedule-form {
  background: #111;
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.schedule-form .form-group {
  margin-bottom: 12px;
}

.schedule-form .form-group:last-of-type {
  margin-bottom: 16px;
}

.day-picker {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.day-btn {
  width: 44px;
  height: 36px;
  border: 1px solid #444;
  background: #222;
  color: #888;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.day-btn.active {
  background: #3b82f6;
  border-color: #3b82f6;
  color: white;
}

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

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.schedule-form-actions {
  display: flex;
  gap: 8px;
}

.schedule-form-actions button {
  flex: 1;
}

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

.schedule-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: #111;
  border-radius: 8px;
  border-left: 3px solid #10b981;
}

.schedule-item.disabled {
  border-left-color: #666;
  opacity: 0.7;
}

.schedule-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.schedule-time {
  font-size: 18px;
  font-weight: 600;
}

.schedule-days {
  font-size: 12px;
  color: #888;
}

.schedule-next {
  font-size: 11px;
  color: #666;
}

.schedule-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.schedule-actions button {
  background: #333;
  border: none;
  color: #aaa;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}

.status-badge {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 10px;
  font-weight: 500;
}

.status-badge.active {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
}

.status-badge.inactive {
  background: rgba(156, 163, 175, 0.2);
  color: #9ca3af;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn-primary {
  background: #3b82f6;
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.btn-primary:hover {
  background: #2563eb;
}

.btn-primary:disabled {
  background: #555;
  cursor: not-allowed;
}

.btn-secondary {
  background: #333;
  color: white;
  border: 1px solid #555;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

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

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

.btn-danger {
  background: #dc2626;
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-add {
  width: 100%;
  background: transparent;
  color: #3b82f6;
  border: 2px dashed #3b82f6;
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 12px;
}

.btn-add:hover {
  background: rgba(59, 130, 246, 0.1);
}

.btn-save {
  width: 100%;
  background: #10b981;
  color: white;
  border: none;
  padding: 14px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 16px;
}

.btn-save:hover {
  background: #059669;
}

.btn-save:disabled {
  background: #555;
  cursor: not-allowed;
}

.back-btn {
  background: none;
  border: none;
  color: #3b82f6;
  font-size: 16px;
  cursor: pointer;
  padding: 0;
}

.refresh-btn {
  background: none;
  border: none;
  color: #3b82f6;
  font-size: 14px;
  cursor: pointer;
  margin-left: 8px;
}

/* ============================================
   BUILDER
   ============================================ */

.mobile-builder {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.builder-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #333;
  background: #1a1a1a;
}

.builder-header h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Progress indicator */
.builder-progress {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  background: #1a1a1a;
  border-bottom: 1px solid #333;
}

.progress-step {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #333;
  color: #888;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.progress-step.active {
  background: #3b82f6;
  color: white;
}

.progress-step.current {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

/* Builder content */
.builder-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.builder-step {
  padding: 16px;
}

.builder-step h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 16px 0;
}

/* Builder navigation */
.builder-nav {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid #333;
  background: #1a1a1a;
}

.builder-nav button {
  flex: 1;
}

/* ============================================
   FORM ELEMENTS
   ============================================ */

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

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: #aaa;
  margin-bottom: 6px;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select {
  width: 100%;
  padding: 12px;
  background: #222;
  border: 1px solid #444;
  border-radius: 6px;
  color: white;
  font-size: 16px;
  box-sizing: border-box;
}

.form-group input:focus,
.form-group select:focus {
  border-color: #3b82f6;
  outline: none;
}

.form-group input[type="range"] {
  width: 100%;
  margin-top: 8px;
}

.range-value {
  display: block;
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  color: #3b82f6;
  margin-top: 4px;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.speed-input {
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: center;
  background: #222;
  padding: 12px;
  border-radius: 8px;
}

.speed-input button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #333;
  color: white;
  border: none;
  font-size: 24px;
  cursor: pointer;
}

.speed-input button:hover {
  background: #444;
}

.speed-input span {
  font-size: 28px;
  font-weight: 600;
  min-width: 60px;
  text-align: center;
}

.loading-hint {
  display: block;
  font-size: 12px;
  color: #f59e0b;
  margin-top: 4px;
}

.success-hint {
  display: block;
  font-size: 12px;
  color: #10b981;
  margin-top: 4px;
}

/* ============================================
   ITEM LISTS (Feeds & Actions)
   ============================================ */

.empty-hint {
  text-align: center;
  padding: 24px;
  color: #666;
  font-style: italic;
}

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

.item-card {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 12px;
}

.feed-card {
  border-left: 3px solid #10b981;
}

.action-card {
  border-left: 3px solid #f59e0b;
}

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

.item-title {
  font-weight: 600;
  font-size: 14px;
}

.item-actions {
  display: flex;
  gap: 8px;
}

.item-actions button {
  background: none;
  border: none;
  color: #888;
  font-size: 14px;
  cursor: pointer;
  padding: 4px 8px;
}

.item-actions button:hover {
  color: white;
}

.item-details {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: #888;
}

/* ============================================
   REVIEW SECTION
   ============================================ */

.review-section {
  background: #1a1a1a;
  border-radius: 8px;
  overflow: hidden;
}

.review-item {
  display: flex;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #333;
}

.review-item:last-child {
  border-bottom: none;
}

.review-label {
  color: #888;
  font-size: 14px;
}

.review-value {
  font-weight: 500;
  font-size: 14px;
}

.validation-error {
  background: rgba(220, 38, 38, 0.2);
  border: 1px solid #dc2626;
  border-radius: 6px;
  padding: 12px;
  margin-top: 16px;
  color: #fca5a5;
  font-size: 14px;
  text-align: center;
}

/* ============================================
   MODAL
   ============================================ */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal {
  background: #1a1a1a;
  border-radius: 12px;
  width: 100%;
  max-width: 400px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

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

.modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.modal-header button {
  background: none;
  border: none;
  color: #888;
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid #333;
}

.modal-footer button {
  flex: 1;
}

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

@media (max-width: 360px) {
  .mission-card-stats {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .progress-step {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }
}

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

.map-container {
  margin-bottom: 16px;
}

.map-label {
  font-size: 12px;
  color: #888;
  margin-bottom: 8px;
}

.builder-map {
  position: relative;
  height: 250px;
  background: #1a1a1a;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #333;
}

.builder-map > div {
  height: 100% !important;
  width: 100% !important;
}

.map-overlay-msg {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  color: #888;
  font-size: 14px;
  z-index: 10;
}

.map-legend {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-size: 11px;
  color: #888;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

.legend-dot.blue { background: #3b82f6; }
.legend-dot.green { background: #10b981; }
.legend-dot.red { background: #ef4444; }
.legend-dot.orange { background: #f59e0b; }

/* ============================================
   MODE BADGES
   ============================================ */

.mode-badge {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}

.mode-badge.continuous {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}

.mode-badge.per-animal {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
}

/* ============================================
   TOGGLE BUTTONS
   ============================================ */

.toggle-buttons {
  display: flex;
  gap: 8px;
}

.toggle-btn {
  flex: 1;
  padding: 12px;
  border: 1px solid #444;
  background: #222;
  color: #888;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.toggle-btn.active {
  background: #3b82f6;
  border-color: #3b82f6;
  color: white;
}

.toggle-btn:not(.active):hover {
  background: #333;
  color: white;
}

/* ============================================
   FORM ENHANCEMENTS
   ============================================ */

.form-row {
  display: flex;
  gap: 12px;
}

.form-group.half {
  flex: 1;
}

.field-hint {
  display: block;
  font-size: 10px;
  color: #666;
  margin-top: 2px;
}

.calculated-total {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid #10b981;
  border-radius: 6px;
  padding: 12px;
  text-align: center;
  margin-bottom: 16px;
  color: #6ee7b7;
  font-size: 16px;
}

.calculated-total strong {
  color: #fbbf24;
  font-size: 18px;
}

/* Larger modal for feed form */
.modal-large {
  max-width: 450px;
  max-height: 85vh;
}

/* ============================================
   WAYPOINT INFO BAR
   ============================================ */

.waypoint-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #1a1a1a;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 14px;
  color: #aaa;
}

.waypoint-info strong {
  color: #3b82f6;
}

.btn-map {
  background: #333;
  border: 1px solid #555;
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

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

/* ============================================
   FULLSCREEN MAP PICKER
   ============================================ */

.map-picker-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #111;
  z-index: 2000;
  display: flex;
  flex-direction: column;
}

.map-picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #1a1a1a;
  border-bottom: 1px solid #333;
}

.map-picker-header span {
  font-size: 14px;
  color: #aaa;
}

.map-picker-header button {
  background: #333;
  color: white;
  border: 1px solid #555;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}

.map-picker-content {
  flex: 1;
  position: relative;
}

.map-picker-content > div {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}