/* --- MODO OFFLINE --- */

.offline-indicator {
  position: fixed;
  top: 20px;
  left: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.offline-indicator.online {
  border-left: 4px solid #10b981;
}

.offline-indicator.offline {
  border-left: 4px solid #ef4444;
  animation: pulse 2s ease-in-out infinite;
}

.offline-icon {
  font-size: 16px;
}

.offline-text {
  font-weight: 500;
  color: var(--text-primary);
}

.offline-queue {
  background: var(--primary);
  color: white;
  border-radius: 12px;
  padding: 2px 6px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 4px;
}

/* --- SYNC STATUS --- */
.sync-status {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  z-index: 999;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.sync-status.syncing {
  border-left: 4px solid #3b82f6;
  animation: pulse 1s ease-in-out infinite;
}

.sync-status.synced {
  border-left: 4px solid #10b981;
}

.sync-status.error {
  border-left: 4px solid #ef4444;
}

.sync-status.offline {
  border-left: 4px solid #6b7280;
}

.sync-icon {
  font-size: 16px;
}

.sync-text {
  font-weight: 500;
  color: var(--text-primary);
}

.sync-time {
  color: var(--text-secondary);
  font-size: 0.75rem;
  margin-left: 8px;
}

/* --- ESTADOS DA APLICAÇÃO --- */
body.online .offline-only {
  display: none !important;
}

body.offline .online-only {
  display: none !important;
}

body.offline {
  position: relative;
}

body.offline::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: #ef4444;
  z-index: 1001;
  animation: slideDown 0.3s ease;
}

/* --- OVERLAY OFFLINE --- */
.offline-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1002;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.offline-overlay.active {
  opacity: 1;
  visibility: visible;
}

.offline-overlay-content {
  background: var(--bg-primary);
  border-radius: 12px;
  padding: 30px;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.offline-overlay-icon {
  font-size: 48px;
  color: #ef4444;
  margin-bottom: 20px;
}

.offline-overlay-title {
  color: var(--text-primary);
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 10px;
}

.offline-overlay-message {
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

.offline-overlay-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* --- QUEUE VISUALIZATION --- */
.offline-queue-panel {
  position: fixed;
  top: 70px;
  left: 20px;
  width: 300px;
  max-height: 400px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 998;
  overflow: hidden;
  transform: translateY(-100%);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.offline-queue-panel.active {
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
}

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

.offline-queue-title {
  color: var(--text-primary);
  font-weight: 600;
  margin: 0;
}

.offline-queue-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.offline-queue-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.offline-queue-list {
  max-height: 300px;
  overflow-y: auto;
  padding: 10px;
}

.offline-queue-item {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 8px;
  font-size: 0.875rem;
}

.offline-queue-item-type {
  color: var(--text-primary);
  font-weight: 500;
  margin-bottom: 4px;
}

.offline-queue-item-meta {
  color: var(--text-secondary);
  font-size: 0.75rem;
  display: flex;
  justify-content: space-between;
}

.offline-queue-empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 20px;
  font-style: italic;
}

/* --- CACHE INFO --- */
.cache-info-panel {
  position: fixed;
  bottom: 70px;
  right: 20px;
  width: 280px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 15px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 997;
  transform: translateY(100%);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.cache-info-panel.active {
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
}

.cache-info-title {
  color: var(--text-primary);
  font-weight: 600;
  margin-bottom: 10px;
}

.cache-info-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 15px;
}

.cache-stat {
  text-align: center;
}

.cache-stat-value {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.cache-stat-label {
  color: var(--text-secondary);
  font-size: 0.75rem;
}

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

.cache-info-actions button {
  flex: 1;
  padding: 6px 12px;
  font-size: 0.875rem;
}

/* --- ANIMAÇÕES --- */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

@keyframes slideDown {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: translateY(0);
  }
}

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

.sync-status.syncing .sync-icon {
  animation: spin 1s linear infinite;
}

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
  .offline-indicator {
    top: 10px;
    left: 10px;
    right: 10px;
    padding: 6px 10px;
  }
  
  .sync-status {
    bottom: 10px;
    left: 10px;
    right: 10px;
    padding: 6px 10px;
  }
  
  .offline-queue-panel {
    left: 10px;
    right: 10px;
    width: auto;
  }
  
  .cache-info-panel {
    left: 10px;
    right: 10px;
    width: auto;
  }
  
  .offline-overlay-content {
    margin: 20px;
    padding: 20px;
  }
}

@media (max-width: 480px) {
  .offline-overlay-content {
    margin: 10px;
    padding: 15px;
  }
  
  .offline-overlay-icon {
    font-size: 36px;
  }
  
  .offline-overlay-title {
    font-size: 1.25rem;
  }
  
  .offline-overlay-actions {
    flex-direction: column;
  }
}

/* --- DARK MODE --- */
@media (prefers-color-scheme: dark) {
  .offline-indicator.offline {
    background: rgba(239, 68, 68, 0.1);
  }
  
  .sync-status.syncing {
    background: rgba(59, 130, 246, 0.1);
  }
  
  .sync-status.error {
    background: rgba(239, 68, 68, 0.1);
  }
}

/* --- FOCUS E ACESSIBILIDADE --- */
.offline-indicator:focus,
.sync-status:focus,
.offline-queue-close:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* --- ESTADOS ESPECIAIS --- */
body.offline .btn.primary {
  opacity: 0.7;
  cursor: not-allowed;
}

body.offline .btn.primary:hover {
  opacity: 0.7;
  transform: none;
}

body.offline input[required]:invalid {
  border-color: #ef4444;
}

/* --- INDICADORES DE FORMULÁRIO --- */
.form-field.offline-pending {
  position: relative;
}

.form-field.offline-pending::after {
  content: 'offline';
  position: absolute;
  top: 0;
  right: 0;
  background: #ef4444;
  color: white;
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.form-field.offline-synced::after {
  content: 'synced';
  position: absolute;
  top: 0;
  right: 0;
  background: #10b981;
  color: white;
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

/* --- TOOLTIPS --- */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-tooltip);
  color: var(--text-tooltip);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 1000;
}

[data-tooltip]:hover::after {
  opacity: 1;
}
