/* Base Styles */
:root {
  --primary: #16a34a;
  --primary-dark: #15803d;
  --secondary: #2563eb;
  --background: #f1f5f9;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #cbd5f5;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
  --radius: 12px;
  --radius-sm: 8px;
}

/* Dark Theme */
body.dark {
  --primary: #22c55e;
  --primary-dark: #16a34a;
  --background: #020617;
  --card-bg: #0f172a;
  --text: #e5e7eb;
  --text-light: #94a3b8;
  --border: #334155;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.3);
}

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

body {
  background: var(--background);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  line-height: 1.6;
  transition: background-color 0.3s, color 0.3s;
}

/* Accessibility */
*:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* App Container */
.app {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

/* Top Controls */
.top-controls {
  position: fixed;
  top: 15px;
  right: 15px;
  display: flex;
  gap: 10px;
  z-index: 1000;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--card-bg);
  color: var(--text);
  box-shadow: var(--shadow);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all 0.3s;
}

.icon-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Header */
header {
  text-align: center;
  margin-bottom: 25px;
  padding-bottom: 15px;
  border-bottom: 2px solid var(--border);
}

h1 {
  font-size: 24px;
  margin-bottom: 10px;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

h1 i {
  font-size: 28px;
}

.last-update {
  font-size: 14px;
  color: var(--text-light);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* Controls Container */
.controls-container {
  background: var(--card-bg);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

/* Filters */
.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 15px;
  margin-bottom: 15px;
}

.select-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.select-wrapper i {
  position: absolute;
  left: 15px;
  color: var(--text-light);
  z-index: 1;
}

select {
  width: 100%;
  padding: 14px 15px 14px 45px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  appearance: none;
  transition: border-color 0.3s;
}

select:focus {
  border-color: var(--primary);
}

/* Search */
.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-wrapper i {
  position: absolute;
  left: 15px;
  color: var(--text-light);
}

#search {
  width: 100%;
  padding: 14px 15px 14px 45px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  font-size: 15px;
  transition: border-color 0.3s;
}

#search:focus {
  border-color: var(--primary);
}

/* Meta & Actions */
.meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 15px;
}

#resultCount {
  font-size: 15px;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.action-btn {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--card-bg);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s;
  box-shadow: var(--shadow);
}

.action-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

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

.action-btn.active {
  background: var(--primary);
  color: white;
}

.call-btn {
  background: var(--primary);
  color: white;
}

.call-btn:hover {
  background: var(--primary-dark);
}

.fav-badge {
  background: gold;
  color: #1e293b;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: bold;
  margin-left: 8px;
}

/* Map Container */
.map-container {
  position: relative;
  height: 250px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 25px;
}

#map {
  height: 100%;
  width: 100%;
}

.map-controls {
  position: absolute;
  bottom: 15px;
  right: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
}

.map-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: white;
  color: #1e293b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  transition: all 0.3s;
}

.map-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

/* Map Popup */
.map-popup {
  padding: 10px;
}

.map-call-btn {
  margin-top: 8px;
  padding: 6px 12px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Sections */
.section {
  margin-bottom: 25px;
}

.section h2 {
  font-size: 16px;
  padding: 12px 15px;
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
}

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  padding: 18px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
  transition: transform 0.3s, box-shadow 0.3s;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.card-content {
  flex: 1;
}

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

.card-header strong {
  font-size: 16px;
  color: var(--text);
}

.phone-count {
  background: var(--background);
  color: var(--text-light);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
}

.fav {
  color: #94a3b8;
  cursor: pointer;
  font-size: 18px;
  transition: color 0.3s;
}

.fav:hover {
  color: gold;
}

.fav.active {
  color: gold;
}

/* Phone List */
.phone-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.phone-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  background: var(--background);
  border-radius: 8px;
  width: 95%;
}

.phone-number {
  font-family: 'Courier New', monospace;
  font-size: 15px;
  color: var(--text);
}

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

.phone-actions button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--card-bg);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
}

.phone-actions button:hover {
  background: var(--primary);
  color: white;
  transform: scale(1.1);
}

/* Card Actions */
.card-actions {
  display: flex;
  gap: 10px;
}

.card-actions .action-btn {
  padding: 8px 12px;
  font-size: 13px;
}

.call-all {
  background: var(--primary);
  color: white;
}

.share-counter {
  background: var(--secondary);
  color: white;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
}

.empty-state i {
  font-size: 48px;
  margin-bottom: 15px;
  color: var(--border);
}

.empty-state h3 {
  margin-bottom: 10px;
  color: var(--text);
}

/* Offline Status */
.offline-alert {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #dc2626;
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius);
  display: none;
  align-items: center;
  gap: 10px;
  z-index: 1000;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateX(-50%) translateY(100px);
    opacity: 0;
  }
  to {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  overflow-y: auto;
}

.modal-content {
  background: var(--card-bg);
  margin: 50px auto;
  width: 90%;
  max-width: 500px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: modalFade 0.3s ease-out;
}

@keyframes modalFade {
  from {
    opacity: 0;
    transform: translateY(-50px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.modal-header h3 {
  display: flex;
  align-items: center;
  gap: 10px;
}

.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-light);
  cursor: pointer;
  transition: color 0.3s;
}

.close-btn:hover {
  color: var(--text);
}

.modal-body {
  padding: 20px;
}

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

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  color: var(--text);
  font-size: 15px;
  transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  outline: none;
}

.submit-btn {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background-color 0.3s;
}

.submit-btn:hover {
  background: var(--primary-dark);
}

/* Call Options */
.call-header {
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border);
}

.call-header h4 {
  display: flex;
  align-items: center;
  gap: 10px;
}

.call-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  background: var(--background);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}

.call-info {
  flex: 1;
}

.call-bus {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 4px;
}

.call-counter {
  font-weight: 500;
  color: var(--text);
}

.call-action {
  display: flex;
  align-items: center;
  gap: 15px;
}

.call-phone {
  font-family: 'Courier New', monospace;
  font-size: 14px;
}

.call-option-btn {
  padding: 8px 15px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background-color 0.3s;
}

.call-option-btn:hover {
  background: var(--primary-dark);
}

/* Toast Notifications */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--card-bg);
  color: var(--text);
  padding: 15px 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 1000;
  transform: translateY(100px);
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast-success {
  border-left: 4px solid var(--primary);
}

.toast-warning {
  border-left: 4px solid #f59e0b;
}

.toast-info {
  border-left: 4px solid var(--secondary);
}

/* Responsive Design */
@media (max-width: 768px) {
  .app {
    padding: 15px;
  }
  
  h1 {
    font-size: 20px;
  }
  
  .filters {
    grid-template-columns: 1fr;
  }
  
  .meta {
    flex-direction: column;
    align-items: stretch;
  }
  
  .action-buttons {
    justify-content: center;
  }
  
  .card {
    flex-direction: column;
    gap: 15px;
  }
  
  .card-actions {
    width: 100%;
    justify-content: stretch;
  }
  
  .card-actions .action-btn {
    flex: 1;
    justify-content: center;
  }
  
  .modal-content {
    width: 95%;
    margin: 20px auto;
  }
  
  .top-controls {
    top: 10px;
    right: 10px;
  }
  
  .icon-btn {
    width: 40px;
    height: 40px;
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  .phone-item {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }
  
  .phone-actions {
    width: 100%;
    justify-content: center;
  }
  
  .map-container {
    height: 200px;
  }
}

/* Add this at the end of your existing style.css */

/* Fix for map display */
#map {
  height: 100%;
  width: 100%;
  min-height: 200px;
}

/* Fix for phone number display in dark mode */
.dark .phone-number {
  color: #e5e7eb !important;
}

/* Fix for map popup in dark mode */
.dark .map-popup {
  color: #1e293b;
}

/* Ensure map controls are visible */
.map-controls {
  position: absolute;
  bottom: 15px;
  right: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
}

/* Fix for loading spinner */
.fa-spinner {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}