/* ============================================================================
   Archive Link Connect — main stylesheet
   ============================================================================ */

* { box-sizing: border-box; }

:root {
    --bg: #0f1115;
    --bg-elev: #181b22;
    --bg-elev-2: #21252e;
    --border: #2a2f3a;
    --text: #e7e9ee;
    --text-muted: #8b94a5;
    --accent: #4a9eff;
    --accent-hover: #3a8eef;
    --success: #4caf50;
    --error: #ef4444;
    --warning: #f59e0b;
    --radius: 6px;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.5;
    min-height: 100vh;
}

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

h1, h2, h3 { margin-top: 0; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.15rem; color: var(--accent); }

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

/* ----------------------------------------------------------------------------
   Header / nav
---------------------------------------------------------------------------- */
.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elev);
}

.brand {
    color: var(--text);
    font-size: 1rem;
    text-decoration: none;
}
.brand:hover { text-decoration: none; }

.site-nav {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.site-nav a.active {
    color: var(--text);
    border-bottom: 2px solid var(--accent);
    padding-bottom: 0.15rem;
}

/* ----------------------------------------------------------------------------
   Buttons
---------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 0.9rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-elev-2);
    color: var(--text);
    font: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { background: #2a3040; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--bg-elev-2); }

.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.85rem; }
.btn-lg { padding: 0.75rem 1.25rem; font-size: 1.05rem; }
.btn-block { width: 100%; }

/* ----------------------------------------------------------------------------
   Hero (landing page)
---------------------------------------------------------------------------- */
.hero {
    max-width: 720px;
    margin: 6rem auto;
    padding: 0 1.5rem;
    text-align: center;
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.hero .lede {
    font-size: 1.15rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.hero .cta {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.hero .meta {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* ----------------------------------------------------------------------------
   Auth pages (login, signup, reset)
---------------------------------------------------------------------------- */
.auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 60px);
    padding: 2rem 1rem;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
}

.auth-card h1 {
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
}

.auth-card form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}

.auth-card label {
    display: flex;
    flex-direction: column;
    font-size: 0.875rem;
    gap: 0.35rem;
    color: var(--text-muted);
}

.auth-card input {
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font: inherit;
}

.auth-card input:focus {
    outline: none;
    border-color: var(--accent);
}

.auth-card .hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.auth-footer {
    text-align: center;
    margin-top: 1.25rem;
    font-size: 0.875rem;
}

.form-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
}

.success-state {
    text-align: center;
    padding: 1rem 0;
}

/* ----------------------------------------------------------------------------
   App pages (dashboard, workers, account)
---------------------------------------------------------------------------- */
.app-page {
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.page-head {
    margin-bottom: 1.5rem;
}

.card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}

.card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.card-head h2 { margin: 0; }

/* ----------------------------------------------------------------------------
   Subscription card
---------------------------------------------------------------------------- */
.subscription {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tier-name {
    font-size: 1.4rem;
    font-weight: 600;
}

.tier-state {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    width: fit-content;
}

.state-active { background: rgba(76, 175, 80, 0.15); color: var(--success); }
.state-trial { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.state-past_due, .state-canceled, .state-expired {
    background: rgba(239, 68, 68, 0.15); color: var(--error);
}

/* ----------------------------------------------------------------------------
   Worker list
---------------------------------------------------------------------------- */
.worker-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.worker-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.875rem;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.status-dot.online { background: var(--success); }
.status-dot.offline { background: var(--text-muted); }

.device-uuid { font-size: 0.75rem; }
.last-seen { margin-left: auto; font-size: 0.75rem; }

.empty-state {
    text-align: center;
    padding: 1rem;
    color: var(--text-muted);
}
.empty-state p { margin-bottom: 0.75rem; }

/* ----------------------------------------------------------------------------
   Pair form (workers.html)
---------------------------------------------------------------------------- */
.pair-form {
    display: grid;
    grid-template-columns: max-content 1fr auto;
    gap: 0.75rem;
    align-items: end;
    margin-top: 0.75rem;
}

.pair-form label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.pair-form input {
    padding: 0.55rem 0.7rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font: inherit;
}

.pair-form input:focus {
    outline: none;
    border-color: var(--accent);
}

.code-input {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 1.2rem;
    letter-spacing: 0.2rem;
    text-align: center;
    width: 8rem;
}

.pair-form button {
    height: fit-content;
}

.pair-result {
    margin-top: 0.5rem;
}

.pair-success {
    background: rgba(76, 175, 80, 0.1);
    border-left: 3px solid var(--success);
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
}

@media (max-width: 600px) {
    .pair-form { grid-template-columns: 1fr; }
}

/* ----------------------------------------------------------------------------
   Worker cards (workers.html)
---------------------------------------------------------------------------- */
.worker-card {
    list-style: none;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
        "head   actions"
        "body   actions";
    gap: 0.4rem 1rem;
    margin-bottom: 0.5rem;
}

.worker-card-head {
    grid-area: head;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.worker-name { font-size: 1rem; }

.worker-card-body {
    grid-area: body;
    font-size: 0.8rem;
    font-family: 'Consolas', 'Monaco', monospace;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.worker-card-body code {
    background: transparent;
    padding: 0;
    color: var(--text-muted);
}

.worker-card-actions {
    grid-area: actions;
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--error);
}
.btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: rgba(239, 68, 68, 0.5);
}

/* ----------------------------------------------------------------------------
   Account page
---------------------------------------------------------------------------- */
.profile-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 480px;
    margin-top: 0.5rem;
}

.profile-form label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.profile-form input {
    padding: 0.55rem 0.7rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font: inherit;
}

.profile-form input:focus {
    outline: none;
    border-color: var(--accent);
}

.profile-form input:disabled {
    color: var(--text-muted);
    cursor: not-allowed;
}

.profile-form button {
    align-self: flex-start;
    margin-top: 0.5rem;
}

.subscription-actions {
    margin-top: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.security-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.card-danger {
    border-color: rgba(239, 68, 68, 0.3);
}
.card-danger h2 {
    color: var(--error);
}

.quick-links {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.quick-links li { padding: 0.25rem 0; }

/* ----------------------------------------------------------------------------
   Toasts
---------------------------------------------------------------------------- */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 1000;
    pointer-events: none;
}

.toast {
    padding: 0.65rem 1rem;
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.875rem;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: auto;
    max-width: 320px;
}
.toast.toast-visible { opacity: 1; transform: translateY(0); }

.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--error); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-info { border-left: 3px solid var(--accent); }
