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

:root {
  --bg-color: #0c0d12;
  --panel-bg: rgba(18, 20, 30, 0.7);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(0, 229, 255, 0.25);
  
  --text-main: #f0f2f5;
  --text-muted: #8d92a0;
  
  --primary: #00e5ff;
  --primary-glow: rgba(0, 229, 255, 0.4);
  --secondary: #9d4edd;
  --secondary-glow: rgba(157, 78, 221, 0.4);
  
  --green: #00e676;
  --green-glow: rgba(0, 230, 118, 0.3);
  --red: #ff1744;
  --red-glow: rgba(255, 23, 68, 0.3);
  --yellow: #ffea00;
}

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

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(157, 78, 221, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(0, 229, 255, 0.05) 0%, transparent 45%);
  background-attachment: fixed;
}

/* ================= LOGIN STYLING ================= */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.login-card {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  width: 100%;
  max-width: 420px;
  padding: 2.5rem;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.login-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.login-header h2 {
  font-size: 1.5rem;
  margin-top: 0.5rem;
  font-weight: 700;
}

.login-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.2rem;
}

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

.form-group input, .form-input {
  background-color: rgba(12, 13, 18, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

.form-group input:focus, .form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 8px var(--primary-glow);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  border: none;
  border-radius: 8px;
  padding: 0.8rem;
  color: #0c0d12;
  font-family: inherit;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 4px 15px rgba(0, 229, 255, 0.2);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 229, 255, 0.35);
}

.login-error-msg {
  color: var(--red);
  background-color: rgba(255, 23, 68, 0.08);
  border: 1px solid rgba(255, 23, 68, 0.2);
  border-radius: 8px;
  padding: 0.6rem;
  font-size: 0.85rem;
  text-align: center;
}

.login-footer {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  padding-top: 1rem;
  line-height: 1.4;
}

/* ================= DASHBOARD HEADER ================= */
header {
  backdrop-filter: blur(12px);
  background-color: rgba(12, 13, 18, 0.75);
  border-bottom: 1px solid var(--border-color);
  padding: 1.2rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.logo h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.company-subname {
  font-size: 0.85rem;
  color: var(--primary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.logo-icon {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #0c0d12;
  box-shadow: 0 0 15px var(--primary-glow);
}

.server-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  border: 1px solid var(--border-color);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse 2s infinite;
}

.status-dot.disconnected {
  background-color: var(--red);
  box-shadow: 0 0 8px var(--red);
}

.btn-logout {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-logout:hover {
  background: rgba(255, 23, 68, 0.1);
  border-color: rgba(255, 23, 68, 0.25);
  color: var(--red);
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.5; }
  50% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.5; }
}

main {
  flex: 1;
  padding: 1.5rem;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Tarjetas de Métricas */
.metrics-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.2rem;
}

.metric-card {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.3s ease;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
}

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

.metric-info h3 {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-main);
}

.metric-card.registered .metric-value { color: var(--primary); text-shadow: 0 0 10px rgba(0, 229, 255, 0.2); }
.metric-card.online .metric-value { color: var(--green); text-shadow: 0 0 10px rgba(0, 230, 118, 0.2); }
.metric-card.offline .metric-value { color: var(--text-muted); }

.metric-icon {
  font-size: 2rem;
  opacity: 0.7;
}

/* Contenido Principal */
.dashboard-grid {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* Contenedor Panel */
.panel {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
}

.panel-header {
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.01);
}

.panel-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* Lista de Dispositivos */
.device-list-container {
  max-height: 600px;
  overflow-y: auto;
}

.device-item {
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.device-item:hover, .device-item.active {
  background: rgba(255, 255, 255, 0.03);
}

.device-item.active {
  border-left: 3px solid var(--primary);
  background: rgba(0, 229, 255, 0.04);
}

.device-main-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  overflow: hidden;
  flex: 1;
}

.device-model {
  font-weight: 600;
  font-size: 1rem;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.device-id {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: monospace;
}

.device-item-status {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.3rem;
  margin-left: 0.5rem;
}

.device-badge-status {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  text-transform: uppercase;
}

.device-badge-status.online {
  background-color: rgba(0, 230, 118, 0.1);
  color: var(--green);
  border: 1px solid rgba(0, 230, 118, 0.25);
}

.device-badge-status.offline {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.device-item-net {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Área de Mapa y Detalle */
.view-area {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

#map-container {
  height: 400px;
  position: relative;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  overflow: hidden;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
}

#map {
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Secciones de Detalles del Dispositivo Seleccionado */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 768px) {
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

.detail-card {
  height: 380px;
  display: flex;
  flex-direction: column;
}

.detail-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 1.2rem;
}

/* Lista de Especificaciones de Hardware */
.spec-list {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.spec-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  font-size: 0.95rem;
  gap: 1rem;
}

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

.spec-name {
  color: var(--text-muted);
}

.spec-val {
  font-weight: 500;
  text-align: right;
  word-break: break-all;
}

/* Modificación de Alias de Dispositivo */
.alias-edit-row {
  display: flex;
  gap: 0.5rem;
  width: 100%;
  justify-content: flex-end;
}
.alias-input {
  background: rgba(12, 13, 18, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  color: #fff;
  font-size: 0.9rem;
  width: 180px;
  font-family: inherit;
}
.alias-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* Historial Web / URLs */
.web-history-list {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.web-history-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  padding: 0.8rem;
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  transition: background 0.2s ease;
}

.web-history-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.web-url-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  overflow: hidden;
  flex: 1;
}

.web-url-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.web-url-link:hover {
  text-decoration: underline;
}

.web-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.web-data-badge {
  background: rgba(157, 78, 221, 0.15);
  color: #c77dff;
  border: 1px solid rgba(157, 78, 221, 0.3);
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: monospace;
  white-space: nowrap;
}

/* ================= INVENTARIO FÍSICO Y FOTOS ================= */
.inline-form {
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.8rem;
}

.file-upload-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.file-upload-wrapper input[type="file"] {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.8rem;
}

.photo-item {
  border-radius: 8px;
  border: 1px solid var(--border-color);
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  position: relative;
  cursor: pointer;
  transition: all 0.2s ease;
}

.photo-item:hover {
  border-color: var(--primary);
  transform: scale(1.02);
}

.photo-thumb {
  width: 100%;
  height: 90px;
  object-fit: cover;
}

.photo-notes {
  padding: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

/* ================= INTERVENCIONES Y TIMELINE ================= */
.form-row-multi {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.interventions-timeline {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.intervention-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--secondary);
  border-radius: 8px;
  padding: 0.8rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
}

.int-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
}

.int-desc {
  font-weight: 500;
  font-size: 0.9rem;
}

.int-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.int-cost {
  color: var(--green);
  font-weight: 600;
  font-family: monospace;
  font-size: 0.95rem;
  background: rgba(0, 230, 118, 0.08);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

/* Personalización de Scrollbars */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Sin Selección */
.no-selection {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  gap: 1rem;
  padding: 2rem;
  text-align: center;
}

.no-selection-icon {
  font-size: 3rem;
  opacity: 0.3;
}
