/* ============================================================
   Styles — Panel de Notas en la Nube
   ============================================================
   Diseño responsive, tono Material Design.
   ============================================================ */

/* ----- Variables ----- */
:root {
  --color-primary: #1565C0;
  --color-primary-dark: #0D47A1;
  --color-secondary: #FF6F00;
  --color-background: #F5F5F5;
  --color-surface: #FFFFFF;
  --color-text: #212121;
  --color-text-secondary: #757575;
  --color-border: #E0E0E0;
  --color-error: #D32F2F;
  --color-success: #2E7D32;

  --color-general:   #757575;
  --color-idea:      #7B1FA2;
  --color-incidencia:#D32F2F;
  --color-tarea:     #1565C0;
  --color-aviso:     #F57F17;
  --color-consulta:  #00897B;
  --color-urgente:   #C62828;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-card: 0 1px 4px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
  --shadow-elevated: 0 4px 12px rgba(0,0,0,0.15);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ----- Reset básico ----- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--color-background);
  color: var(--color-text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   CABECERA
   ============================================================ */
.header {
  background: var(--color-primary);
  color: #fff;
  padding: 16px 24px;
  box-shadow: var(--shadow-elevated);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header__inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.header__icon { font-size: 32px; }

.header__title {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.header__version {
  font-size: 0.7rem;
  font-weight: 500;
  color: rgba(255,255,255,0.7);
  letter-spacing: 0.02em;
}

/* Botón descarga APK */
.header__download {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: var(--radius-sm);
  color: #fff;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: background 0.15s;
  white-space: nowrap;
}

.header__download:hover { background: rgba(255,255,255,0.25); }

.header__download .material-symbols-outlined { font-size: 18px; }

@media (max-width: 480px) {
  .header__download-text { display: none; }
}

/* ============================================================
   CUERPO
   ============================================================ */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 16px;
  flex: 1;
  width: 100%;
}

/* ============================================================
   ESTADÍSTICAS
   ============================================================ */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 20px 16px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.stat-card__value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1.2;
  word-break: break-word;
  max-width: 100%;
}

.stat-card__label {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ============================================================
   FILTROS
   ============================================================ */
.filters {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
}

.filters__title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
}

.filters__row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.filters__row:last-child { margin-bottom: 0; }

.filter-group {
  flex: 1 1 180px;
  min-width: 0;
}

.filter-group--date-presets { flex: 0 1 auto; }
.filter-group--date-custom { flex: 0 1 160px; }
.filter-group--actions {
  flex: 0 1 auto;
  display: flex;
  align-items: flex-end;
}

.filter-group__label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.filter-group__input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color 0.15s;
}

.filter-group__input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(21, 101, 192, 0.15);
}

/* ----- Presets de fecha ----- */
.date-presets {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.date-btn {
  padding: 8px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-family: var(--font);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.date-btn:hover { border-color: var(--color-primary); color: var(--color-primary); }

.date-btn--active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.date-btn--active:hover { background: var(--color-primary-dark); }

/* ----- Botón limpiar ----- */
.btn--clear {
  padding: 10px 20px;
  border: 1px solid var(--color-error);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-error);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  height: fit-content;
}

.btn--clear:hover { background: var(--color-error); color: #fff; }

/* ============================================================
   BARRA DE NOTAS
   ============================================================ */
.notes-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}

.notes-bar__count {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
}

.notes-bar__views {
  display: flex;
  gap: 4px;
}

.view-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-family: var(--font);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}

.view-btn:hover { border-color: var(--color-primary); color: var(--color-primary); }

.view-btn--active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.view-btn--active:hover { background: var(--color-primary-dark); color: #fff; }

.view-btn .material-symbols-outlined { font-size: 18px; }

/* ============================================================
   BARRA DE ACTUALIZACIÓN
   ============================================================ */
.refresh-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  margin-bottom: 8px;
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
  font-size: 0.78rem;
  gap: 8px;
  flex-wrap: wrap;
}

.refresh-bar__info {
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.refresh-bar__count {
  color: var(--color-text-secondary);
  font-weight: 500;
}

/* ============================================================
   TOAST DE NUEVAS NOTAS
   ============================================================ */
.new-notes-toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  margin-bottom: 8px;
  background: var(--color-success);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-elevated);
  animation: slideDown 0.3s ease-out;
}

.new-notes-toast[hidden] { display: none; }

.new-notes-toast .material-symbols-outlined { font-size: 20px; }

.new-notes-toast__close {
  margin-left: auto;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  opacity: 0.8;
}

.new-notes-toast__close:hover { opacity: 1; }

.new-notes-toast__close .material-symbols-outlined { font-size: 18px; }

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

/* ============================================================
   CONTENEDOR DE NOTAS
   ============================================================ */
.notes-container {
  min-height: 200px;
}

/* ----- Mensajes de estado ----- */
.state-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--color-text-secondary);
}

.state-message__icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.state-message__text {
  font-size: 1rem;
}

/* Spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   VISTA TABLA
   ============================================================ */
.notes-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.notes-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.notes-table th {
  background: var(--color-primary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 14px 12px;
  text-align: left;
  white-space: nowrap;
}

.notes-table td {
  padding: 12px;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}

.notes-table tr:last-child td { border-bottom: none; }

.notes-table tr:hover td { background: #F8F9FA; }

/* Categoría en tabla */
td .category-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
}

/* Urgente en tabla */
tr.urgent-row td { background: #FFF5F5; }
tr.urgent-row:hover td { background: #FFEBEE; }
tr.urgent-row .category-badge { background: var(--color-urgente); }

/* ============================================================
   VISTA TARJETAS
   ============================================================ */
.notes-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.note-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 16px;
  border-left: 4px solid var(--color-primary);
  transition: box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.note-card:hover { box-shadow: var(--shadow-elevated); }

/* Urgente en tarjeta */
.note-card.urgent-card {
  border-left-color: var(--color-urgente);
  background: #FFF5F5;
}

.note-card.urgent-card .note-card__category {
  background: var(--color-urgente);
  color: #fff;
}

/* ----- Componentes internos de tarjeta ----- */
.note-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.note-card__category {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
}

.note-card__date {
  font-size: 0.78rem;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

.note-card__alias {
  font-size: 0.8rem;
  color: var(--color-secondary);
  font-weight: 500;
}

.note-card__content {
  font-size: 0.92rem;
  color: var(--color-text);
  line-height: 1.5;
}

.note-card__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--color-text-secondary);
  margin-top: auto;
  padding-top: 4px;
}

.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
}

/* ============================================================
   PIE
   ============================================================ */
.footer {
  text-align: center;
  padding: 20px 16px;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  border-top: 1px solid var(--color-border);
  margin-top: 24px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .header { padding: 12px 16px; }
  .header__title { font-size: 1.05rem; }
  .main { padding: 12px; }

  .stats { grid-template-columns: repeat(2, 1fr); }

  .filter-group { flex: 1 1 100%; }
  .filter-group--date-presets { flex: 1 1 100%; }
  .filter-group--date-custom { flex: 1 1 calc(50% - 6px); }
  .filter-group--actions { flex: 1 1 100%; }

  .notes-cards { grid-template-columns: 1fr; }

  .notes-table th,
  .notes-table td { padding: 10px 8px; font-size: 0.82rem; }
}

@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 16px 12px; }
  .stat-card__value { font-size: 1.5rem; }
}
