/* Глобальные исправления для ширины экрана */
html, body {
  width: 100%;
  overflow-x: hidden;
}

.app-container {
  width: 100%;
}
:root {
  --bg-primary: #0f1419;
  --bg-secondary: #1a1f2e;
  --bg-tertiary: #232938;
  --bg-elevated: #2d3446;
  --border-color: #2d3748;
  --border-subtle: #3a4359;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --accent-primary: #5b7c99;
  --accent-secondary: #4a6b8a;
  --accent-glow: rgba(91, 124, 153, 0.15);
  --status-online: #486c6e;
  --status-warning: #8b6f47;
  --status-offline: #6b4848;
  --type-server: #4a6b8a;
  --type-switch: #4a7a6f;
  --type-storage: #6b5b8a;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg-primary: #f5f7fa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e8ecf1;
  --bg-elevated: #dfe4ea;
  --border-color: #cbd5e1;
  --border-subtle: #d4dbe4;
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-tertiary: #64748b;
  --accent-primary: #5b7c99;
  --accent-secondary: #7a94b0;
  --accent-glow: rgba(91, 124, 153, 0.1);
  --status-online: #6b9b7a;
  --status-warning: #c9a962;
  --status-offline: #a97a7a;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
  transition: background var(--transition-base), color var(--transition-base);
}

.header {
  height: 56px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: relative;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-brand { display: flex; align-items: center; gap: 12px; font-size: 1.1rem; font-weight: 700; letter-spacing: -0.5px; }
.header-brand svg { color: var(--accent-primary); }
.header-stats { display: flex; gap: 16px; }

.stat-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  transition: var(--transition-fast);
}

.stat-badge:hover { background: var(--bg-elevated); transform: translateY(-1px); }

.stat-dot { width: 8px; height: 8px; border-radius: 50%; }
.stat-dot.online-dot { background: var(--status-online); animation: pulse 2s infinite; }
.stat-dot.offline-dot { background: var(--status-offline); }
.stat-dot.total-dot { background: var(--accent-primary); }

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

.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
  margin-left: 16px;
}

.theme-toggle:hover { background: var(--bg-elevated); color: var(--text-primary); transform: rotate(15deg); }

.app-container { display: grid; grid-template-columns: 1fr 450px; height: calc(100vh - 56px); overflow: hidden; }
.main-view { position: relative; overflow: hidden; background: var(--bg-primary); display: flex; flex-direction: column; }

.nav-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
  flex-shrink: 0;
  min-height: 52px;
}

.nav-button {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
  font-size: 1rem;
}

.nav-button:hover:not(:disabled) { background: var(--accent-primary); color: white; border-color: var(--accent-primary); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.nav-button:disabled { opacity: 0.3; cursor: not-allowed; }

.nav-breadcrumb { flex: 1; font-size: 0.9rem; color: var(--text-secondary); display: flex; align-items: center; gap: 8px; overflow: hidden; flex-wrap: wrap; }
.breadcrumb-item { cursor: pointer; transition: var(--transition-fast); padding: 2px 6px; border-radius: 4px; }
.breadcrumb-item:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.scroll-area { flex: 1; overflow-y: auto; padding: 24px; }
.view-container { animation: fadeIn 0.4s ease forwards; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; justify-items: center; }

.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  transition: var(--transition-base);
  position: relative;
  overflow: hidden;
  width: 100%;
  max-width: 350px;
}

.card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--accent-primary); opacity: 0; transition: opacity var(--transition-fast); }
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--accent-secondary); }
.card:hover::before { opacity: 1; }

.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 12px; }
.card-title { font-size: 1.05rem; font-weight: 600; display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.card-meta { font-size: 0.8rem; color: var(--text-tertiary); display: flex; gap: 12px; margin-top: 8px; }

.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 12px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; }
.badge-open { background: var(--status-online); color: white; }
.badge-closed { background: var(--status-offline); color: white; }
.badge-server { background: var(--type-server); color: white; }
.badge-switch { background: var(--type-switch); color: white; }
.badge-storage { background: var(--type-storage); color: white; }

.gear-btn {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: rgba(255,255,255,0.05);
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
  opacity: 0;
  z-index: 5;
}

.card:hover .gear-btn { opacity: 1; }
.gear-btn:hover { background: var(--bg-elevated); color: var(--text-primary); transform: rotate(30deg); }

.u-rack {
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  margin-top: 20px;
}

.u-rack-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.u-slots {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.u-slot {
  height: 28px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  cursor: pointer;
  transition: var(--transition-fast);
  position: relative;
  font-size: 0.8rem;
}

.u-slot:hover {
  background: var(--bg-elevated);
  border-color: var(--accent-secondary);
  transform: translateX(4px);
}

.u-slot.occupied {
  border-left: 4px solid var(--accent-primary);
  background: linear-gradient(90deg, var(--accent-glow), var(--bg-tertiary));
}

.u-slot .u-number {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  font-weight: 600;
  position: absolute;
  right: 12px;
}

.u-slot .eq-info {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  flex: 1;
  margin-right: 40px;
}

.u-slot .eq-icon { font-size: 1rem; flex-shrink: 0; }
.u-slot .eq-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.u-slot .empty-label { position: absolute; left: 50%; transform: translateX(-50%); color: var(--text-tertiary); font-size: 0.75rem; opacity: 0.5; }

.side-panel { background: var(--bg-secondary); border-left: 1px solid var(--border-color); display: flex; flex-direction: column; overflow: hidden; }
.side-content { flex: 1; overflow-y: auto; padding: 20px; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-tertiary); }
.empty-icon { width: 64px; height: 64px; margin: 0 auto 16px; opacity: 0.3; }

.btn {
  padding: 10px 20px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn:hover { background: var(--bg-elevated); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn-primary { background: var(--accent-primary); border-color: var(--accent-primary); color: white; }
.btn-primary:hover { background: var(--accent-secondary); border-color: var(--accent-secondary); }
.btn-danger { background: rgba(239,68,68,0.1); border-color: var(--status-offline); color: var(--status-offline); }
.btn-danger:hover { background: var(--status-offline); color: white; }

.actions { display: flex; gap: 12px; margin-top: 20px; flex-wrap: wrap; }
.section-title { font-size: 1.3rem; font-weight: 700; margin: 32px 0 16px 0; display: flex; align-items: center; gap: 10px; padding-bottom: 8px; border-bottom: 2px solid var(--border-color); }

.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(4px); z-index: 200; align-items: center; justify-content: center; }
.modal-overlay.active { display: flex; }
.modal { background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 16px; width: 600px; max-width: 90vw; max-height: 85vh; overflow: hidden; box-shadow: var(--shadow-lg); }
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; background: var(--bg-tertiary); }
.modal-close { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--bg-elevated); color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: var(--transition-fast); }
.modal-close:hover { background: var(--status-offline); color: white; border-color: var(--status-offline); transform: rotate(90deg); }
.modal-body { padding: 24px; overflow-y: auto; max-height: 60vh; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 12px; background: var(--bg-tertiary); }

.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.form-input, .form-select { width: 100%; padding: 10px 14px; background: var(--bg-primary); border: 1px solid var(--border-color); border-radius: 8px; color: var(--text-primary); font-size: 0.9rem; outline: none; transition: var(--transition-fast); }
.form-input:focus, .form-select:focus { border-color: var(--accent-primary); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* Современные стили для кнопок */
.btn {
  padding: 8px 16px;
  border-radius: 10px;
  font-weight: 500;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.btn-primary {
  background: linear-gradient(135deg, #5b7c99, #4a6b8a);
  border: none;
}

.nav-button {
  transition: all 0.2s ease;
}

.nav-button:hover:not(:disabled) {
  transform: scale(1.05);
}

.stat-badge {
  transition: all 0.2s ease;
}

.stat-badge:hover {
  transform: translateY(-2px);
}

/* Карточки */
.card {
  transition: all 0.25s ease;
}

.card:hover {
  transform: translateY(-6px);
}

/* U слоты */
.u-slot {
  transition: all 0.2s ease;
}

.u-slot:hover {
  transform: translateX(6px);
}

/* Модальные окна */
.modal {
  animation: fadeInScale 0.25s ease;
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
