/* ============================================
   PROFILE PANEL (User Cabinet)
   Uses project CSS variables: --bg, --sf, --bd, --tx, --t2, --ac, --rd, etc.
   ============================================ */

.profile-overlay {
  position: fixed;
  inset: 0;
  z-index: 950;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  pointer-events: none;
}

.profile-overlay[data-open="true"] {
  pointer-events: auto;
}

#profile-overlay,
.profile-overlay-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 999;
}

.profile-wrap {
  position: relative;
  z-index: 1;
  background: var(--bg);
  color: var(--tx);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

/* Close button (desktop panel) */
.profile-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  width: 36px;
  height: 36px;
  border: none;
  background: var(--cd2);
  color: var(--t2);
  font-size: 18px;
  line-height: 1;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.profile-close-btn:hover {
  background: var(--bd);
  color: var(--tx);
}

/* --- Desktop layout (> 768px): overlay panel, centered, 90% width --- */
.profile-desktop {
  flex-direction: row;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90vw;
  max-width: 1200px;
  height: 90vh;
  min-height: 400px;
  overflow-y: auto;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  border: 1px solid var(--bd);
  z-index: 1000;
}

.profile-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sf);
  border-right: 1px solid var(--bd);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
}

.profile-sidebar-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #6c5ce7;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 20px 12px;
}

.profile-sidebar-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--tx);
  margin: 0 20px 2px;
}

.profile-sidebar-role {
  font-size: 12px;
  color: var(--t2);
  margin: 0 20px 20px;
}

.profile-sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 10px;
}

.profile-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  color: var(--t2);
  cursor: pointer;
  transition: all 0.15s;
}

.profile-nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--tx);
}

.profile-nav-item.active {
  background: rgba(108, 92, 231, 0.22);
  color: var(--ac);
  font-weight: 600;
}

.profile-sidebar-logout {
  margin: 12px 20px 0;
  padding: 10px 14px;
  border-radius: 10px;
  border: none;
  background: none;
  width: calc(100% - 40px);
  text-align: left;
  font-size: 13px;
  color: rgba(255, 150, 150, 0.85);
  cursor: pointer;
  transition: all 0.15s;
}

.profile-sidebar-logout:hover {
  background: rgba(239, 68, 68, 0.12);
  color: var(--rd);
}

.profile-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px 32px;
}

.profile-main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  gap: 20px;
  align-items: stretch;
}

.profile-info-card {
  grid-column: 1;
}

.profile-tariff-card {
  grid-column: 2;
}

.profile-kpi-grid {
  grid-column: 1 / -1;
}

@media (max-width: 768px) {
  .profile-main-grid {
    grid-template-columns: 1fr;
  }
}

.profile-content-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--tx);
  margin: 0 0 24px;
}

.profile-card {
  background: var(--sf);
  border: 1px solid var(--bd);
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 20px;
}

.profile-info-card,
.profile-tariff-card {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  margin-bottom: 0;
  border: 1px solid var(--bd);
}

[data-theme="dark"] .profile-info-card,
[data-theme="dark"] .profile-tariff-card {
  background: var(--sf);
}

.profile-tariff-card {
  text-align: center;
}

.profile-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--tx);
  margin: 0 0 16px;
}

.profile-avatar-block {
  position: relative;
  display: inline-block;
  margin-bottom: 20px;
}

.profile-avatar {
  border-radius: 50%;
  background: #6c5ce7;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.profile-avatar-lg {
  width: 100px;
  height: 100px;
  font-size: 28px;
}

.profile-avatar-cam {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--cd2);
  border: 1px solid var(--bd);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
}

/* Avatar upload wrap & overlay */
.profile-avatar-wrap {
  position: relative;
  display: inline-block;
  cursor: pointer;
  border-radius: 50%;
}
.profile-avatar-wrap:hover .avatar-overlay {
  opacity: 1;
}
.avatar-overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
.profile-avatar-wrap.avatar-loading .avatar-overlay {
  opacity: 1;
}
.avatar-spinner {
  width: 26px;
  height: 26px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: avatarSpin 0.8s linear infinite;
}
@keyframes avatarSpin {
  to { transform: rotate(360deg); }
}

/* Fields: same style as .fr in modals */
.profile-fr {
  margin-bottom: 14px;
}

.profile-fr:last-of-type {
  margin-bottom: 0;
}

.profile-fr label {
  display: block;
  font-size: 11px;
  color: var(--t2);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

/* Текстовые поля профиля — без стрелки (appearance + background-image) */
#profile-panel input,
#profile-panel select,
#profile-panel textarea {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: none;
}

.profile-fr input,
.profile-fr select,
.profile-fr textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--cd2);
  border: 1px solid var(--bd);
  border-radius: 10px;
  color: var(--tx);
  font-size: 13px;
  outline: none;
  font-family: inherit;
  box-sizing: border-box;
}

.profile-fr input:focus,
.profile-fr select:focus,
.profile-fr textarea:focus {
  border-color: var(--ac);
}

/* Убираем псевдоэлементы со стрелкой у полей профиля */
#profile-panel .profile-field-wrap::after,
#profile-panel .profile-fr::after {
  display: none !important;
}

/* Режим только чтение: подчёркивание, без рамки */
.profile-fr input[readonly],
.profile-field-wrap input[readonly] {
  border: none;
  border-bottom: 1px solid #e0e0e0;
  background: transparent;
  cursor: text;
  border-radius: 0;
}

.profile-fr input[readonly]:focus,
.profile-field-wrap input[readonly]:focus {
  border-color: transparent;
  border-bottom-color: #e0e0e0;
  outline: none;
}

/* Режим редактирования (нет readonly): фиолетовая рамка, скругление */
.profile-fr input:not([readonly]),
.profile-field-wrap input:not([readonly]) {
  border: 1px solid #6c5ce7;
  border-radius: 8px;
  background: #fff;
  padding: 8px 12px;
}

[data-theme="dark"] .profile-fr input:not([readonly]),
[data-theme="dark"] .profile-field-wrap input:not([readonly]) {
  background: var(--cd2);
}

.profile-fr input:not([readonly]):focus,
.profile-field-wrap input:not([readonly]):focus {
  border-color: var(--ac);
  outline: none;
}

.profile-field-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.profile-field-wrap input {
  padding-right: 36px;
}

.profile-edit-ico {
  position: absolute;
  right: 12px;
  font-size: 12px;
  color: var(--t2);
  cursor: pointer;
  pointer-events: auto;
}

.profile-edit-ico:hover {
  color: var(--ac);
}

/* Toast для профиля */
.profile-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 9999;
  color: white;
  pointer-events: none;
  white-space: nowrap;
}
.profile-toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.profile-toast--success {
  background: #27ae60;
}
.profile-toast--error {
  background: #e74c3c;
}

.profile-btn-save {
  margin-top: 20px;
  padding: 10px 20px;
  border-radius: 10px;
  border: none;
  background: var(--ac);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.profile-btn-save:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

/* Tariff block */
.profile-tariff-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.profile-tariff-badge {
  display: inline-flex;
  padding: 4px 12px;
  border-radius: 20px;
  background: #6c5ce7;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.profile-tariff-price {
  font-size: 15px;
  font-weight: 600;
  color: var(--tx);
}

.profile-tariff-date,
.profile-tariff-days {
  font-size: 13px;
  color: var(--t2);
  margin: 4px 0;
}

.profile-tariff-status {
  font-size: 13px;
  color: var(--gn);
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0 12px;
}

.profile-tariff-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gn);
}

/* SVG circular tariff diagram */
.tariff-circle-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 16px auto;
  text-align: center;
}

.tariff-circle-label {
  position: absolute;
  text-align: center;
}

.tariff-days-number {
  display: block;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

.tariff-days-text {
  display: block;
  font-size: 11px;
  color: #888;
  margin-top: 2px;
}

.tariff-svg {
  transform: rotate(0deg);
}

/* Legacy progress bar (kept for mobile tariff if needed) */
.profile-tariff-progress-wrap {
  height: 8px;
  background: var(--cd2);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.profile-tariff-progress {
  height: 100%;
  background: #6c5ce7;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.profile-tariff-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.profile-btn-primary {
  padding: 10px 20px;
  border-radius: 10px;
  border: none;
  background: var(--ac);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.profile-btn-primary:hover {
  filter: brightness(1.1);
}

.profile-btn-secondary {
  padding: 10px 20px;
  border-radius: 10px;
  border: 1px solid var(--bd);
  background: var(--cd2);
  color: var(--tx);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.profile-btn-secondary:hover {
  border-color: var(--ac);
  color: var(--ac);
}

/* KPI tiles — 4 в ряд на десктопе */
.profile-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.profile-kpi {
  background: var(--sf);
  border: 1px solid var(--bd);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
}

.profile-kpi-n {
  font-size: 20px;
  font-weight: 800;
  color: var(--tx);
  line-height: 1.2;
}

.profile-kpi-l {
  font-size: 11px;
  color: var(--t2);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-top: 4px;
}

/* --- Mobile layout (<= 768px): fullscreen overlay, блоки-карточки --- */
.profile-mobile {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  background: var(--bg);
  overflow-y: auto;
}

.profile-mob-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--sf);
  border-bottom: 1px solid var(--bd);
  flex-shrink: 0;
}

.profile-mob-back {
  padding: 8px 0;
  border: none;
  background: none;
  font-size: 14px;
  color: var(--ac);
  cursor: pointer;
}

.profile-mob-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--tx);
  margin: 0;
}

.profile-mob-body {
  padding: 20px 16px 100px;
}

.profile-mob-avatar-block {
  text-align: center;
  margin-bottom: 24px;
  position: relative;
  display: inline-block;
  margin-left: 50%;
  transform: translateX(-50%);
}

.profile-avatar-mob {
  width: 80px;
  height: 80px;
  font-size: 24px;
}

.profile-avatar-cam-mob {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 24px;
  height: 24px;
  font-size: 12px;
}

.profile-mob-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--tx);
  margin-top: 8px;
}

.profile-mob-role-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  background: rgba(108, 92, 231, 0.15);
  color: var(--ac);
  font-size: 11px;
  font-weight: 600;
  margin-top: 4px;
}

/* Мобиль: секции как карточки с разделением */
.profile-mob-section {
  margin-bottom: 12px;
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .profile-mob-section {
  background: var(--sf);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.profile-mob-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--tx);
  margin: 0 0 12px;
}

/* Мобильные поля профиля — текстовые, readonly по умолчанию */
.profile-mob-section .profile-fr input[readonly] {
  border-color: transparent;
  background: transparent;
  cursor: default;
}

.profile-mob-section .profile-fr input[readonly]:focus {
  border-color: transparent;
  outline: none;
}

.profile-mob-section .profile-fr input:not([readonly]) {
  border: 1px solid var(--bd);
  background: var(--cd2);
}

.profile-mob-section .profile-fr input:not([readonly]):focus {
  border-color: var(--ac);
}

.profile-mob-tariff-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.profile-mob-tariff-row .profile-tariff-badge {
  flex-shrink: 0;
}

.profile-mob-tariff-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.profile-mob-tariff-meta .profile-tariff-price,
.profile-mob-tariff-meta .profile-tariff-date,
.profile-mob-tariff-meta .profile-tariff-status {
  margin: 0;
  font-size: 13px;
}

/* Мобиль: блок Статистика — сетка 2×2, без фона у обёртки */
.profile-kpis-mob {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

/* Цветные KPI-плитки (мобиль и общие модификаторы) */
.profile-kpi-k1 { background: #e8f4fd !important; border: none !important; }
.profile-kpi-k1 .profile-kpi-n { color: #2d86c4; }
.profile-kpi-k2 { background: #e8f8f0 !important; border: none !important; }
.profile-kpi-k2 .profile-kpi-n { color: #27ae60; }
.profile-kpi-k3 { background: #f0ecfd !important; border: none !important; }
.profile-kpi-k3 .profile-kpi-n { color: #6c5ce7; }
.profile-kpi-k4 { background: #fdecea !important; border: none !important; }
.profile-kpi-k4 .profile-kpi-n { color: #e74c3c; }

.profile-mob-links {
  list-style: none;
  padding: 0;
  margin: 0 0 24px;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  border: none;
}

[data-theme="dark"] .profile-mob-links {
  background: var(--sf);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.profile-mob-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 16px;
  border: none;
  background: none;
  font-size: 14px;
  color: var(--tx);
  text-align: left;
  cursor: pointer;
  border-bottom: 1px solid var(--bd);
}

.profile-mob-link:last-child,
.profile-mob-link-toggle {
  border-bottom: none;
}

.profile-mob-link span:last-child {
  color: var(--t2);
}

.profile-mob-link-toggle {
  cursor: default;
}

.profile-toggle {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--gn);
  color: #fff;
}

.profile-toggle-on {
  background: var(--gn);
}

.profile-mob-logout {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: none;
  background: rgba(239, 68, 68, 0.12);
  color: var(--rd);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.profile-mob-logout:hover {
  background: rgba(239, 68, 68, 0.2);
}

/* Show/hide desktop vs mobile */
@media (max-width: 768px) {
  .profile-desktop {
    display: none !important;
  }

  .profile-mobile {
    display: block !important;
  }
}

@media (min-width: 769px) {
  .profile-mobile {
    display: none !important;
  }

  .profile-desktop {
    display: flex !important;
  }
}

/* When panel is open */
#profile-panel[data-open="true"] {
  display: flex !important;
}

/* Бургер-меню всегда виден в шапке (не перекрывать) */
.v10-top .v10-burg {
  display: flex !important;
  flex-shrink: 0;
}
