/* Shared modal styles — matches panel.php "Добавить устройство" design */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-box {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  scrollbar-width: none;          /* Firefox */
  -ms-overflow-style: none;       /* IE/Edge */
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  animation: modalFadeIn 0.2s ease;
}

.modal-box::-webkit-scrollbar {
  display: none;                  /* Chrome / Safari */
}

.modal-box.modal-wide {
  max-width: 600px;
}

.modal-box.modal-xl {
  max-width: 800px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: #1f2937;
}

.modal-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #6b7280;
  font-size: 18px;
  padding: 4px;
  line-height: 1;
  transition: color 0.15s;
}

.modal-close-btn:hover {
  color: #1f2937;
}

.modal-body {
  padding: 20px 24px 24px;
}

/* Tabs */
.modal-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-bottom: 2px solid #e5e7eb;
}

.modal-tab {
  padding: 8px 16px;
  cursor: pointer;
  border: none;
  background: none;
  font-size: 0.875rem;
  font-weight: 600;
  color: #6b7280;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}

.modal-tab:hover {
  color: #374151;
}

.modal-tab.active {
  color: var(--accent, #005BFF);
  border-bottom-color: var(--accent, #005BFF);
}

/* Diagnose result */
.diagnose-result {
  padding: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.8125rem;
  margin-top: 12px;
}

.diagnose-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid #f1f5f9;
}

.diagnose-row:last-child {
  border-bottom: none;
}

.diagnose-label {
  color: #64748b;
}

.diagnose-value {
  font-weight: 600;
  color: #1e293b;
}

.diagnose-ok { color: #10b981; }
.diagnose-error { color: #ef4444; }
.diagnose-warn { color: #f59e0b; }

/* Info hint banner */
.modal-hint {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  margin-bottom: 18px;
  background: #f0f4ff;
  border: 1px solid #dbe4ff;
  border-radius: 10px;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: #4b5e8a;
}

.modal-hint i {
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--accent, #005BFF);
  font-size: 0.875rem;
}

.modal-body .form-group {
  margin-bottom: 16px;
}

.modal-body .form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 6px;
}

.modal-body .form-group .required {
  color: #ef4444;
}

.modal-body .form-group input[type="text"],
.modal-body .form-group input[type="number"],
.modal-body .form-group input[type="email"],
.modal-body .form-group input[type="password"],
.modal-body .form-group input[type="url"],
.modal-body .form-group input[type="date"],
.modal-body .form-group select,
.modal-body .form-group textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.9rem;
  font-family: inherit;
  border: 1.5px solid #eef1f6;
  border-radius: 10px;
  background: #f8fafc;
  color: #1f2937;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.modal-body .form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.modal-body .form-group select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.modal-body .form-group input:focus,
.modal-body .form-group select:focus,
.modal-body .form-group textarea:focus {
  border-color: var(--accent, #005BFF);
}

.modal-body .form-group input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
}

.modal-body .form-group input:disabled,
.modal-body .form-group select:disabled,
.modal-body .form-group textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Horizontal form row (e.g. identities modal) */
.identities-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.identities-row .form-group {
  margin-bottom: 0;
}

.radio-row {
  display: flex;
  gap: 16px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  color: #1f2937;
  cursor: pointer;
}

.radio-label input[type="radio"],
.radio-label input[type="checkbox"] {
  accent-color: var(--accent, #005BFF);
}

.modal-submit-btn {
  width: 100%;
  padding: 11px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: var(--accent, #005BFF);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 4px;
}

.modal-submit-btn:hover {
  filter: brightness(1.15);
}

.modal-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.modal-danger-btn {
  width: 100%;
  padding: 11px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: #ef4444;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 4px;
}

.modal-danger-btn:hover {
  background: #dc2626;
}

.modal-cancel-btn {
  width: 100%;
  padding: 11px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  color: #6b7280;
  background: #f3f4f6;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 8px;
}

.modal-cancel-btn:hover {
  background: #e5e7eb;
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.modal-actions .modal-submit-btn,
.modal-actions .modal-danger-btn,
.modal-actions .modal-cancel-btn {
  margin-top: 0;
}

.modal-text {
  font-size: 0.9rem;
  color: #4b5563;
  line-height: 1.5;
  margin-bottom: 16px;
}

/* ── Standalone select inside modals (outside form-group) ── */

.modal-select {
  width: 100%;
  padding: 10px 12px;
  padding-right: 36px;
  font-size: 0.9rem;
  font-family: inherit;
  border: 1.5px solid #eef1f6;
  border-radius: 10px;
  background: #f8fafc;
  color: #1f2937;
  outline: none;
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: border-color 0.15s;
}

.modal-select:focus {
  border-color: var(--accent, #005BFF);
}

/* ── Table action buttons (square with rounded corners) ── */

.action-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1.5px solid #d1d5db;
  border-radius: 10px;
  background: #fff;
  color: #6b7280;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  text-decoration: none;
}

.action-btn:hover {
  border-color: #9ca3af;
  color: #1f2937;
  background: #f9fafb;
}

.action-btn-label {
  width: auto;
  padding: 0 12px;
  gap: 6px;
  font-size: 0.8125rem;
}

.action-btn-danger {
  border-color: #fca5a5;
  color: #ef4444;
  background: #fff;
}

.action-btn-danger:hover {
  border-color: #ef4444;
  color: #dc2626;
  background: #fef2f2;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
  .modal-box,
  .modal-box.modal-wide,
  .modal-box.modal-xl {
    max-width: 100%;
    border-radius: 12px;
  }
}
