/* ═══════════════════════════════════════════════════════════
   🎨 ESTILOS ESPECÍFICOS DEL DASHBOARD
   ═══════════════════════════════════════════════════════════ */

:root {
  --radius: 15px;
}

/* ═══════════════════════════════════════════════════════════
   📋 HEADER
   ═══════════════════════════════════════════════════════════ */
.header {
  background: white;
  padding: 30px;
  border-radius: 15px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.1);
  margin-bottom: 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header h1 {
  color: #667eea;
  font-size: 32px;
  display: flex;
  align-items: center;
  gap: 15px;
}

.user-info { 
  text-align: right; 
}

.user-info .name { 
  font-weight: bold; 
  color: #333; 
  font-size: 16px; 
}

.user-info .role { 
  color: #666; 
  font-size: 14px; 
}

/* ═══════════════════════════════════════════════════════════
   🔍 FILTROS
   ═══════════════════════════════════════════════════════════ */
.filters {
  background: white;
  padding: 25px;
  border-radius: 15px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.1);
  margin-bottom: 30px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}

.filter-group { 
  display: flex; 
  flex-direction: column; 
  gap: 8px; 
}

.filter-group label { 
  font-weight: 600; 
  color: #555; 
  font-size: 14px; 
}

.filter-group select,
.filter-group input {
  padding: 10px 15px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  transition: all 0.3s;
}

.filter-group select:focus,
.filter-group input:focus { 
  outline: none; 
  border-color: #667eea; 
}

/* ═══════════════════════════════════════════════════════════
   📊 ESTADÍSTICAS
   ═══════════════════════════════════════════════════════════ */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

/* ═══════════════════════════════════════════════════════════
   📊 MATERIAL CATEGORIES
   ═══════════════════════════════════════════════════════════ */
.material-categories-section {
  margin-bottom: 30px;
}

.material-categories-section .section-header {
  margin-bottom: 20px;
}

.material-categories-section .section-header h2 {
  font-size: 22px;
  color: #2d3748;
  margin-bottom: 5px;
}

.material-categories-section .section-header p {
  color: #718096;
  font-size: 14px;
}

.material-categories-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 20px;
}

.category-chart-card {
  background: white;
  padding: 20px;
  border-radius: 15px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}

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

.chart-header h3 {
  font-size: 16px;
  color: #2d3748;
}

.chart-header span {
  font-size: 13px;
  color: #718096;
}

.chart-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

.category-legend {
  display: grid;
  gap: 8px;
  width: 100%;
}

.legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: #4a5568;
}

.legend-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.category-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 15px;
}

.category-card {
  background: white;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.08);
  border-left: 4px solid transparent;
  display: grid;
  gap: 8px;
}

.category-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: #2d3748;
}

.category-card-header i {
  font-size: 18px;
}

.category-card p {
  margin: 0;
  font-size: 13px;
  color: #718096;
}

@media (max-width: 900px) {
  .material-categories-grid {
    grid-template-columns: 1fr;
  }
}

.stat-card {
  background: white;
  padding: 25px;
  border-radius: 15px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.1);
  text-align: center;
  transition: transform 0.3s;
}

.stat-card:hover { 
  transform: translateY(-5px); 
}

.stat-card .number { 
  font-size: 48px; 
  font-weight: bold; 
  color: #667eea; 
  margin-bottom: 10px; 
}

.stat-card .label { 
  color: #666; 
  font-size: 14px; 
  font-weight: 600; 
  text-transform: uppercase; 
  letter-spacing: 1px; 
}

/* ═══════════════════════════════════════════════════════════
   📋 CONTENEDOR DE TAREAS
   ═══════════════════════════════════════════════════════════ */
.tasks-container {
  background: white;
  padding: 30px;
  border-radius: 15px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}

.loading { 
  text-align: center; 
  padding: 60px; 
  color: #667eea; 
  font-size: 18px; 
}

.spinner {
  border: 4px solid #f3f3f3;
  border-top: 4px solid #667eea;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

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

/* ═══════════════════════════════════════════════════════════
   🎴 TARJETAS DE TAREAS
   ═══════════════════════════════════════════════════════════ */
.task-card {
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  transition: all 0.3s;
}

.task-card:hover { 
  border-color: #667eea; 
  box-shadow: 0 5px 20px rgba(102, 126, 234, 0.2); 
}

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

.task-id { 
  font-weight: bold; 
  color: #667eea; 
  font-size: 16px; 
}

.task-status {
  padding: 6px 15px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.status-pendiente { background: #fff3cd; color: #856404; }
.status-en-proceso { background: #cfe2ff; color: #084298; }
.status-aprobado { background: #d1e7dd; color: #0f5132; }
.status-completado { background: #d1e7dd; color: #0f5132; }
.status-rechazado { background: #f8d7da; color: #721c24; }
.status-en-revisión { background: #e7d4f8; color: #5a1a8c; }
.status-borrador { background: #edf2f7; color: #4a5568; }
.status-planificacion { background: #e6fffa; color: #285e61; }
.status-revision-plan { background: #faf089; color: #744210; }
.status-plan-rechazado { background: #fed7d7; color: #742a2a; }
.status-lista { background: #c6f6d5; color: #276749; }
.status-revision-trabajo { background: #e9d8fd; color: #553c9a; }
.status-trabajo-rechazado { background: #fed7d7; color: #742a2a; }
.status-completada { background: #c6f6d5; color: #276749; }
.status-cancelada { background: #e2e8f0; color: #4a5568; }

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

.task-field { 
  display: flex; 
  flex-direction: column; 
  gap: 5px; 
}

.task-field label { 
  font-size: 12px; 
  color: #666; 
  font-weight: 600; 
  text-transform: uppercase; 
  letter-spacing: 0.5px; 
}

.task-field .value { 
  font-size: 14px; 
  color: #333; 
}

.task-actions {
  display: flex;
  gap: 10px;
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid #e0e0e0;
}

/* ═══════════════════════════════════════════════════════════
   🌳 TASK TREE (V2)
   ═══════════════════════════════════════════════════════════ */
.task-tree {
  list-style: none;
  margin: 0;
  padding: 0;
}

.task-node {
  margin-bottom: 8px;
}

.task-row {
  display: grid;
  grid-template-columns: 24px 2fr 120px 200px 120px 180px 110px auto;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f9fbff;
}

.task-row:hover {
  border-color: #667eea;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.task-toggle {
  border: none;
  background: transparent;
  font-size: 16px;
  cursor: pointer;
  color: #667eea;
}

.task-toggle.hidden {
  visibility: hidden;
}

.task-main {
  cursor: pointer;
}

.task-title {
  font-weight: 600;
  color: #2d3748;
}

.task-subtitle {
  font-size: 12px;
  color: #718096;
}

.task-meta {
  font-size: 12px;
  color: #4a5568;
}

.task-executor {
  font-weight: 600;
  color: #2b6cb0;
}

.task-progress {
  font-size: 12px;
  text-align: center;
  color: #2d3748;
}

.task-progress-status {
  color: #718096;
}

.task-assignees,
.task-deps {
  font-size: 12px;
  color: #4a5568;
}

.task-children {
  list-style: none;
  margin: 8px 0 0 24px;
  padding: 0 0 0 12px;
  border-left: 2px dashed #e2e8f0;
}

.task-children.collapsed {
  display: none;
}

.task-node.drag-over .task-row {
  border-color: #48bb78;
  background: #f0fff4;
}

.task-node.dragging {
  opacity: 0.6;
}

/* ═══════════════════════════════════════════════════════════
   🧾 TASK SIDE PANEL
   ═══════════════════════════════════════════════════════════ */
.task-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  height: 100%;
  background: #fff;
  box-shadow: -10px 0 30px rgba(0,0,0,0.1);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 1200;
  display: flex;
  flex-direction: column;
}

.task-panel.open {
  transform: translateX(0);
}

.task-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 20px;
  border-bottom: 1px solid #e2e8f0;
}

.task-panel-subtitle {
  font-size: 14px;
  color: #4a5568;
}

.task-panel-meta {
  font-size: 12px;
  color: #718096;
}

.task-panel-tabs {
  display: flex;
  gap: 6px;
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8f0;
  flex-wrap: wrap;
}

.task-panel-tab {
  border: none;
  background: #edf2f7;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
}

.task-panel-tab.active {
  background: #667eea;
  color: #fff;
}

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

.task-panel-section {
  display: none;
}

.task-panel-section.active {
  display: block;
}

.panel-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.panel-item {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
  background: #f7fafc;
}

.panel-group-title {
  font-weight: 600;
  margin: 12px 0 8px;
}

.panel-empty,
.panel-loading {
  color: #718096;
  font-size: 13px;
  padding: 8px 0;
}

.panel-form {
  display: grid;
  gap: 8px;
  width: 100%;
}

.panel-form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.panel-form-row.full textarea {
  width: 100%;
}

/* ═══════════════════════════════════════════════════════════
   🧰 EXECUTOR TAB
   ═══════════════════════════════════════════════════════════ */
.executor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.executor-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

.executor-card form {
  display: grid;
  gap: 10px;
}

.executor-list {
  display: grid;
  gap: 8px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}

.kpi-item {
  background: #edf2f7;
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}

.kpi-value {
  font-size: 20px;
  font-weight: 700;
  color: #2d3748;
}

.kpi-label {
  font-size: 12px;
  color: #718096;
}

/* ═══════════════════════════════════════════════════════════
   📭 ESTADO VACÍO
   ═══════════════════════════════════════════════════════════ */
.empty-state { 
  text-align: center; 
  padding: 60px; 
  color: #999; 
}

.empty-state-icon { 
  font-size: 64px; 
  margin-bottom: 20px; 
}

.empty-state-text { 
  font-size: 18px; 
  color: #666; 
}

/* ═══════════════════════════════════════════════════════════
   🪟 MODAL
   ═══════════════════════════════════════════════════════════ */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  overflow-y: auto;
  animation: fadeIn 0.3s ease-out;
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

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

.modal-content {
  background: white;
  border-radius: 20px;
  width: 100%;
  max-width: 1000px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  animation: slideUp 0.3s ease-out;
}

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

.modal-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 30px;
  border-radius: 20px 20px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header-content { 
  flex: 1; 
}

.modal-header h2 {
  margin: 0 0 10px 0;
  font-size: 28px;
  display: flex;
  align-items: center;
  gap: 15px;
}

.modal-header .task-meta { 
  display: flex; 
  gap: 20px; 
  font-size: 14px; 
  opacity: 0.9; 
}

.modal-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 28px;
  cursor: pointer;
  padding: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.3s;
  flex-shrink: 0;
}

.modal-close:hover { 
  background: rgba(255, 255, 255, 0.3); 
}

.modal-body { 
  padding: 30px; 
}

.create-task-modal .modal-content {
  max-width: 720px;
}

/* ═══════════════════════════════════════════════════════════
   📝 SECCIONES DE DETALLES
   ═══════════════════════════════════════════════════════════ */
.detail-section { 
  margin-bottom: 30px; 
  padding-bottom: 25px; 
  border-bottom: 2px solid #f0f0f0; 
}

.detail-section:last-child { 
  border-bottom: none; 
  margin-bottom: 0; 
}

.detail-section-title {
  font-size: 20px;
  font-weight: bold;
  color: #667eea;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.detail-item {
  background: #f8f9fa;
  padding: 18px;
  border-radius: 10px;
  border-left: 4px solid #667eea;
}

.detail-item.full-width { 
  grid-column: 1 / -1; 
}

.detail-label {
  font-size: 12px;
  color: #666;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.detail-value { 
  font-size: 16px; 
  color: #333; 
  font-weight: 500; 
}

.detail-value.empty { 
  color: #999; 
  font-style: italic; 
}

.detail-value.highlight { 
  color: #dc3545; 
  font-weight: bold; 
  font-size: 18px; 
}

.detail-item input,
.detail-item select,
.detail-item textarea {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 2px solid #e0e0e0;
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.3s;
}

.detail-item input:focus,
.detail-item select:focus,
.detail-item textarea:focus { 
  outline: none; 
  border-color: #667eea; 
}

.detail-item textarea { 
  min-height: 100px; 
  resize: vertical; 
  font-family: monospace; 
}

/* ═══════════════════════════════════════════════════════════
   🏷️ BADGES
   ═══════════════════════════════════════════════════════════ */
.status-badge {
  display: inline-block;
  padding: 8px 20px;
  border-radius: 25px;
  font-size: 14px;
  font-weight: 600;
}

.priority-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  border-radius: 25px;
  font-size: 14px;
  font-weight: 600;
}

.priority-baja { background: #d1e7dd; color: #0f5132; }
.priority-media { background: #cfe2ff; color: #084298; }
.priority-alta { background: #fff3cd; color: #856404; }
.priority-urgente { background: #f8d7da; color: #721c24; }

/* ═══════════════════════════════════════════════════════════
   🦶 MODAL FOOTER
   ═══════════════════════════════════════════════════════════ */
.modal-footer {
  padding: 20px 30px;
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8f9fa;
  border-radius: 0 0 20px 20px;
}

.modal-footer-info { 
  font-size: 12px; 
  color: #666; 
}

.modal-footer-actions { 
  display: flex; 
  gap: 10px; 
}

/* ═══════════════════════════════════════════════════════════
   🔔 NOTIFICACIONES
   ═══════════════════════════════════════════════════════════ */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 15px 25px;
  border-radius: 8px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
  z-index: 2000;
  display: none;
  animation: slideIn 0.3s ease-out;
}

.notification.active { 
  display: block; 
}

.notification.success { 
  background: #d1e7dd; 
  color: #0f5132; 
  border-left: 4px solid #28a745; 
}

.notification.error { 
  background: #f8d7da; 
  color: #721c24; 
  border-left: 4px solid #dc3545; 
}

@keyframes slideIn {
  from { transform: translateX(400px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════
   📸 GALERÍA DE FOTOS
   ═══════════════════════════════════════════════════════════ */
.foto-item {
  position: relative;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
  background: white;
  transition: all 0.3s;
}

.foto-item:hover {
  border-color: #667eea;
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.foto-item img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  cursor: pointer;
  transition: transform 0.3s;
}

.foto-item img:hover {
  transform: scale(1.05);
}

/* ═══════════════════════════════════════════════════════════
   📦 MATERIALES
   ═══════════════════════════════════════════════════════════ */
.material-item {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 15px;
  border: 2px solid #e0e0e0;
  position: relative;
  transition: all 0.3s;
}

.material-item:hover {
  border-color: #667eea;
  box-shadow: 0 3px 10px rgba(102, 126, 234, 0.2);
}

/* ═══════════════════════════════════════════════════════════
   🔄 LOADING INDICATOR
   ═══════════════════════════════════════════════════════════ */
#loadingIndicator {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #667eea, #764ba2);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
  z-index: 10000;
  display: none;
}

/* ═══════════════════════════════════════════════════════════
   📱 RESPONSIVE / MOBILE FIRST
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .header, .filters, .stat-card, .tasks-container {
    box-shadow: 0 6px 20px rgba(0,0,0,0.10);
  }
  
  .task-card {
    padding: 18px;
    border-radius: 16px;
    border-width: 2px;
  }

  .task-id {
    font-size: 18px;
  }

  .task-status {
    font-size: 13px;
    padding: 8px 14px;
  }

  .task-field label {
    font-size: 12px;
    letter-spacing: 0.8px;
  }

  .task-field .value {
    font-size: 17px;
    line-height: 1.25;
  }

  .task-field {
    background: #f8f9fa;
    border: 1px solid #eee;
    border-radius: 12px;
    padding: 12px 12px;
  }

  .task-body {
    gap: 12px;
    margin-top: 10px;
  }

  .task-actions {
    margin-top: 16px;
    padding-top: 16px;
  }

  .task-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .task-status,
  .task-meta,
  .task-progress,
  .task-assignees,
  .task-deps {
    justify-self: start;
  }

  .task-panel {
    width: 100%;
  }

  .btn {
    padding: 14px 16px;
    font-size: 16px;
    border-radius: 12px;
  }

  .modal.active {
    padding: 10px;
    align-items: flex-start;
  }

  .modal-content {
    max-width: 100%;
    width: 100%;
    max-height: 92vh;
    border-radius: 16px;
  }

  .modal-header {
    padding: 16px;
    border-radius: 16px 16px 0 0;
    gap: 10px;
  }

  .modal-header h2 {
    font-size: 20px;
    gap: 10px;
  }

  .modal-header .task-meta {
    flex-wrap: wrap;
    gap: 10px;
  }

  .modal-body {
    padding: 16px;
  }

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

  .detail-item {
    padding: 14px;
    border-radius: 12px;
  }

  .detail-value {
    font-size: 15px;
  }

  .modal-footer {
    padding: 12px 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .modal-footer-actions {
    flex-direction: column;
    gap: 10px;
  }

  .modal-close {
    width: 38px;
    height: 38px;
    font-size: 24px;
  }

  .notification {
    left: 12px;
    right: 12px;
    top: 12px;
  }
}

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

@media (hover: none) {
  .task-card:hover,
  .stat-card:hover,
  .foto-item img:hover {
    transform: none;
    box-shadow: none;
  }
}
