/* =========================================================================
   Promptify - Modern Dashboard Styles
   Author: Muhammad Ali (Developer)
   ========================================================================= */

:root {
    --brand: #6c5ce7;
    --brand-2: #a29bfe;
    --brand-grad: linear-gradient(135deg, #6c5ce7 0%, #8e7bff 100%);
    --bg: #f4f5fb;
    --surface: #ffffff;
    --surface-2: #f8f9ff;
    --text: #1e2235;
    --text-soft: #6b7086;
    --border: #e7e8f2;
    --shadow: 0 10px 30px rgba(45, 44, 90, 0.08);
    --shadow-sm: 0 4px 14px rgba(45, 44, 90, 0.06);
    --radius: 16px;
    --radius-sm: 10px;
    --sidebar-w: 264px;
    --success: #00b894;
    --danger: #e74c3c;
    --warn: #fdcb6e;
    --font: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="dark"] {
    --bg: #12131a;
    --surface: #1c1e29;
    --surface-2: #232634;
    --text: #eef0f8;
    --text-soft: #9aa0b8;
    --border: #2c2f3f;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ------------------------------------------------------------- APP SHELL */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    transition: transform .25s ease;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 20px;
    border-bottom: 1px solid var(--border);
}
.brand-logo {
    width: 42px; height: 42px;
    display: grid; place-items: center;
    background: var(--brand-grad);
    color: #fff; font-size: 22px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
}
.brand-name { display: block; font-weight: 700; font-size: 18px; }
.brand-sub { display: block; font-size: 11px; color: var(--text-soft); }

.nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 14px; border-radius: var(--radius-sm);
    color: var(--text-soft); font-weight: 500;
    transition: all .15s ease;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
    background: var(--brand-grad); color: #fff;
    box-shadow: var(--shadow-sm);
}
.nav-icon { font-size: 18px; width: 22px; text-align: center; }

.sidebar-foot { padding: 14px; border-top: 1px solid var(--border); }
.dev-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-size: 12px;
    display: flex; flex-direction: column; gap: 6px;
}
.dev-card strong { font-size: 13px; }
.dev-card a { color: var(--text-soft); }
.dev-card a:hover { color: var(--brand); }

.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.4); z-index: 40;
}

/* ----------------------------------------------------------------- MAIN */
.main {
    flex: 1; margin-left: var(--sidebar-w);
    display: flex; flex-direction: column; min-height: 100vh;
}

.topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: 14px;
    padding: 14px 24px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}
.page-title { font-size: 20px; font-weight: 700; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.icon-btn {
    width: 40px; height: 40px; border: 1px solid var(--border);
    background: var(--surface); border-radius: 11px;
    display: grid; place-items: center; cursor: pointer;
    font-size: 17px; color: var(--text); transition: all .15s;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--brand-2); }
.menu-toggle { display: none; }

.net-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 13px; border-radius: 30px; font-size: 12px; font-weight: 700;
    border: 1px solid var(--border); white-space: nowrap; transition: all .2s;
}
.net-pill.is-online  { color: var(--success); background: color-mix(in srgb, var(--success) 12%, transparent); border-color: color-mix(in srgb, var(--success) 30%, var(--border)); }
.net-pill.is-offline { color: var(--danger);  background: color-mix(in srgb, var(--danger) 12%, transparent);  border-color: color-mix(in srgb, var(--danger) 30%, var(--border)); }
.net-pill.is-sync    { color: #c98a00;         background: color-mix(in srgb, var(--warn) 22%, transparent);    border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); }
.net-count { font-weight: 600; opacity: .9; }

.user-chip {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 12px 5px 5px; border: 1px solid var(--border);
    border-radius: 30px; background: var(--surface);
}
.user-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--brand-grad); color: #fff;
    display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.user-name { font-size: 13px; font-weight: 600; }

.content { padding: 26px 24px; flex: 1; }

/* --------------------------------------------------------------- FOOTER */
.app-footer {
    display: flex; flex-wrap: wrap; gap: 10px;
    align-items: center; justify-content: space-between;
    padding: 16px 24px; border-top: 1px solid var(--border);
    background: var(--surface); font-size: 12px; color: var(--text-soft);
}
.footer-right { display: flex; gap: 16px; }
.footer-right a:hover, .footer-left a:hover { color: var(--brand); }

/* ---------------------------------------------------------------- CARDS */
.stat-grid {
    display: grid; gap: 18px;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    margin-bottom: 26px;
}
.stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px;
    box-shadow: var(--shadow-sm);
    display: flex; align-items: center; gap: 16px;
}
.stat-ico {
    width: 52px; height: 52px; border-radius: 14px;
    display: grid; place-items: center; font-size: 24px;
    background: var(--surface-2);
}
.stat-num { font-size: 26px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 13px; color: var(--text-soft); margin-top: 4px; }

/* --------------------------------------------------------------- TOOLBAR */
.toolbar {
    display: flex; flex-wrap: wrap; gap: 12px;
    align-items: center; margin-bottom: 20px;
}
.search-box { position: relative; flex: 1; min-width: 220px; }
.search-box input {
    width: 100%; padding: 11px 14px 11px 40px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text); font-size: 14px;
}
.search-box::before {
    content: "🔍"; position: absolute; left: 13px; top: 50%;
    transform: translateY(-50%); opacity: .6;
}
.select, select.select {
    padding: 11px 14px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); background: var(--surface);
    color: var(--text); font-size: 14px; cursor: pointer;
}

/* ---------------------------------------------------------------- BUTTONS */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 11px 18px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); background: var(--surface);
    color: var(--text); font-size: 14px; font-weight: 600;
    cursor: pointer; transition: all .15s;
}
.btn:hover { border-color: var(--brand-2); }
.btn-primary {
    background: var(--brand-grad); color: #fff; border: none;
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }

/* ------------------------------------------------------------ PROMPT GRID */
.prompt-grid {
    display: grid; gap: 18px;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}
.prompt-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px;
    box-shadow: var(--shadow-sm); display: flex; flex-direction: column;
    transition: transform .15s, box-shadow .15s;
}
.prompt-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.pc-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.pc-title { font-weight: 700; font-size: 16px; flex: 1; }
.fav-btn { background: none; border: none; cursor: pointer; font-size: 18px; }
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600;
    background: var(--surface-2); color: var(--text-soft);
}
.chip-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.pc-body {
    font-size: 13px; color: var(--text-soft); background: var(--surface-2);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 12px; margin: 10px 0; max-height: 120px; overflow: hidden;
    white-space: pre-wrap; word-break: break-word; position: relative;
}
.pc-meta { display: flex; gap: 14px; font-size: 11px; color: var(--text-soft); margin-bottom: 12px; }
.pc-actions { display: flex; gap: 8px; margin-top: auto; flex-wrap: wrap; }
.pc-actions .btn { flex: 1; }

/* --------------------------------------------------------------- CATEGORIES */
.cat-grid {
    display: grid; gap: 16px;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.cat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm);
    border-left: 5px solid var(--brand);
}
.cat-name { font-weight: 700; font-size: 16px; }
.cat-count { font-size: 12px; color: var(--text-soft); }
.cat-actions { display: flex; gap: 8px; margin-top: 14px; }

.pc-chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ----------------------------------------------------------- CATEGORY TREE */
.tree {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow-sm);
}
.tree-row {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: var(--radius-sm);
    transition: background .15s; flex-wrap: wrap;
}
.tree-row:hover { background: var(--surface-2); }
.tree-branch { opacity: .6; font-size: 14px; width: 18px; text-align: center; }
.tree-dot { width: 12px; height: 12px; border-radius: 4px; flex-shrink: 0; }
.tree-name { font-weight: 600; }
.tree-count { font-size: 12px; color: var(--text-soft); margin-left: auto; }
.tree-actions { display: flex; gap: 6px; }
.tree-actions .btn { padding: 6px 10px; }

/* -------------------------------------------------------------- EMPTY STATE */
.empty {
    text-align: center; padding: 60px 20px; color: var(--text-soft);
}
.empty-ico { font-size: 52px; margin-bottom: 12px; }

/* ---------------------------------------------------------- IMAGE UPLOAD */
.hidden-file { display: none; }
.file-drop {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 6px; padding: 22px; text-align: center; cursor: pointer;
    border: 2px dashed var(--border); border-radius: var(--radius-sm);
    background: var(--surface-2); color: var(--text-soft); transition: all .15s;
}
.file-drop:hover { border-color: var(--brand); color: var(--brand); }
.file-drop i { font-size: 26px; }
.file-drop small { font-weight: 600; color: var(--brand); }

.pc-images {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 8px; margin: 4px 0 12px;
}
.pc-img { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.pc-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pc-img-del {
    position: absolute; top: 4px; right: 4px; width: 22px; height: 22px;
    display: grid; place-items: center; border-radius: 50%;
    background: rgba(0,0,0,.6); color: #fff; font-size: 11px;
}
.pc-img-del:hover { background: var(--danger); }

/* --------------------------------------------------------- ICON PICKER */
.icon-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.icon-choice {
    width: 42px; height: 42px; border: 1px solid var(--border);
    background: var(--surface-2); border-radius: 10px; cursor: pointer;
    display: grid; place-items: center; font-size: 17px; color: var(--text);
    transition: all .15s;
}
.icon-choice:hover { border-color: var(--brand-2); }
.icon-choice.active { background: var(--brand-grad); color: #fff; border: none; }

.company-ico { font-size: 20px; }
.emoji-icon { font-style: normal; }

/* -------------------------------------------------------------- MODAL */
.modal-backdrop {
    display: none; position: fixed; inset: 0; z-index: 100;
    background: rgba(15, 16, 25, .55); backdrop-filter: blur(3px);
    align-items: center; justify-content: center; padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
    background: var(--surface); border-radius: var(--radius);
    width: 100%; max-width: 560px; box-shadow: var(--shadow);
    max-height: 92vh; overflow-y: auto;
    animation: pop .18s ease;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 18px; }
.modal-body { padding: 22px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.form-control {
    width: 100%; padding: 11px 14px; font-size: 14px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface-2); color: var(--text); font-family: var(--font);
}
.form-control:focus { outline: 2px solid var(--brand-2); border-color: var(--brand); }
textarea.form-control { min-height: 140px; resize: vertical; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

/* -------------------------------------------------------------- TOAST */
.toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(120%);
    background: var(--text); color: var(--surface);
    padding: 12px 22px; border-radius: 30px; font-size: 14px; font-weight: 600;
    box-shadow: var(--shadow); z-index: 200; transition: transform .3s ease;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* -------------------------------------------------------------- AUTH PAGE */
.auth-wrap {
    min-height: 100vh; display: grid; place-items: center; padding: 20px;
    background: radial-gradient(circle at 20% 20%, #8e7bff33, transparent 40%),
                radial-gradient(circle at 80% 80%, #6c5ce733, transparent 40%),
                var(--bg);
}
.auth-card {
    width: 100%; max-width: 400px; background: var(--surface);
    border: 1px solid var(--border); border-radius: 22px;
    padding: 34px; box-shadow: var(--shadow);
}
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-brand .brand-logo { margin: 0 auto 12px; width: 56px; height: 56px; font-size: 28px; }
.auth-brand h1 { font-size: 24px; }
.auth-brand p { color: var(--text-soft); font-size: 13px; margin-top: 4px; }
.auth-dev {
    margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border);
    text-align: center; font-size: 12px; color: var(--text-soft); line-height: 1.9;
}
.auth-dev a:hover { color: var(--brand); }
.alert {
    padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13px;
    margin-bottom: 16px;
}
.alert-error { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.alert-success { background: color-mix(in srgb, var(--success) 16%, transparent); color: var(--success); }

/* -------------------------------------------------------------- INSTALLER */
.install-wrap { max-width: 620px; margin: 40px auto; padding: 0 20px; }
.install-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 22px; padding: 34px; box-shadow: var(--shadow);
}
.steps { display: flex; gap: 8px; margin-bottom: 26px; }
.step {
    flex: 1; text-align: center; font-size: 12px; color: var(--text-soft);
    padding-bottom: 10px; border-bottom: 3px solid var(--border);
}
.step.active { color: var(--brand); border-color: var(--brand); font-weight: 700; }
.step.done { color: var(--success); border-color: var(--success); }

/* -------------------------------------------------------------- RESPONSIVE */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar.open ~ .sidebar-overlay { display: block; }
    .main { margin-left: 0; }
    .menu-toggle { display: grid; }
    .user-name { display: none; }
}
@media (max-width: 560px) {
    .content { padding: 18px 14px; }
    .footer-right { width: 100%; }
    .pc-actions .btn { flex: none; }
}

/* PWA install banner */
.install-banner {
    position: fixed; bottom: 20px; right: 20px; z-index: 150;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
    display: none; align-items: center; gap: 12px; max-width: 320px;
}
.install-banner.show { display: flex; }
