/* filesunlim — интерфейс загрузки изображений */

:root {
    --bg-1: #eef2ff;
    --bg-2: #faf5ff;
    --surface: #ffffff;
    --text: #0f172a;
    --muted: #6b7280;
    --faint: #9ca3af;
    --border: #e6e8ef;
    --border-strong: #d6d9e3;
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-soft: #eef2ff;
    --violet: #8b5cf6;
    --ok-bg: #ecfdf5;
    --ok-border: #a7f3d0;
    --ok-text: #047857;
    --err-bg: #fef2f2;
    --err-border: #fecaca;
    --err-text: #b91c1c;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
    --shadow: 0 12px 28px -8px rgba(79, 70, 229, .18), 0 6px 12px -6px rgba(16, 24, 40, .08);
    --shadow-lg: 0 24px 60px -12px rgba(79, 70, 229, .28);
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    color: var(--text);
    background:
        radial-gradient(1100px 520px at 8% -8%, var(--bg-1), transparent 60%),
        radial-gradient(1000px 520px at 100% 0%, var(--bg-2), transparent 55%),
        #f7f8fc;
    background-attachment: fixed;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

.ico { flex: 0 0 auto; }
svg { display: inline-block; vertical-align: middle; }

/* --- Верхняя панель --- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255, 255, 255, .8);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
}
.topbar-inner {
    max-width: 1000px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-weight: 800;
    font-size: 18px;
    letter-spacing: -.02em;
    color: var(--text);
    text-decoration: none;
}
.brand .ico { color: var(--primary); width: 22px; height: 22px; }
.menu { display: flex; gap: 4px; align-items: center; }
.menu-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    text-decoration: none;
    padding: 8px 13px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    transition: background .15s, color .15s;
}
.menu-link:hover { background: var(--primary-soft); color: var(--primary-dark); }
.menu-link.active { background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }
.menu-link.logout { color: var(--faint); }
.menu-link.logout:hover { background: var(--err-bg); color: var(--err-text); }
@media (max-width: 560px) { .menu-link span { display: none; } }

/* --- Контейнер --- */
.container {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 36px 20px 56px;
    flex: 1;
}
.page-title {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -.025em;
    margin: 0 0 6px;
}
.page-sub { color: var(--muted); margin: 0 0 26px; }

.footer {
    text-align: center;
    color: var(--faint);
    font-size: 13px;
    padding: 22px;
}

/* --- Сетки --- */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }

/* --- Карточки --- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 26px;
    margin-bottom: 20px;
    transition: box-shadow .2s, transform .2s, border-color .2s;
}
.card:hover { box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.card-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--primary), var(--violet));
    color: #fff;
    box-shadow: 0 6px 14px -4px rgba(99, 102, 241, .5);
}
.card-title { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.card-hint { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.card-head + .card-hint { margin-top: 6px; }
code {
    font-family: var(--mono);
    background: var(--primary-soft);
    color: var(--primary-dark);
    padding: 2px 7px;
    border-radius: 6px;
    font-size: 12.5px;
}

/* --- Поля --- */
.field { display: block; margin-bottom: 16px; }
.field-label {
    display: block;
    font-size: 13px;
    color: var(--text);
    margin-bottom: 7px;
    font-weight: 600;
}
.field input[type="text"],
.field input[type="url"],
.field input[type="password"],
.field input[type="number"] {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: var(--font);
    color: var(--text);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
}
.field input::placeholder { color: var(--faint); }
.field input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, .14);
}
.copy-input {
    cursor: pointer;
    background: #f8fafc;
    font-family: var(--mono);
    font-size: 12.5px;
    color: var(--text);
}
.copy-input:hover { border-color: var(--primary); }

.checkbox {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 14px;
    color: var(--muted);
    margin: -2px 0 16px;
    cursor: pointer;
}
.checkbox input { width: 17px; height: 17px; accent-color: var(--primary); }

/* --- Drag&drop зона загрузки файла --- */
.dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    padding: 30px 18px;
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    background: #fbfbfe;
    color: var(--muted);
    cursor: pointer;
    transition: border-color .15s, background .15s, color .15s;
    margin-bottom: 16px;
}
.dropzone:hover, .dropzone.dragover {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary-dark);
}
.dropzone .ico { width: 30px; height: 30px; color: var(--primary); }
.dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}
.dropzone-main { font-weight: 600; color: var(--text); }
.dropzone-sub { font-size: 12.5px; }
.dropzone-name { font-weight: 600; color: var(--primary-dark); }

/* --- Кнопки --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: var(--radius-sm);
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    text-decoration: none;
    transition: filter .15s, transform .04s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--violet));
    color: #fff;
    box-shadow: 0 10px 20px -8px rgba(99, 102, 241, .6);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border-strong);
}
.btn-ghost:hover { background: #f8fafc; }
.btn-block { width: 100%; }

/* --- Уведомления --- */
.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: var(--radius-sm);
    padding: 13px 16px;
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid transparent;
}
.alert-ok { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok-text); }
.alert-error { background: var(--err-bg); border-color: var(--err-border); color: var(--err-text); }

/* --- Результат загрузки --- */
.result-card {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
    margin-bottom: 22px;
}
@media (max-width: 620px) { .result-card { grid-template-columns: 1fr; } }
.result-preview img {
    width: 100%;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background:
        linear-gradient(45deg, #f1f5f9 25%, transparent 25%, transparent 75%, #f1f5f9 75%) 0 0/18px 18px,
        linear-gradient(45deg, #f1f5f9 25%, #fff 25%, #fff 75%, #f1f5f9 75%) 9px 9px/18px 18px;
}
.result-fields { min-width: 0; }
.result-fields .field:last-child { margin-bottom: 0; }
.result-edit { margin-top: 12px; }

/* --- Редактор размера --- */
.edit-card {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 26px;
    align-items: start;
}
@media (max-width: 720px) { .edit-card { grid-template-columns: 1fr; } }
.edit-preview img {
    width: 100%;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background:
        linear-gradient(45deg, #f1f5f9 25%, transparent 25%, transparent 75%, #f1f5f9 75%) 0 0/18px 18px,
        linear-gradient(45deg, #f1f5f9 25%, #fff 25%, #fff 75%, #f1f5f9 75%) 9px 9px/18px 18px;
}
.edit-dims { margin: 12px 0 0; color: var(--muted); font-size: 14px; }
.edit-controls .btn-ghost { margin-top: 10px; }

/* --- Логин --- */
.login-wrap {
    min-height: calc(100vh - 60px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-card {
    width: 100%;
    max-width: 400px;
    text-align: left;
    box-shadow: var(--shadow-lg);
    padding: 34px;
}
.login-badge {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--violet));
    color: #fff;
    box-shadow: 0 12px 24px -8px rgba(99, 102, 241, .6);
}
.login-badge .ico { width: 28px; height: 28px; }
.login-logo {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -.03em;
    text-align: center;
    margin: 0;
}
.login-sub { text-align: center; color: var(--muted); margin: 4px 0 24px; font-size: 14px; }

/* --- Bare-страницы (форма/результат API во фрейме) --- */
body.is-bare { background: #f7f8fc; }
.embed { max-width: 480px; margin: 30px auto; padding: 0 16px; }
.embed .card { margin-bottom: 14px; }
.embed-back { text-align: center; margin-top: 4px; }
.embed-back a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--primary-dark);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
}
.embed-back a:hover { text-decoration: underline; }

/* --- Тост копирования (создаётся embed.js) --- */
.toast {
    position: fixed;
    left: 50%;
    bottom: 30px;
    transform: translateX(-50%) translateY(8px);
    background: #111827;
    color: #fff;
    padding: 11px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, transform .2s;
    z-index: 60;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
