/**
 * PWA Offline Styles
 * Styling untuk offline indicator dan UI komponen
 */

/* ========================================
   Offline Indicator
   ======================================== */

#offline-indicator {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background-color: #fff3cd;
  border-bottom: 1px solid #ffc107;
  padding: 12px 20px;
  animation: slideDown 0.3s ease-out;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

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

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

#offline-indicator.hide {
  animation: slideUp 0.3s ease-in;
}

#offline-indicator.alert {
  margin: 0;
  border-radius: 0;
}

#offline-indicator .d-flex {
  align-items: center;
}

#offline-indicator .btn-light {
  background-color: #ffe57f;
  border-color: #ffca28;
}

#offline-indicator .btn-light:hover {
  background-color: #ffd54f;
  border-color: #ffb300;
}

#offline-indicator .text-small {
  font-size: 0.875rem;
  color: #856404;
  margin-top: 2px;
}

#offline-indicator .progress {
  height: 20px;
  background-color: rgba(255, 255, 255, 0.5);
  border-radius: 3px;
}

#offline-indicator .progress-bar {
  background-color: #ffc107;
  background-image: linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.15) 25%,
    transparent 25%,
    transparent 50%,
    rgba(255, 255, 255, 0.15) 50%,
    rgba(255, 255, 255, 0.15) 75%,
    transparent 75%,
    transparent
  );
  background-size: 1rem 1rem;
  animation: progress-bar-stripes 1s linear infinite;
}

@keyframes progress-bar-stripes {
  0% {
    background-position: 0 0;
  }
  100% {
    background-position: 1rem 0;
  }
}

#sync-progress {
  margin-top: 12px;
  display: none;
}

#sync-progress small {
  display: block;
  margin-top: 8px;
}

/* ========================================
   Offline Status Badge
   ======================================== */

.offline-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background-color: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 20px;
  font-size: 0.875rem;
  color: #856404;
  font-weight: 500;
}

.offline-status-badge i {
  animation: pulse 2s infinite;
}

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

.offline-status-badge.online {
  background-color: #d4edda;
  border-color: #28a745;
  color: #155724;
}

.offline-status-badge.online i {
  color: #28a745;
  animation: none;
}

/* ========================================
   Sync Status Notifications
   ======================================== */

.sync-notification {
  position: fixed;
  bottom: 20px;
  right: 20px;
  min-width: 300px;
  max-width: 400px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 16px;
  z-index: 10000;
  animation: slideInRight 0.3s ease-out;
}

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

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

.sync-notification.hide {
  animation: slideOutRight 0.3s ease-in;
}

.sync-notification.success {
  border-left: 4px solid #28a745;
}

.sync-notification.success .icon {
  color: #28a745;
}

.sync-notification.error {
  border-left: 4px solid #dc3545;
}

.sync-notification.error .icon {
  color: #dc3545;
}

.sync-notification.info {
  border-left: 4px solid #17a2b8;
}

.sync-notification.info .icon {
  color: #17a2b8;
}

.sync-notification.warning {
  border-left: 4px solid #ffc107;
}

.sync-notification.warning .icon {
  color: #ffc107;
}

.sync-notification .icon {
  display: inline-block;
  margin-right: 12px;
  font-size: 20px;
}

.sync-notification .message {
  display: inline-block;
  vertical-align: middle;
}

.sync-notification .message strong {
  display: block;
  margin-bottom: 4px;
}

.sync-notification .close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  cursor: pointer;
  color: #999;
  font-size: 20px;
  padding: 0;
}

.sync-notification .close-btn:hover {
  color: #333;
}

/* ========================================
   Pending Transactions Panel
   ======================================== */

.pending-transactions-panel {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  background: #f8f9fa;
}

.pending-transactions-panel .transaction-item {
  padding: 12px;
  border-bottom: 1px solid #dee2e6;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pending-transactions-panel .transaction-item:last-child {
  border-bottom: none;
}

.pending-transactions-panel .transaction-info {
  flex: 1;
}

.pending-transactions-panel .transaction-method {
  font-weight: 600;
  font-size: 0.875rem;
  color: #333;
  margin-bottom: 4px;
}

.pending-transactions-panel .transaction-url {
  font-size: 0.8rem;
  color: #666;
  word-break: break-all;
  margin-bottom: 4px;
}

.pending-transactions-panel .transaction-time {
  font-size: 0.75rem;
  color: #999;
}

.pending-transactions-panel .retry-badge {
  background: #ffc107;
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 12px;
}

/* ========================================
   Sync Status Banner
   ======================================== */

.sync-status-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #f8f9fa;
  border-left: 4px solid #17a2b8;
  border-radius: 4px;
  margin-bottom: 16px;
}

.sync-status-banner .spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #17a2b8;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.sync-status-banner.success {
  border-left-color: #28a745;
  background: #d4edda;
}

.sync-status-banner.success .spinner {
  border-top-color: #28a745;
  animation: none;
}

.sync-status-banner.success .spinner::before {
  content: "✓";
  display: inline-block;
  width: 100%;
  height: 100%;
  line-height: 12px;
  text-align: center;
  color: #28a745;
  font-weight: bold;
}

.sync-status-banner.error {
  border-left-color: #dc3545;
  background: #f8d7da;
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 576px) {
  #offline-indicator {
    padding: 8px 12px;
    font-size: 0.875rem;
  }

  #offline-indicator .d-flex {
    flex-direction: column;
    align-items: flex-start;
  }

  #offline-indicator .btn {
    margin-top: 8px;
    width: 100%;
  }

  .sync-notification {
    bottom: 10px;
    right: 10px;
    left: 10px;
    min-width: auto;
    max-width: none;
  }

  .pending-transactions-panel {
    max-height: 200px;
  }
}

/* ========================================
   Animation & Transitions
   ======================================== */

.fade-in {
  animation: fadeIn 0.3s ease-in;
}

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

.fade-out {
  animation: fadeOut 0.3s ease-out;
}

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

/* ========================================
   Loading States
   ======================================== */

.sync-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.7;
}

.sync-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #007bff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* ========================================
   Disabled State (Offline)
   ======================================== */

.offline-disabled {
  opacity: 0.6;
  pointer-events: none;
}

.offline-disabled::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.5);
  cursor: not-allowed;
}

/* ========================================
   Utility Classes
   ======================================== */

.text-offline {
  color: #ffc107;
}

.text-online {
  color: #28a745;
}

.text-syncing {
  color: #17a2b8;
}

.bg-offline {
  background-color: #fff3cd;
}

.bg-online {
  background-color: #d4edda;
}

.bg-syncing {
  background-color: #d1ecf1;
}

.border-offline {
  border-color: #ffc107 !important;
}

.border-online {
  border-color: #28a745 !important;
}

.border-syncing {
  border-color: #17a2b8 !important;
}
