/* assets/css/style.css */
:root {
    --bg: #0f1115;
    --bg-2: #171a21;
    --bg-3: #1f232c;
    --border: #2a2f3a;
    --text: #e8e9ee;
    --text-dim: #9aa0ad;
    --accent: #ff6a3d;
    --accent-hover: #ff8259;
    --danger: #e05555;
    --danger-hover: #f06666;
    --ok: #4ec9a1;
    --err: #ff7676;
    --radius: 10px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* ---------- Buttons ---------- */
button, .btn {
    font-family: inherit;
    font-size: 14px;
    padding: 8px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-3);
    color: var(--text);
    cursor: pointer;
    transition: all .15s ease;
}
button:hover, .btn:hover { background: var(--border); }
button:disabled { opacity: .5; cursor: not-allowed; }

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

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

.btn-link {
    background: none;
    border: none;
    color: var(--text-dim);
    padding: 6px 10px;
}
.btn-link:hover { color: var(--text); background: var(--bg-3); }

/* ---------- Forms ---------- */
input[type="text"],
input[type="password"],
input[type="number"],
textarea {
    font-family: inherit;
    font-size: 15px;
    padding: 10px 12px;
    background: var(--bg-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    outline: none;
    transition: border-color .15s;
}
input:focus, textarea:focus {
    border-color: var(--accent);
}

label {
    display: block;
    margin-bottom: 12px;
    color: var(--text-dim);
    font-size: 13px;
}
label input { margin-top: 4px; color: var(--text); }

.msg {
    padding: 10px 12px;
    border-radius: var(--radius);
    margin-bottom: 12px;
    font-size: 14px;
}
.msg.ok  { background: rgba(78, 201, 161, .12); color: var(--ok);  border: 1px solid rgba(78, 201, 161, .3); }
.msg.err { background: rgba(255, 118, 118, .12); color: var(--err); border: 1px solid rgba(255, 118, 118, .3); }

/* ---------- Auth (Login/Setup) ---------- */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: radial-gradient(circle at 30% 20%, #1a1f2b 0%, #0f1115 60%);
}
.auth-box {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.auth-box h1 {
    margin: 0 0 24px;
    font-size: 24px;
    text-align: center;
}
.auth-box button[type="submit"] {
    width: 100%;
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 600;
    padding: 12px;
    margin-top: 8px;
    font-size: 15px;
}
.auth-box button[type="submit"]:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}
.auth-box p { color: var(--text-dim); font-size: 14px; }

/* ---------- App Layout ---------- */
.app-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--bg-2);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.topbar .brand {
    font-weight: 700;
    font-size: 16px;
}
.topbar .user {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-dim);
    font-size: 14px;
}

/* ---------- Dashboard Layout ---------- */
.dashboard {
    display: grid;
    grid-template-columns: 320px 1fr;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    background: var(--bg-2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.sidebar-head h2 {
    margin: 0;
    font-size: 15px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: .05em;
}

.script-list {
    list-style: none;
    margin: 0;
    padding: 8px;
    overflow-y: auto;
    flex: 1;
}
.script-list li {
    padding: 12px;
    border-radius: var(--radius);
    cursor: pointer;
    margin-bottom: 4px;
    border: 1px solid transparent;
    transition: all .12s;
}
.script-list li:hover {
    background: var(--bg-3);
}
.script-list li.active {
    background: var(--bg-3);
    border-color: var(--accent);
}
.script-list li.empty {
    color: var(--text-dim);
    text-align: center;
    padding: 40px 12px;
    cursor: default;
    font-size: 13px;
}
.script-list li.empty:hover { background: none; }
.script-list .title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}
.script-list .meta {
    font-size: 12px;
    color: var(--text-dim);
}

/* ---------- Editor ---------- */
.editor {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
}
.editor-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.editor-head input#script-title {
    flex: 1;
    font-size: 18px;
    font-weight: 600;
    background: transparent;
    border: 1px solid transparent;
    padding: 6px 10px;
}
.editor-head input#script-title:hover {
    border-color: var(--border);
}
.editor-head input#script-title:focus {
    border-color: var(--accent);
    background: var(--bg-2);
}
.editor-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}
.save-status {
    color: var(--text-dim);
    font-size: 13px;
    min-width: 90px;
    text-align: right;
}
.save-status.saving { color: var(--accent); }
.save-status.saved  { color: var(--ok); }
.save-status.error  { color: var(--err); }

textarea#script-content {
    flex: 1;
    border: none;
    border-radius: 0;
    background: var(--bg);
    color: var(--text);
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 15px;
    line-height: 1.7;
    padding: 20px;
    resize: none;
    outline: none;
}

.editor-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--bg-2);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    font-size: 13px;
    color: var(--text-dim);
}
.foot-actions { display: flex; gap: 8px; }

/* ---------- Placeholder ---------- */
.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    font-size: 15px;
    background: var(--bg);
    text-align: center;
    padding: 40px;
}
.placeholder p {
    max-width: 400px;
}

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
    .dashboard {
        grid-template-columns: 1fr;
    }
    .sidebar {
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .editor-head input#script-title {
        font-size: 16px;
    }
}