@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  --bg-primary: #0a0d14;
  --bg-secondary: rgba(16, 20, 30, 0.6);
  --bg-card: rgba(22, 28, 45, 0.4);
  --border-color: rgba(255, 255, 255, 0.06);
  --border-focus: rgba(0, 242, 254, 0.5);
  
  --primary: #00f2fe;
  --primary-glow: rgba(0, 242, 254, 0.15);
  --secondary: #4facfe;
  --accent: #7f00ff;
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-inverse: #0a0d14;
  
  --status-active: #10b981;
  --status-inactive: #ef4444;
  --status-abandoned: #6b7280;
  --status-construction: #3b82f6;
  --status-critical: #f59e0b;
  
  --glass-blur: blur(16px);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Outfit', sans-serif;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

/* Custom scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Login Screen */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: radial-gradient(circle at top right, rgba(127, 0, 255, 0.15), transparent 40%),
              radial-gradient(circle at bottom left, rgba(0, 242, 254, 0.15), transparent 40%),
              var(--bg-primary);
  padding: 20px;
}

.login-card {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-color);
  padding: 40px;
  border-radius: 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  text-align: center;
  transform: translateY(0);
  animation: floatIn 0.6s ease-out;
}

@keyframes floatIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-logo {
  font-size: 2.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
  letter-spacing: -1px;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 32px;
}

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

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-field {
  width: 100%;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-main);
  font-size: 1rem;
  transition: var(--transition);
}

.input-field:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 12px var(--primary-glow);
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border: none;
  border-radius: 12px;
  color: var(--text-inverse);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 15px rgba(0, 242, 254, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 242, 254, 0.5);
  filter: brightness(1.1);
}

.btn-primary:active {
  transform: translateY(0);
}

.error-msg {
  color: var(--status-inactive);
  font-size: 0.85rem;
  margin-top: 12px;
  display: none;
}

/* App Layout */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 30px 20px;
  position: fixed;
  height: 100vh;
  z-index: 100;
}

.sidebar-logo {
  font-size: 1.8rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 40px;
  text-align: center;
}

.nav-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  color: var(--text-muted);
  border-radius: 12px;
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.nav-item i {
  margin-right: 12px;
  font-size: 1.2rem;
}

.nav-item:hover, .nav-item.active {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
  border-left: 3px solid var(--primary);
  background: linear-gradient(90deg, rgba(0, 242, 254, 0.06), transparent);
}

.sidebar-footer {
  margin-top: 20px;
  border-top: 1px solid var(--border-color);
  padding-top: 20px;
}

.user-info {
  font-size: 0.85rem;
  margin-bottom: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-info span {
  display: block;
  font-weight: 600;
  color: var(--text-main);
}

.user-info small {
  color: var(--text-muted);
}

.btn-logout {
  width: 100%;
  padding: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--status-inactive);
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.2);
}

/* Main Content Area */
.main-content {
  flex-grow: 1;
  margin-left: 260px;
  padding: 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

.header h1 {
  font-size: 2rem;
  font-weight: 600;
}

.selector-panel {
  display: flex;
  gap: 15px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: 16px;
}

.select-custom {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 0.95rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  padding-right: 20px;
}

.select-custom option {
  background: var(--bg-primary);
  color: var(--text-main);
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  transition: var(--transition);
}

.kpi-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.12);
}

.kpi-icon {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: rgba(0, 242, 254, 0.1);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.5rem;
  color: var(--primary);
}

.kpi-details h3 {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-bottom: 4px;
}

.kpi-details .value {
  font-size: 1.8rem;
  font-weight: 700;
}

/* Sections & Cards */
.view-section {
  display: none;
  animation: fadeIn 0.4s ease-out;
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.grid-2col {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 30px;
  margin-bottom: 30px;
}

.grid-equal {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  margin-bottom: 30px;
}

.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 28px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.panel-card h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-card h2 i {
  color: var(--primary);
}

/* Maps */
#map {
  height: 500px;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  z-index: 10;
}

/* Alert Lists */
.alert-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 380px;
  overflow-y: auto;
}

.alert-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 14px;
  background: rgba(239, 68, 68, 0.05);
  border: 1px solid rgba(239, 68, 68, 0.15);
  border-radius: 12px;
}

.alert-item.critical {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.25);
}

.alert-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--status-inactive);
  box-shadow: 0 0 8px var(--status-inactive);
  flex-shrink: 0;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.alert-text h4 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.alert-text p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Donut Chart Container */
.chart-container {
  position: relative;
  height: 250px;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Tables */
.table-container {
  overflow-x: auto;
  margin-top: 15px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.data-table th {
  padding: 14px 16px;
  border-bottom: 2px solid var(--border-color);
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-badge.active { background: rgba(16, 185, 129, 0.1); color: var(--status-active); }
.status-badge.inactive { background: rgba(239, 68, 68, 0.1); color: var(--status-inactive); }
.status-badge.abandoned { background: rgba(107, 114, 128, 0.1); color: var(--status-abandoned); }
.status-badge.construction { background: rgba(59, 130, 246, 0.1); color: var(--status-construction); }

/* Buttons */
.btn-action {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
  margin-right: 5px;
}

.btn-action:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-action.delete:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--status-inactive);
  border-color: rgba(239, 68, 68, 0.2);
}

.btn-success {
  background: var(--status-active);
  color: var(--text-inverse);
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-success:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 13, 20, 0.7);
  backdrop-filter: blur(8px);
  z-index: 200;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: rgba(18, 24, 38, 0.95);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  width: 100%;
  max-width: 600px;
  padding: 30px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  animation: floatIn 0.4s ease-out;
  max-height: 90vh;
  overflow-y: auto;
}

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

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  transition: var(--transition);
}

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
}

.form-grid .full-width {
  grid-column: span 2;
}

/* Canvas View for Well & Strata */
.canvas-wrapper {
  display: flex;
  justify-content: center;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 16px;
  border: 1px solid var(--border-color);
  padding: 20px;
  overflow: hidden;
}

#wellCanvas, #strataCanvas {
  max-width: 100%;
  background: transparent;
}

.detail-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.detail-list {
  list-style: none;
}

.detail-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
}

.detail-list li span:first-child {
  color: var(--text-muted);
}

.detail-list li span:last-child {
  font-weight: 500;
}

/* Layout modifications when screen is small */
@media (max-width: 1024px) {
  .grid-2col {
    grid-template-columns: 1fr;
  }
  .grid-equal {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    width: 80px;
    padding: 20px 10px;
  }
  .sidebar-logo {
    font-size: 1.2rem;
    margin-bottom: 20px;
  }
  .nav-item span, .user-info, .sidebar-footer button span {
    display: none;
  }
  .nav-item {
    justify-content: center;
    padding: 12px;
  }
  .nav-item i {
    margin-right: 0;
  }
  .main-content {
    margin-left: 80px;
    padding: 20px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-grid .full-width {
    grid-column: span 1;
  }
  .detail-columns {
    grid-template-columns: 1fr;
  }
}
