/* ============================================================
   Stena VK — стили
   ============================================================ */

:root {
    --bg:           #0f1115;
    --bg-2:         #1a1f2e;
    --bg-3:         #242a3d;
    --card:         #181c28;
    --card-2:       #1f2533;
    --text:         #e6e9f0;
    --muted:        #8a92a6;
    --border:       #2a3142;
    --primary:      #4f8cff;
    --primary-dk:   #2d6cdf;
    --danger:       #ff5b6b;
    --warn:         #ffb74d;
    --ok:           #4caf80;
    --pending:      #5fa8ff;
    --shadow:       0 4px 24px rgba(0, 0, 0, 0.25);
    --radius:       12px;
    --radius-sm:    8px;
    --gap:          16px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PT Sans", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); }

code {
    font-family: "SF Mono", Consolas, Menlo, monospace;
    font-size: 0.9em;
    background: var(--bg-3);
    padding: 1px 6px;
    border-radius: 4px;
}

.hidden { display: none !important; }

/* ----- Экраны ----- */
.screen {
    min-height: 100vh;
    padding: 24px 16px;
}
.screen.hidden { display: none; }

#screen-setup, #screen-login {
    display: flex;
    align-items: center;
    justify-content: center;
}

#screen-app {
    padding: 0;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: var(--gap);
}

/* ----- Карточки ----- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}
.card-narrow {
    max-width: 460px;
    width: 100%;
}

h1 {
    margin: 0 0 4px;
    font-size: 28px;
    font-weight: 700;
}
h2 {
    margin: 0 0 16px;
    font-size: 20px;
    font-weight: 600;
}
.subtitle {
    color: var(--muted);
    margin: 0 0 24px;
}

/* ----- Top bar ----- */
.topbar {
    background: var(--bg-2);
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(8px);
}
.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}
.topbar-info {
    color: var(--muted);
    font-size: 13px;
}
.logo {
    font-size: 17px;
    font-weight: 600;
}
.topbar-right {
    display: flex;
    gap: 8px;
}

/* ----- Формы ----- */
.form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.form-row {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
}
.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 0 0 auto;
}
.field-grow { flex: 1 1 300px; }
.field-action { align-self: flex-end; }
.label {
    font-size: 13px;
    color: var(--muted);
}
.label small { color: var(--muted); font-size: 11px; }

input[type="text"],
input[type="password"],
input[type="datetime-local"],
select {
    background: var(--bg-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    width: 100%;
    transition: border-color 0.15s, background 0.15s;
}
input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-3);
}
input::placeholder { color: var(--muted); }

select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%238a92a6' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 10px;
    padding-right: 32px;
}

.btn-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ----- Кнопки ----- */
.btn {
    border: 0;
    border-radius: var(--radius-sm);
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, transform 0.05s, opacity 0.15s;
    color: var(--text);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: translateY(1px); }

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dk); }

.btn-secondary {
    background: var(--bg-3);
    border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--border); }

.btn-ghost {
    background: transparent;
    padding: 8px 12px;
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-3); }

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--border);
}
.btn-danger:hover:not(:disabled) { background: var(--danger); color: white; border-color: var(--danger); }

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

/* ----- Подсказки / ошибки ----- */
.hint {
    color: var(--danger);
    font-size: 13px;
    margin: 0;
    min-height: 1em;
}
.hint-ok { color: var(--ok); }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; }

/* ----- Вкладки ----- */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
    overflow-x: auto;
}
.tab {
    background: transparent;
    border: 0;
    color: var(--muted);
    padding: 10px 16px;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab-active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ----- Списки ----- */
.list-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.empty {
    color: var(--muted);
    text-align: center;
    padding: 32px 16px;
    font-size: 14px;
}

.pin {
    background: var(--card-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.pin-main {
    flex: 1;
    min-width: 0;
}
.pin-url {
    color: var(--primary);
    text-decoration: none;
    font-size: 13px;
    word-break: break-all;
    display: block;
    margin-bottom: 4px;
}
.pin-url:hover { text-decoration: underline; }
.pin-meta {
    color: var(--muted);
    font-size: 12px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.pin-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* Статусы */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.badge-pending  { background: rgba(95, 168, 255, 0.15); color: var(--pending); }
.badge-done     { background: rgba(76, 175, 128, 0.15); color: var(--ok); }
.badge-failed   { background: rgba(255, 91, 107, 0.15); color: var(--danger); }
.badge-waiting  { background: rgba(255, 183, 77, 0.15); color: var(--warn); }

.pin-error {
    color: var(--danger);
    font-size: 12px;
    margin-top: 4px;
}

/* ----- Лог ----- */
.log {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-family: "SF Mono", Consolas, Menlo, monospace;
    font-size: 12px;
    line-height: 1.6;
    color: var(--muted);
    max-height: 500px;
    overflow: auto;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ----- Тост ----- */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-3);
    color: var(--text);
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    z-index: 100;
    animation: toast-in 0.2s ease-out;
    max-width: 90vw;
}
.toast.toast-ok    { border-left: 4px solid var(--ok); }
.toast.toast-error { border-left: 4px solid var(--danger); }
.toast.toast-info  { border-left: 4px solid var(--primary); }

@keyframes toast-in {
    from { transform: translate(-50%, 20px); opacity: 0; }
    to   { transform: translate(-50%, 0);    opacity: 1; }
}

/* ----- Адаптив ----- */
@media (max-width: 640px) {
    .screen { padding: 16px 8px; }
    .card { padding: 16px; }
    .form-row { flex-direction: column; align-items: stretch; }
    .field-action { align-self: stretch; }
    .btn { width: 100%; }
    .btn-row .btn { flex: 1; }
    .topbar { padding: 10px 12px; }
    .topbar-info { display: none; }
    .container { padding: 16px 8px; }
}
