/* styles.css - Основные стили приложения ID Manager */

:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #e2e8f0;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border:  #cbd5e1;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  --info: #06b6d4;
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: all 0.2s ease;
}

/* Темная тема */
[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --border:  #475569;
  --accent: #60a5fa;
  --accent-hover: #3b82f6;
  --danger: #f87171;
  --success: #34d399;
  --warning:  #fbbf24;
  --info: #22d3ee;
}

/* ==================== ОСНОВНЫЕ СТИЛИ ====================*/

* {
  margin: 0;
  padding:  0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background:  linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  background-attachment: fixed;
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  padding: 20px;
}

/* ==================== КОНТЕЙНЕР ====================*/

.popup-container {
  max-width: 1200px;
  margin: 0 auto;
  background:  var(--bg-primary);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ==================== HEADER ====================*/

.header {
  background: var(--bg-secondary);
  padding: 20px;
  border-bottom:  1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 15px;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.5rem;
  font-weight:  700;
  color: var(--text-primary);
}

.header-title.icon {
  font-size: 1.8rem;
}

.header-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* ==================== TABS ====================*/

.tabs {
  display: flex;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  overflow-x: auto;
  flex-shrink: 0;
}

.tab {
  padding: 15px 20px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-weight: 500;
  cursor:  pointer;
  border-bottom:  3px solid transparent;
  transition:  var(--transition);
  white-space: nowrap;
  font-size: 0.95rem;
}

.tab: hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: var(--bg-primary);
}

/* ==================== TAB CONTENT ====================*/

.tab-content {
  display: none;
  padding: 20px;
  overflow-y: auto;
  flex:  1;
}

.tab-content.active {
  display: block;
}

/* ==================== CARDS ====================*/

.card {
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 20px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 15px;
  flex-wrap: wrap;
  gap: 10px;
}

.card-title {
  font-size: 1.1rem;
  font-weight:  600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ==================== FORMS ====================*/

.form-group {
  margin-bottom: 15px;
}

.form-label {
  display: block;
  margin-bottom: 5px;
  font-weight:  500;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  transition: var(--transition);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-textarea {
  resize:  vertical;
  min-height:  100px;
}

.form-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

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

/* ==================== BUTTONS ====================*/

.btn {
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration:  none;
  white-space: nowrap;
}

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

.btn:hover: not(: disabled) {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

/* Варианты кнопок */

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover: not(:disabled) {
  background: var(--accent-hover);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover:not(:disabled) {
  background: #059669;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
}

.btn-warning {
  background: var(--warning);
  color: white;
}

.btn-warning:hover:not(:disabled) {
  background: #d97706;
}

.btn-info {
  background: var(--info);
  color: white;
}

.btn-info:hover:not(:disabled) {
  background: #0891b2;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.btn-outline:hover:not(:disabled) {
  background: var(--bg-tertiary);
  border-color: var(--accent);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* ==================== STATS GRID ====================*/

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-secondary);
  padding: 15px;
  border-radius:  var(--radius-sm);
  border: 1px solid var(--border);
  text-align: center;
  transition: var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 5px;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ==================== TABLES ====================*/

.table-container {
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 20px;
  max-height: 600px;
  overflow-y: auto;
}

.table {
  width: 100%;
  border-collapse:  collapse;
}

.table th {
  background: var(--bg-secondary);
  padding: 12px 15px;
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index:  10;
}

.table td {
  padding: 12px 15px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.table tr:hover {
  background: var(--bg-tertiary);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

/* ==================== STATUS INDICATORS ====================*/

.status-online {
  color: var(--success);
  font-weight: 600;
}

.status-offline {
  color: var(--danger);
  font-weight: 600;
}

.status-warning {
  color: var(--warning);
  font-weight: 600;
}

.status-disabled {
  background: #f8d7da;
  color: #721c24;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 0.8rem;
}

.status {
  padding: 12px 16px;
  border-radius:  var(--radius-sm);
  font-size: 0.9rem;
  margin:  10px 0;
}

.status.success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.status.error {
  background: #fee2e2;
  color:  #7f1d1d;
  border: 1px solid #fecaca;
}

.status.warning {
  background: #fef3c7;
  color: #78350f;
  border: 1px solid #fde68a;
}

.status.info {
  background: #cffafe;
  color: #164e63;
  border: 1px solid #a5f3fc;
}

/* ==================== DOWNLOAD SECTION ====================*/

.download-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 15px;
  margin-bottom:  20px;
}

.download-card {
  background: var(--bg-secondary);
  padding: 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  text-align: center;
  transition: var(--transition);
}

.download-card:hover {
  box-shadow:  var(--shadow);
  transform: translateY(-2px);
}

.download-icon {
  font-size: 2rem;
  margin-bottom: 10px;
}

/* ==================== PAGINATION ====================*/

.pagination {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
}

.pagination button {
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  transition: var(--transition);
}

.pagination button:hover:not(.active) {
  background: var(--bg-tertiary);
  border-color: var(--accent);
}

.pagination button.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.pagination button: disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ==================== BACKUP STYLES ====================*/

.backup-item {
  padding: 10px;
  margin-bottom: 8px;
  background: var(--bg-secondary);
  border-radius: 6px;
  border-left:  4px solid var(--success);
  cursor: pointer;
  transition: var(--transition);
}

.backup-item:hover {
  background: var(--bg-tertiary);
  transform: translateX(2px);
}

.backup-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  flex-wrap: wrap;
  gap: 10px;
}

.backup-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.backup-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.backup-info {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.backup-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}

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

/* ==================== MODAL STYLES ====================*/

.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height:  100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  width: 100%;
  max-width: 600px;
  max-height:  90vh;
  overflow-y:  auto;
  animation: slideIn 0.3s ease-out;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  padding-top: 15px;
  border-top:  1px solid var(--border);
  flex-wrap: wrap;
}

.modal-actions.btn {
  flex: 1;
  min-width: 120px;
  padding: 12px;
  font-size: 1rem;
}

/* ==================== SELECTOR STYLES ====================*/

.selector-textarea {
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  line-height: 1.4;
}

.quick-selectors-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom:  10px;
}

.quick-selector-btn {
  padding: 8px 12px;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  font-weight: 500;
}

.quick-selector-btn:hover {
  background: var(--accent);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  border-color: var(--accent);
}

.quick-selector-btn: active {
  transform: translateY(0);
}

/* ==================== IMPORT STYLES ====================*/

.import-preview-item {
  padding: 8px;
  margin:  4px 0;
  background: var(--bg-secondary);
  border-radius: 6px;
  border-left:  3px solid var(--success);
  font-family: monospace;
  font-size:  0.8rem;
  word-break: break-all;
}

.import-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin:  10px 0;
}

.import-stat {
  text-align: center;
  padding: 8px;
  background: var(--bg-primary);
  border-radius: 6px;
  border:  1px solid var(--border);
}

.import-stat-value {
  font-size:  1.2rem;
  font-weight:  bold;
  color: var(--accent);
}

.import-stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 4px;
}

/* ==================== SETTING STATUS ====================*/

.setting-status {
  padding: 4px 8px;
  border-radius: 12px;
  font-size:  0.8rem;
  font-weight: 600;
}

.setting-status.status-enabled {
  background: #d1fae5;
  color:  #065f46;
}

.setting-status.status-disabled {
  background: #fee2e2;
  color:  #7f1d1d;
}

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

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

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

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

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

/* ==================== SCROLLBAR ====================*/

: :-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ==================== RESPONSIVE ====================*/

@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  .popup-container {
    max-height: 95vh;
  }

  .header {
    flex-direction: column;
    align-items: stretch;
  }

  .header-controls {
    justify-content: center;
    width: 100%;
  }

  .tabs {
    padding: 0 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tab {
    padding: 12px 15px;
    font-size: 0.85rem;
  }

  .tab-content {
    padding: 15px;
  }

  .form-row {
    flex-direction: column;
  }

  .form-row.form-group {
    flex: 1 ! important;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .table-container {
    max-height: 400px;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .modal-content {
    max-width: calc(100% - 40px);
  }

  .quick-selectors-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .download-grid {
    grid-template-columns: 1fr;
  }

  .btn {
    font-size: 0.85rem;
    padding: 8px 12px;
  }

  .pagination {
    justify-content: center;
  }

  .pagination button {
    padding: 6px 10px;
    font-size:  0.75rem;
  }
}

@media (max-width: 480px) {
  body {
    padding: 5px;
  }

  .popup-container {
    border-radius: 8px;
  }

  .header {
    padding: 15px;
  }

  .header-title {
    font-size: 1.2rem;
  }

  .header-title.icon {
    font-size: 1.5rem;
  }

  .tabs {
    padding: 0 5px;
  }

  .tab {
    padding: 10px 12px;
    font-size: 0.75rem;
  }

  .card {
    padding: 15px;
    margin-bottom: 15px;
  }

  .stats-grid {
    gap: 10px;
  }

  .stat-value {
    font-size: 1.2rem;
  }

  .stat-label {
    font-size: 0.7rem;
  }

  .table {
    font-size: 0.8rem;
  }

  .table th,
  .table td {
    padding: 8px 10px;
  }

  .form-input,
  .form-select,
  .form-textarea {
    font-size: 16px; /* Предотвращает зум на iOS */
  }

  .btn {
    font-size: 0.8rem;
    padding: 8px 10px;
  }

  .modal-content {
    max-width: 100%;
  }

  .quick-selectors-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    gap: 8px;
  }
}

/* ==================== DARK MODE FIXES ====================*/

@media (prefers-color-scheme: dark) {
  body {
    background:  linear-gradient(135deg, #1e3a8a 0%, #3730a3 100%);
    background-attachment: fixed;
  }

  .table tbody tr:hover {
    background: rgba(59, 130, 246, 0.1);
  }

  code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius:  4px;
  }
}

/* ==================== UTILITY CLASSES ====================*/

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

.text-right {
  text-align: right;
}

.text-left {
  text-align: left;
}

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top:  1rem; }
.mt-4 { margin-top:  1.5rem; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }

.p-0 { padding: 0; }
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 1rem; }
.p-4 { padding: 1.5rem; }

.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }

.hidden {
  display: none ! important;
}

.visible {
  display: block !important;
}

.opacity-50 {
  opacity: 0.5;
}

.opacity-75 {
  opacity:  0.75;
}

.cursor-pointer {
  cursor: pointer;
}

.cursor-not-allowed {
  cursor: not-allowed;
}