/* =============================
   🎨 Theme Variables
============================= */
:root {
    --primary: #4f46e5;
    --secondary: #64748b;
    --bg: #0b1220;
    --card: #0f172a;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --success: #10b981;
    --danger: #ef4444;
}

/* =============================
   🔧 Base Styles
============================= */
* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, 'Helvetica Neue', Arial, 'Noto Sans', 'Apple Color Emoji', 'Segoe UI Emoji';
}

a {
    color: var(--text);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* =============================
   🧱 Layout Containers
============================= */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px;
}

/* =============================
   🧭 Header
============================= */
.site-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    position: sticky;
    top: 0;
    background: rgba(11, 18, 32, 0.8);
    backdrop-filter: saturate(140%) blur(8px);
    z-index: 10;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand a {
    font-weight: 700;
    color: #fff;
    font-size: 18px;
}

.nav a {
    margin-right: 14px;
    color: var(--muted);
}

.nav .btn {
    margin-left: 8px;
}

.user-info {
    display: flex;
    gap: 10px;
    align-items: center;
}

.user-email {
    color: var(--muted);
    font-size: 14px;
}

.user-balance {
  color: var(--muted);
  font-size: 14px;
}


/* =============================
   🦶 Footer
============================= */
.site-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    margin-top: 40px;
    color: var(--muted);
}

/* =============================
   🧩 Buttons
============================= */
.btn {
    display: inline-block;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: 0.2s;
    background: transparent;
}

.btn:hover {
    transform: translateY(-1px);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.15), rgba(79, 70, 229, 0.05));
    border-color: rgba(79, 70, 229, 0.5);
    color: #c7d2fe;
}

.btn-secondary {
    background: rgba(100, 116, 139, 0.1);
    border-color: rgba(100, 116, 139, 0.4);
    color: #cbd5e1;
}

.btn-google {
    background: #fff;
    color: #111;
    border-color: #e5e7eb;
}

/* =============================
   🏠 Hero Section
============================= */
.hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 80px 0;
    text-align: center;
}

/* =============================
   📦 Cards & Tables
============================= */
.card {
    background: var(--card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    padding: 18px;
    margin: 12px 0;
}

.center {
    text-align: center;
}

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

.table th,
.table td {
    padding: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    text-align: left;
}

.table th {
    color: #a8b3cf;
    font-weight: 600;
}

.table .muted {
    color: var(--muted);
}

/* =============================
   📊 Dashboard
============================= */
.dashboard-top {
    display: flex;
    gap: 16px;
    align-items: stretch;
    flex-wrap: wrap;
}

.balance-card {
    flex: 1;
    min-width: 260px;
    background: linear-gradient(145deg, rgba(16, 185, 129, 0.12), rgba(16, 185, 129, 0.02));
    border: 1px solid rgba(16, 185, 129, 0.4);
    border-radius: 14px;
    padding: 16px;
}

.balance-label {
    color: #8bf0c8;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.08em;
}

.balance-value {
    display: inline-block;
    margin-top: 6px;
    font-size: 28px;
    font-weight: 700;
    color: #e7fff5;
}

.topup-action {
    display: flex;
    align-items: center;
}

.messages {
    margin: 10px 0;
}

.message {
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.message.error {
    border-color: rgba(239, 68, 68, 0.6);
    background: rgba(239, 68, 68, 0.08);
}

/* =============================
   🧾 Forms
============================= */
.form-inline {
    display: flex;
    gap: 10px;
    align-items: center;
}

.form-inline input[type=number],
.form-inline input[type=text],
.form-inline input[type=email] {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 10px 12px;
    color: var(--text);
}

.muted {
    color: var(--muted);
}

/* =============================
   🌐 Sites Section
============================= */
.sites-section h3 {
    margin-bottom: 8px;
}

/* =============================
   🪟 Modal
============================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.7);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;

    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;

}

/* ⚙️ Скрытие модалки, если hidden */
.modal-overlay[hidden] {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
    display: flex;
}

.modal {
    width: min(980px, 100%);
    background: var(--card);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding: 14px 16px;
}

.modal-header h3 {
    margin: 0;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 18px;
    cursor: pointer;
}

.modal-body {
    padding: 16px;
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: center;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding: 12px 16px;
}

.two-columns {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 16px;
}

@media (max-width: 860px) {
    .two-columns {
        grid-template-columns: 1fr;
    }
}

.modal-left .form-group {
    margin-bottom: 14px;
}

.modal-left input[type=url],
.modal-left input[type=number],
.modal-left textarea {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 10px 12px;
    color: var(--text);
}

.modal-left .inline {
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-left .hint {
    margin-top: 6px;
}

.modal-left .hint.error {
    color: #fecaca;
}

.modal-left .hint.success {
    color: #a7f3d0;
}

.screenshot-box {
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    min-height: 240px;
    max-height: 480px;
    overflow: hidden;
    display: flex; /* ← только это */
    align-items: center;
    justify-content: center;
    padding: 8px;
    position: relative;
}

.preview-placeholder {
    position: absolute;
    inset: 0;
    border-radius: 12px;
    background: rgba(255,255,255,0.03);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 6px;
    text-align: center;
    color: #889;
    font-size: 14px;
    padding: 10px;
}

.preview-placeholder.error {
    color: #ff6b6b;
}

.placeholder-icon {
    font-size: 32px;
    opacity: 0.7;
}

#previewLoader {
    position: absolute;
    z-index: 5;
}

.screenshot-box img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
}

.btn-create-site {
    display: inline-flex;
    align-items: center;
}
.btn-create-site::after {
    content: "➕"; /* замените на нужный символ/иконку */
    margin-left: 8px;
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity .2s ease, transform .2s ease;
  }

.btn-create-site:hover::after {
    opacity: 1;
    transform: translateX(0);
}

/* Контейнер в момент загрузки */
.screenshot-loading {
    filter: blur(8px);
    opacity: 0.4;
    animation: pulseGlow 1.6s ease-in-out infinite;
    transition: opacity .3s ease, filter .3s ease;
}

/* Изображение появилось → плавно показать */
.screenshot-loaded {
    opacity: 0;
    filter: blur(6px);
    transition: opacity .6s ease, filter .6s ease;
}

.screenshot-loaded.show {
    opacity: 1;
    filter: blur(0);
}

/* Пульсация */
@keyframes pulseGlow {
    0% {
        opacity: 0.35;
        transform: scale(0.995);
    }
    50% {
        opacity: 0.55;
        transform: scale(1.01);
    }
    100% {
        opacity: 0.35;
        transform: scale(0.995);
    }
}


.gradient-loader {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: conic-gradient(
        from 0deg,
        #0051ff,
        #00c3ff,
        #008cff,
        #0051ff
    );
    animation: rotate 1s linear infinite;
    mask: radial-gradient(circle, transparent 55%, black 56%);
    margin: auto;
}

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

.screenshot-scroll {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;

    /* важно — отменяем влияние flex из screenshot-box */
    flex: 1 1 auto;
    align-self: stretch;

    /* чтобы скролл выглядел красиво */
    border-radius: 8px;
}

/* Сама картинка — занимает всю ширину, но по высоте не масштабируется */
.screenshot-scroll img {
    width: 100%;
    height: auto;
    display: block;

    /* убрать авто-центрирование, если было унаследовано */
    margin: 0;
}

  #modal_edit_image .modal {
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* чтобы внутренности скроллились, а не раздували модалку */
  }

  #modal_edit_image .modal-header,
  #modal_edit_image .modal-footer {
    flex: 0 0 auto;
  }

  #modal_edit_image .modal-body {
    flex: 1 1 auto;   /* тело занимает остаток */
    min-height: 0;    /* важно для корректного скролла внутри */
    overflow: auto;   /* скроллим содержимое, а не весь экран */
  }

  /* сетка тела модалки тоже не должна раздувать высоту */
  #modal_edit_image .two-columns,
  #modal_edit_image .modal-left,
  #modal_edit_image .modal-right {
    min-height: 0;
  }

  /* чуть сильнее ограничим превью по высоте, чтобы точно не «выпирало» */
#modal_edit_image #imgPreview {
  max-width: min(100%, 520px);
  max-height: 36vh;  /* было 50vh */
  width: auto;
  height: auto;
  display: block;
  object-fit: contain;
}

@media (max-width: 860px) {
  #modal_edit_image #imgPreview {
    max-height: 28vh; /* было 40vh */
  }
}

/* История в пределах модалки */
#modal_edit_image #imgAiHistory {
  max-height: 30vh; /* вместо фиксированных 320px */
}



/* --- Subsite tasks in sidebar --- */
.sidebar .subtasks {
  margin: 8px 0 12px 0;
  padding: 8px;
  border-radius: 12px;
  border: 1px dashed rgba(255,255,255,0.18);
  background: rgba(79,70,229,0.06);
}

.subtasks-title {
  font-size: 13px;
  color: #c7d2fe;
  margin-bottom: 6px;
}

.tasks-list {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow-x: hidden; /* страховка от горизонтального скролла */
}

.task-item {
  display: flex;
  flex-direction: column;  /* ВОТ ТУТ: кладём всё столбцом */
  align-items: stretch;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.03);
  margin-bottom: 6px;
}
.task-item:last-child { margin-bottom: 0; }
/* Бейдж статуса */
.task-badge {
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.2);
}
.task-badge.awaiting { color: #93c5fd; border-color: rgba(147,197,253,0.4); background: rgba(59,130,246,0.12); }
.task-badge.processing { color: #fdba74; border-color: rgba(253,186,116,0.4); background: rgba(234,88,12,0.12); }
.task-badge.error { color: #fecaca; border-color: rgba(254,202,202,0.4); background: rgba(239,68,68,0.12); }


.task-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

.task-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Ряд кнопок действий — под задачей */
.task-actions-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;       /* чтобы кнопки переносились и не тянули ширину */
}


.task-actions {
  display: flex;
  gap: 6px;
}
.icon-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.12);
  padding: 6px 8px;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
}
.icon-btn:hover {
  background: rgba(255,255,255,0.06);
}

.icon-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.12);
  padding: 6px 8px;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
}
.icon-btn:hover {
  background: rgba(255,255,255,0.06);
}


/* Сообщение об ошибке — под задачей, в потоке, с переносами */
.task-error-msg {
  color: #fecaca;
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.35);
  padding: 8px 10px;
  border-radius: 8px;
  white-space: normal;
  overflow-wrap: anywhere;
}




/* Тип таска — бейдж */
.task-type-badge {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 8px;
  border: 1px solid rgba(147,197,253,0.35);
  color: #bfdbfe;
  background: rgba(59,130,246,0.12);
}


/* Для хинта ошибки */
.task-item { position: relative; }

.task-error-tip { display: none !important; }


.task-item.has-error:hover .task-error-tip {
  display: block;
}

.task-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Иконка-индикатор ошибки в строке задачи */
.task-error-indicator {
  color: #fecaca;
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.35);
  padding: 0 6px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 20px;
}

/* Глобальный тултип ошибки поверх всей страницы */
.global-tooltip {
  position: fixed;
  z-index: 2000;
  max-width: 480px;
  padding: 8px 10px;
  background: rgba(17,24,39,0.96); /* темный фон */
  color: #fecaca;                   /* красный текст */
  border: 1px solid rgba(239,68,68,0.5);
  border-radius: 8px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.35);
  pointer-events: none;             /* чтобы не перехватывать ховер */
  white-space: normal;
  overflow-wrap: anywhere;
}

/* Можно скрыть старую «в потоке» ошибку, если где-то ещё всплывёт */
.task-error-msg { display: none !important; }
