/* ==========================================
   UNIFIED MODAL SYSTEM - Clean & Professional
   ========================================== */

/* Modal Container */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.hidden {
  display: none !important;
}

/* Modal Overlay */
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.2s ease;
}

/* Modal Content */
.modal-content {
  position: relative;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.2s ease;
  z-index: 1001;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Modal Header */
.modal-header {
  padding: 24px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #111827;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Close Button */
.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: #6b7280;
  font-size: 24px;
  line-height: 1;
  transition: all 0.15s;
  flex-shrink: 0;
}

.modal-close:hover {
  background: #f3f4f6;
  color: #111827;
}

/* Modal Body */
.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

/* Modal Form */
.modal-form {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

/* Form Group */
.form-group {
  margin-bottom: 20px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 500;
  color: #374151;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  color: #111827;
  background: #ffffff;
  transition: all 0.15s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: #9ca3af;
}

/* Form Row */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

/* Form Hint */
.form-hint {
  margin-top: 4px;
  font-size: 12px;
  color: #6b7280;
  line-height: 1.4;
}

/* Modal Actions */
.modal-actions {
  padding: 16px 24px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* Buttons */
.btn-cancel {
  padding: 10px 20px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #ffffff;
  color: #374151;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-cancel:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}

.btn-submit {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  background: #3b82f6;
  color: #ffffff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-submit:hover {
  background: #2563eb;
}

/* WhatsApp Button */
.btn-whatsapp {
  background: #25d366;
}

.btn-whatsapp:hover {
  background: #20ba5a;
}

/* Danger Button */
.btn-danger {
  background: #ef4444;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-danger-sm {
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  background: #ef4444;
  color: #ffffff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-danger-sm:hover {
  background: #dc2626;
}

/* WhatsApp Status */
.whatsapp-status-display {
  padding: 16px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin-bottom: 16px;
}

.whatsapp-status-display .status-text {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: #111827;
}

.whatsapp-status-display .status-icon {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.whatsapp-status-display .status-icon.connected {
  background: #10b981;
}

.whatsapp-status-display .status-icon.disconnected {
  background: #ef4444;
}

.whatsapp-status-display .status-icon.loading {
  background: #f59e0b;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* WhatsApp QR */
.whatsapp-qr-display {
  min-height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: #f9fafb;
  border: 2px dashed #d1d5db;
  border-radius: 8px;
  margin-bottom: 16px;
}

.whatsapp-qr-display img,
.whatsapp-qr-display canvas {
  max-width: 100%;
  height: auto;
}

.whatsapp-qr-display .loading-text {
  color: #6b7280;
  font-size: 14px;
}

/* Scrollbar */
.modal-body::-webkit-scrollbar,
.modal-form::-webkit-scrollbar {
  width: 8px;
}

.modal-body::-webkit-scrollbar-track,
.modal-form::-webkit-scrollbar-track {
  background: transparent;
}

.modal-body::-webkit-scrollbar-thumb,
.modal-form::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover,
.modal-form::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* Responsive */
@media (max-width: 640px) {
  .modal {
    padding: 0;
  }

  .modal-content {
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  .modal-header,
  .modal-body,
  .modal-form {
    padding: 20px;
  }

  .modal-actions {
    padding: 16px 20px;
    flex-direction: column-reverse;
  }

  .btn-cancel,
  .btn-submit {
    width: 100%;
    justify-content: center;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
}


/* ==========================================
   DARK MODE STYLES
   ========================================== */

[data-theme="dark"] .modal-content,
html[data-theme="dark"] .modal-content,
body[data-theme="dark"] .modal-content {
  background: #1e293b !important;
  border: 1px solid #334155;
}

[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-header,
body[data-theme="dark"] .modal-header {
  border-bottom-color: #334155 !important;
}

[data-theme="dark"] .modal-header h3,
html[data-theme="dark"] .modal-header h3,
body[data-theme="dark"] .modal-header h3 {
  color: #f1f5f9 !important;
}

[data-theme="dark"] .modal-close,
html[data-theme="dark"] .modal-close,
body[data-theme="dark"] .modal-close {
  color: #94a3b8 !important;
}

[data-theme="dark"] .modal-close:hover,
html[data-theme="dark"] .modal-close:hover,
body[data-theme="dark"] .modal-close:hover {
  background: #334155 !important;
  color: #f1f5f9 !important;
}

[data-theme="dark"] .modal-body,
html[data-theme="dark"] .modal-body,
body[data-theme="dark"] .modal-body {
  background: #1e293b !important;
  color: #f1f5f9 !important;
}

[data-theme="dark"] .modal-form,
html[data-theme="dark"] .modal-form,
body[data-theme="dark"] .modal-form {
  background: #1e293b !important;
}

[data-theme="dark"] .modal-actions,
html[data-theme="dark"] .modal-actions,
body[data-theme="dark"] .modal-actions {
  border-top-color: #334155 !important;
  background: #1e293b !important;
}

[data-theme="dark"] .form-group label,
html[data-theme="dark"] .form-group label,
body[data-theme="dark"] .form-group label {
  color: #e2e8f0 !important;
}

[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group textarea,
[data-theme="dark"] .form-group select,
html[data-theme="dark"] .form-group input,
html[data-theme="dark"] .form-group textarea,
html[data-theme="dark"] .form-group select,
body[data-theme="dark"] .form-group input,
body[data-theme="dark"] .form-group textarea,
body[data-theme="dark"] .form-group select {
  background: #0f172a !important;
  border-color: #334155 !important;
  color: #f1f5f9 !important;
}

[data-theme="dark"] .form-hint,
html[data-theme="dark"] .form-hint,
body[data-theme="dark"] .form-hint {
  color: #94a3b8 !important;
}

[data-theme="dark"] .btn-cancel,
html[data-theme="dark"] .btn-cancel,
body[data-theme="dark"] .btn-cancel {
  background: #334155 !important;
  border-color: #475569 !important;
  color: #f1f5f9 !important;
}

[data-theme="dark"] .btn-cancel:hover,
html[data-theme="dark"] .btn-cancel:hover,
body[data-theme="dark"] .btn-cancel:hover {
  background: #475569 !important;
}

[data-theme="dark"] .whatsapp-status-display,
html[data-theme="dark"] .whatsapp-status-display,
body[data-theme="dark"] .whatsapp-status-display {
  background: #0f172a !important;
  border-color: #334155 !important;
}

[data-theme="dark"] .whatsapp-status-display .status-text,
html[data-theme="dark"] .whatsapp-status-display .status-text,
body[data-theme="dark"] .whatsapp-status-display .status-text {
  color: #f1f5f9 !important;
}

[data-theme="dark"] .whatsapp-qr-display,
html[data-theme="dark"] .whatsapp-qr-display,
body[data-theme="dark"] .whatsapp-qr-display {
  background: #0f172a !important;
  border-color: #334155 !important;
}

[data-theme="dark"] .whatsapp-qr-display .loading-text,
html[data-theme="dark"] .whatsapp-qr-display .loading-text,
body[data-theme="dark"] .whatsapp-qr-display .loading-text {
  color: #94a3b8 !important;
}
