/* assets/css/components/offline.css — Styles pour le mode offline */

/* ===================== INDICATEUR DE CONNEXION ===================== */

.connection-status {
  position: relative;
}

.connection-status-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.2s ease;
  position: relative;
}

.connection-status-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.connection-status .connection-icon i {
  font-size: 1.25rem;
  color: #6c757d;
  transition: color 0.2s ease;
}

/* États */
.connection-status.online .connection-icon i {
  color: #198754;
}

.connection-status.offline .connection-icon i {
  color: #dc3545;
  animation: pulse-offline 1.5s ease-in-out infinite;
}

.connection-status.has-conflicts .connection-icon i {
  color: #fd7e14;
}

@keyframes pulse-offline {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Badge */
.connection-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 0.65rem;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  background: #dc3545;
  color: #fff;
  border-radius: 9px;
  animation: badge-pop 0.3s ease;
}

@keyframes badge-pop {
  0% { transform: scale(0); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* Dropdown */
.connection-dropdown {
  min-width: 280px;
  padding: 0;
  border: none;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

.connection-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
}

.connection-state-text {
  font-weight: 600;
  color: #212529;
}

.connection-stats {
  padding: 12px 16px;
}

.connection-stat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 0.875rem;
  color: #495057;
}

.connection-stat i {
  width: 20px;
  color: #6c757d;
}

.connection-stat .stat-pending,
.connection-stat .stat-conflicts {
  font-weight: 600;
}

/* Bouton sync dans dropdown */
.connection-dropdown .btn-sync {
  width: 100%;
  text-align: left;
}

.connection-dropdown .btn-sync:disabled {
  opacity: 0.6;
}

/* ===================== BANDEAU OFFLINE ===================== */

.offline-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 10px 20px;
  background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
  color: #fff;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 1050;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.offline-banner.show {
  transform: translateY(0);
}

.offline-banner i {
  font-size: 1.25rem;
}

.offline-banner .btn {
  padding: 4px 12px;
  font-size: 0.75rem;
}

/* ===================== INDICATEURS DE SYNC ===================== */

/* Badge sur les éléments dirty */
[data-dirty="1"]::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  background: #fd7e14;
  border-radius: 50%;
  animation: pulse-dirty 2s ease-in-out infinite;
}

@keyframes pulse-dirty {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(0.8); }
}

/* Indicateur sur le treeview */
.treeview-item.is-dirty .item-title::after {
  content: '\2022';
  margin-left: 6px;
  color: #fd7e14;
  font-size: 1.2em;
}

.treeview-item.is-syncing .item-title::after {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 6px;
  border: 2px solid #0d6efd;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ===================== PAGE SYNC ===================== */

#syncPage .card {
  border: none;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

#syncPage .display-6 {
  font-size: 2rem;
}

#syncPage .list-group-item {
  border-left: none;
  border-right: none;
  transition: background-color 0.2s ease;
}

#syncPage .list-group-item:hover {
  background-color: #f8f9fa;
}

#syncPage .list-group-item.fade-out {
  opacity: 0;
  transform: translateX(20px);
  transition: all 0.3s ease;
}

#syncPage .progress {
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
}

#syncPage .progress-bar {
  transition: width 0.3s ease;
}

/* Overlay de sync */
#syncOverlay {
  background: rgba(255, 255, 255, 0.9);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

/* ===================== THÈME DARK ===================== */

html[data-theme="dark"] .connection-status-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .connection-status .connection-icon i {
  color: #adb5bd;
}

html[data-theme="dark"] .connection-status.online .connection-icon i {
  color: #20c997;
}

html[data-theme="dark"] .connection-status.offline .connection-icon i {
  color: #f56565;
}

html[data-theme="dark"] .connection-dropdown {
  background: #1e293b;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

html[data-theme="dark"] .connection-header {
  background: #0f172a;
  border-bottom-color: #334155;
}

html[data-theme="dark"] .connection-state-text {
  color: #e5e7eb;
}

html[data-theme="dark"] .connection-stat {
  color: #9ca3af;
}

html[data-theme="dark"] .connection-dropdown .dropdown-item {
  color: #e5e7eb;
}

html[data-theme="dark"] .connection-dropdown .dropdown-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] #syncPage .card {
  background: #1e293b;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

html[data-theme="dark"] #syncPage .list-group-item {
  background: transparent;
  border-color: #334155;
}

html[data-theme="dark"] #syncPage .list-group-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

html[data-theme="dark"] #syncOverlay {
  background: rgba(15, 23, 42, 0.9);
}

/* ===================== THÈME ZKRIVA ===================== */

html[data-theme="zkriva"] .connection-status.online .connection-icon i {
  color: #059669;
}

html[data-theme="zkriva"] .connection-status.offline .connection-icon i {
  color: #dc2626;
}

html[data-theme="zkriva"] .connection-badge {
  background: #d2b491;
}

html[data-theme="zkriva"] .offline-banner {
  background: linear-gradient(135deg, #d2b491 0%, #b89a73 100%);
}

/* ===================== ANIMATIONS ===================== */

/* Toast de sync */
.sync-toast {
  animation: slide-in-right 0.3s ease;
}

@keyframes slide-in-right {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Classe pour body quand offline */
html.zk-offline .connection-status-btn {
  animation: pulse-btn 2s ease-in-out infinite;
}

@keyframes pulse-btn {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 0 4px rgba(220, 53, 69, 0.3); }
}
