/*
 * AppBOX theme: W3Schools dark palette, clean app-style layout.
 */
:root {
    --bg:          #1D2A35;  /* W3Schools dark page */
    --bar:         #282A35;  /* W3Schools top bar */
    --panel:       #38444D;  /* W3Schools dark panel */
    --panel-2:     #2B3843;
    --line:        #3E4C57;
    --text:        #F1F1F1;
    --muted:       #AEB8C0;
    --green:       #04AA6D;  /* W3Schools green */
    --green-dark:  #059862;
    --yellow:      #FFF4A3;  /* W3Schools yellow */
    --red:         #F28B82;

    --topbar-h: 60px;
    --sidebar-w: 240px;
    --radius: 12px;
    --shadow: 0 8px 24px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 "Inter", "Segoe UI", system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

.icon { flex: none; }

/* ---------- Buttons, badges, alerts ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 38px; padding: 0 16px;
    border: 1px solid transparent; border-radius: 8px;
    font: inherit; font-weight: 600; cursor: pointer;
    transition: background .15s, border-color .15s;
}
.btn--primary { background: var(--green); color: #fff; }
.btn--primary:hover { background: var(--green-dark); }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn--ghost:hover { background: var(--panel); }
.btn--block { width: 100%; height: 44px; }

.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px; border-radius: 999px;
    font-size: 11px; font-weight: 600; letter-spacing: .02em; white-space: nowrap;
}
.badge--soon { background: rgba(255, 244, 163, .14); color: var(--yellow); }
.badge--live { background: rgba(4, 170, 109, .18); color: #3DDC97; }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert--error { background: rgba(242, 139, 130, .12); color: var(--red); border: 1px solid rgba(242, 139, 130, .3); }
.alert--info  { background: rgba(4, 170, 109, .12); color: #3DDC97; border: 1px solid rgba(4, 170, 109, .3); }

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.brand__mark {
    display: grid; place-items: center; width: 32px; height: 32px;
    border-radius: 8px; background: var(--green); color: #fff;
}
.brand--center { justify-content: center; width: 100%; margin-bottom: 20px; }

/* ---------- Top bar ---------- */
.topbar {
    position: fixed; inset: 0 0 auto 0; z-index: 30;
    height: var(--topbar-h);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px;
    background: var(--bar);
    border-bottom: 1px solid var(--line);
}
.topbar__left, .topbar__right { display: flex; align-items: center; gap: 16px; }
.topbar__crumb { color: var(--muted); padding-left: 16px; border-left: 1px solid var(--line); }
.topbar__toggle {
    display: none; background: none; border: 0; color: var(--text); cursor: pointer; padding: 6px;
}

.user-chip { display: flex; align-items: center; gap: 10px; }
.user-chip__avatar {
    display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
    background: var(--panel); color: var(--green); font-weight: 700; text-transform: uppercase;
}
.user-chip__text { display: flex; flex-direction: column; line-height: 1.2; }
.user-chip__name { font-weight: 600; font-size: 14px; }
.user-chip__mail { color: var(--muted); font-size: 12px; }

/* ---------- Shell: sidebar + content (full width) ---------- */
.shell { display: flex; min-height: 100vh; padding-top: var(--topbar-h); }

.sidebar {
    position: fixed; top: var(--topbar-h); bottom: 0; left: 0; z-index: 20;
    width: var(--sidebar-w);
    padding: 20px 12px;
    background: var(--bar);
    border-right: 1px solid var(--line);
    overflow-y: auto;
    transition: transform .2s ease;
}
.sidebar__label {
    padding: 0 12px 8px; color: var(--muted);
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em;
}
.sidebar__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.sidebar__link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: 8px;
    color: var(--muted); font-weight: 500;
    transition: background .15s, color .15s;
}
.sidebar__link:hover { background: var(--panel-2); color: var(--text); }
.sidebar__link.is-active { background: var(--green); color: #fff; }
.sidebar__link.is-active .badge--soon { background: rgba(0, 0, 0, .2); color: #fff; }
.sidebar__link .badge { margin-left: auto; }
.sidebar-backdrop { display: none; }

.content {
    flex: 1; min-width: 0;
    margin-left: var(--sidebar-w);
    padding: 32px;
}

/* ---------- Overview ---------- */
.hero {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 24px;
    padding: 28px 32px; margin-bottom: 28px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, #04AA6D 0%, #057a52 55%, #282A35 100%);
    box-shadow: var(--shadow);
}
.hero__title { margin: 0 0 4px; font-size: 26px; font-weight: 700; }
.hero__text { margin: 0; color: rgba(255, 255, 255, .85); }

.card-grid {
    display: grid; gap: 20px;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.card {
    display: flex; flex-direction: column;
    padding: 22px; border-radius: var(--radius);
    background: var(--panel); border: 1px solid var(--line);
    transition: transform .15s, border-color .15s, box-shadow .15s;
}
.card:hover { transform: translateY(-2px); border-color: var(--green); box-shadow: var(--shadow); }
.card__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card__icon {
    display: grid; place-items: center; width: 44px; height: 44px; border-radius: 10px;
    background: rgba(4, 170, 109, .15); color: var(--green);
}
.card__title { margin: 0 0 6px; font-size: 18px; }
.card__text { margin: 0 0 18px; color: var(--muted); flex: 1; }
.card__link { display: inline-flex; align-items: center; gap: 6px; color: var(--green); font-weight: 600; font-size: 14px; }

/* ---------- Coming soon ---------- */
.empty {
    display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px;
    max-width: 520px; margin: 8vh auto 0; padding: 48px 32px;
    border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line);
}
.empty__icon {
    display: grid; place-items: center; width: 80px; height: 80px; border-radius: 20px;
    background: rgba(4, 170, 109, .15); color: var(--green);
}
.empty__title { margin: 4px 0 0; font-size: 26px; }
.empty__text { margin: 0 0 8px; color: var(--muted); }

/* ---------- Login ---------- */
.auth__wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth__card {
    width: 100%; max-width: 400px; padding: 36px 32px;
    border-radius: var(--radius); background: var(--bar); border: 1px solid var(--line);
    box-shadow: var(--shadow);
}
.auth__title { margin: 0; font-size: 22px; text-align: center; }
.auth__sub { margin: 4px 0 24px; color: var(--muted); text-align: center; font-size: 14px; }
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field__label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field__control {
    display: flex; align-items: center; gap: 10px;
    height: 44px; padding: 0 12px; border-radius: 8px;
    background: var(--bg); border: 1px solid var(--line); color: var(--muted);
}
.field__control:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px rgba(4, 170, 109, .25); }
.field__control input {
    flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent;
    color: var(--text); font: inherit;
}

/* ---------- AppStore ---------- */
[hidden] { display: none !important; }

.search {
    display: flex; align-items: center; gap: 10px;
    width: min(320px, 100%); height: 44px; padding: 0 14px; border-radius: 10px;
    background: rgba(29, 42, 53, .55); border: 1px solid rgba(255, 255, 255, .18); color: rgba(255, 255, 255, .8);
}
.search:focus-within { border-color: #fff; }
.search input {
    flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent;
    color: #fff; font: inherit;
}
.search input::placeholder { color: rgba(255, 255, 255, .6); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.chip {
    display: inline-flex; align-items: center; gap: 8px;
    height: 36px; padding: 0 14px; border-radius: 999px;
    background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
    font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}
.chip:hover { color: var(--text); border-color: var(--muted); }
.chip.is-active { background: var(--green); border-color: var(--green); color: #fff; }
.chip__count {
    min-width: 22px; padding: 0 6px; border-radius: 999px;
    background: rgba(0, 0, 0, .2); font-size: 12px; font-weight: 600; text-align: center;
}

.app-logo {
    display: grid; place-items: center; width: 52px; height: 52px; border-radius: 12px;
    background: var(--panel-2); border: 1px solid var(--line); flex: none;
}
.app-logo img { width: 32px; height: 32px; object-fit: contain; }
.app-logo--lg { width: 56px; height: 56px; }
.app-logo--lg img { width: 36px; height: 36px; }
.app-logo__letter { font-size: 22px; font-weight: 700; color: var(--green); }

.badge--cat { background: rgba(255, 255, 255, .06); color: var(--muted); }
.app-card { cursor: default; }
.app-card .card__text { margin-bottom: 14px; }
.app-card__warn {
    display: inline-flex; align-items: center; gap: 6px; margin: -6px 0 12px;
    color: var(--yellow); font-size: 12px; font-weight: 600;
}
.specs { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0 0 18px; padding: 0; }
.specs li {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: 6px;
    background: var(--panel-2); color: var(--text); font-size: 13px;
}
.specs .icon { color: var(--green); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary:disabled:hover { background: var(--green); }
.btn--sm { height: 32px; padding: 0 12px; font-size: 13px; }
.store-empty { margin: 40px 0; color: var(--muted); text-align: center; }

.icon-btn {
    display: grid; place-items: center; width: 36px; height: 36px; flex: none;
    border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--panel); color: var(--text); }
.icon-btn--danger:hover { background: rgba(242, 139, 130, .12); color: var(--red); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }

.alert--warn { background: rgba(255, 244, 163, .1); color: var(--yellow); border: 1px solid rgba(255, 244, 163, .3); }
.alert ul { margin: 0; padding-left: 18px; }

/* Deploy dialog */
body.modal-open { overflow: hidden; }
.modal {
    width: min(760px, calc(100% - 32px)); max-height: calc(100vh - 48px);
    padding: 0; border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--bar); color: var(--text); box-shadow: 0 24px 64px rgba(0, 0, 0, .5);
}
.modal::backdrop { background: rgba(10, 16, 22, .7); backdrop-filter: blur(2px); }
.modal__box { display: flex; flex-direction: column; max-height: calc(100vh - 50px); }
.modal__head {
    display: flex; align-items: center; gap: 14px;
    padding: 18px 20px; border-bottom: 1px solid var(--line);
}
.modal__heading { flex: 1; min-width: 0; }
.modal__title { margin: 0; font-size: 20px; }
.modal__image { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal__body { flex: 1; overflow-y: auto; padding: 20px; display: grid; gap: 18px; align-content: start; }
.modal__body > .alert { margin: 0; }
.modal__foot {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px;
    padding: 14px 20px; border-top: 1px solid var(--line); background: var(--bg);
    border-radius: 0 0 var(--radius) var(--radius);
}
.modal__owner {
    display: inline-flex; align-items: center; gap: 6px; margin-right: auto;
    color: var(--muted); font-size: 13px;
}
.modal__owner .icon { color: var(--green); }

.msec { padding: 16px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }
.msec__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.msec__head .msec__title { margin: 0; }
.msec__title {
    display: flex; align-items: center; gap: 8px; margin: 0 0 12px;
    font-size: 15px; font-weight: 600;
}
.msec__title .icon { color: var(--green); }
.msec__stack { display: grid; gap: 14px; }

.field__prefix { color: var(--muted); font-size: 14px; }
.field__help { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.field__help.is-ok { color: #3DDC97; }
.field__help.is-bad { color: var(--red); }
.field__control.is-ok { border-color: var(--green); }
.field__control.is-bad { border-color: var(--red); }
.field .input { width: 100%; }
.link { display: inline-flex; align-items: center; gap: 4px; color: var(--green); font-weight: 600; }
.link:hover { text-decoration: underline; }

.dns-state { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; flex: none; }
.dns-state--ok { background: var(--green); color: #fff; }
.dns-state--bad { background: rgba(242, 139, 130, .2); color: var(--red); }
.dns-state--checking { border: 2px solid var(--line); border-top-color: var(--green); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.input {
    height: 38px; min-width: 0; padding: 0 10px; border-radius: 8px;
    background: var(--bg); border: 1px solid var(--line); color: var(--text); font: inherit; font-size: 14px;
}
.input:focus { outline: 0; border-color: var(--green); box-shadow: 0 0 0 3px rgba(4, 170, 109, .25); }
.input[readonly] { color: var(--muted); background: transparent; }
.input--mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 13px; }
.input--static { display: flex; align-items: center; color: var(--muted); background: transparent; }
select.input { cursor: pointer; }

.slider + .slider { margin-top: 16px; }
.slider__top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; font-size: 14px; }
.slider__top output { font-weight: 700; color: var(--green); }
.slider__top output.is-low { color: var(--yellow); }
.slider__hint { display: flex; justify-content: space-between; margin-top: 6px; color: var(--muted); font-size: 12px; }
.slider input[type=range] {
    -webkit-appearance: none; appearance: none; width: 100%; height: 6px; margin: 0; border-radius: 999px;
    background: linear-gradient(to right, var(--green) var(--fill, 50%), var(--line) var(--fill, 50%));
    cursor: pointer;
}
.slider input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
    background: #fff; border: 3px solid var(--green);
}
.slider input[type=range]::-moz-range-thumb {
    width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid var(--green);
}
.slider input[type=range]:focus-visible { outline: 2px solid var(--green); outline-offset: 4px; }

.rows { display: grid; gap: 8px; }
.row, .rows-head { display: grid; gap: 8px; align-items: center; }
.row--ports, .rows-head--ports { grid-template-columns: 1fr 1fr 110px 56px; }
.row--volumes, .rows-head--volumes { grid-template-columns: 1.4fr 1fr 64px 56px; }
.row--env { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr) 56px; }
.rows-head { margin-bottom: 6px; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.row > .badge { justify-self: center; }
.row > .icon-btn { justify-self: center; }
.row__check { display: inline-flex; align-items: center; justify-content: center; gap: 6px; color: var(--muted); font-size: 12px; cursor: pointer; }
.row__check input { accent-color: var(--green); width: 16px; height: 16px; }
.row__lock { display: inline-flex; align-items: center; justify-content: center; gap: 4px; color: var(--muted); font-size: 11px; font-weight: 600; }

.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
    padding: 4px 10px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line);
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12px; color: var(--muted);
}
.tag strong { color: var(--green); }

.preview summary {
    display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; font-size: 15px; list-style: none;
}
.preview summary::-webkit-details-marker { display: none; }
.preview summary .icon { color: var(--green); }
.preview[open] summary { margin-bottom: 12px; }
.preview__file { margin: 12px 0 6px; color: var(--muted); font-size: 12px; font-family: ui-monospace, Consolas, monospace; }
.code, .log {
    margin: 0; padding: 12px 14px; border-radius: 8px; overflow: auto;
    background: var(--bg); border: 1px solid var(--line);
    font: 12.5px/1.55 ui-monospace, "Cascadia Code", Consolas, monospace; color: var(--text); white-space: pre;
}
.log { max-height: 320px; white-space: pre-wrap; word-break: break-word; }
.log__step { color: #3DDC97; font-weight: 700; }
.log__err { color: var(--red); font-weight: 700; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .topbar__toggle { display: inline-flex; }
    .topbar__crumb, .user-chip__text, .btn--ghost span { display: none; }
    .sidebar { transform: translateX(-100%); }
    body.sidebar-open .sidebar { transform: none; }
    body.sidebar-open .sidebar-backdrop {
        display: block; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 10;
        background: rgba(0, 0, 0, .5);
    }
    .content { margin-left: 0; padding: 20px 16px; }
    .hero { padding: 22px; }
    .search { width: 100%; }
}

@media (max-width: 640px) {
    .modal { width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; border-radius: 0; }
    .modal__box { max-height: 100%; height: 100%; }
    .modal__foot { border-radius: 0; }
    .modal__body { padding: 14px; }
    .modal__owner { width: 100%; }
    .rows-head { display: none; }
    .row--ports { grid-template-columns: 1fr 1fr 84px 44px; }
    .row--volumes { grid-template-columns: 1fr 44px; }
    .row--volumes > .input { grid-column: 1 / -1; }
    .row--volumes > .row__check { justify-content: flex-start; }
    .row--env { grid-template-columns: 1fr 44px; }
    .row--env > .input:nth-child(2) { grid-column: 1; }
}
