/* Developer portal shell, aligned with the Atlayo apps. */
:root,
[data-theme="dark"] {
    --bg-primary: #eceef1;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f4f5f7;
    --text-primary: #1f2023;
    --text-secondary: #5d6168;
    --text-tertiary: #9a9ea6;
    --border-color: #e7e9ed;
    --card-bg: #ffffff;
    --brand-color: #1f2023;
    --error-color: #e5484d;
    --accent: #ffdb4d;
    --accent-hover: #ffd21f;
    --accent-soft: #fff2bf;
    --hover: #f0f1f4;
    --selected: #eef0f3;
    --ink: #1f2023;
    --ink-2: #5d6168;
    --ink-3: #9a9ea6;
    --surface: #ffffff;
    --surface-2: #f4f5f7;
    --line: #e7e9ed;
    --shadow: 0 12px 40px rgba(20, 24, 31, .16);
}

html, body.portal-shell { height: 100%; }
body.portal-shell {
    margin: 0;
    background: var(--bg-primary);
    color: var(--ink);
    font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}
body.portal-shell .portal-app {
    display: flex;
    height: 100vh;
    height: 100dvh;
    padding: 8px 8px 8px 0;
}
body.portal-shell .rail {
    width: 60px;
    flex: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 0 4px;
}
body.portal-shell .rail-logo {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    margin-bottom: 14px;
}
body.portal-shell .rail-logo img { width: 26px; height: 28px; }
body.portal-shell .rail-services {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
    overflow: auto;
}
body.portal-shell .rail-item {
    position: relative;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    color: #4a4e55;
    text-decoration: none;
}
body.portal-shell .rail-item svg { width: 28px; height: 28px; }
body.portal-shell .rail-item:hover { background: rgba(0, 0, 0, .06); color: var(--ink); }
body.portal-shell .rail-item.active {
    background: var(--surface);
    color: #ff0000;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
}
body.portal-shell .rail-item .tip {
    position: absolute;
    left: 48px;
    top: 50%;
    transform: translateY(-50%);
    white-space: nowrap;
    background: #2a2c31;
    color: #fff;
    font-size: 12px;
    padding: 4px 9px;
    border-radius: 6px;
    opacity: 0;
    pointer-events: none;
    z-index: 30;
}
body.portal-shell .rail-item:hover .tip { opacity: 1; }
body.portal-shell .rail-bottom {
    margin-top: auto;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}
body.portal-shell .rail-avatar {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    padding: 0;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: var(--accent-soft);
    font-size: 13px;
    font-weight: 600;
    color: #5a4700;
}
body.portal-shell .rail-avatar img,
body.portal-shell .user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
body.portal-shell .user-menu {
    position: absolute;
    left: 46px;
    bottom: 0;
    width: 230px;
    background: var(--surface);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 12px;
    z-index: 40;
    text-align: left;
}
body.portal-shell .user-menu-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
body.portal-shell .user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: var(--accent-soft);
    font-size: 16px;
    font-weight: 600;
    color: #5a4700;
    flex: none;
}
body.portal-shell .user-menu-name { font-weight: 600; }
body.portal-shell .user-menu-sub { margin: 0; color: var(--ink-2); font-size: 12.5px; }
body.portal-shell .user-menu .logout-btn,
body.portal-shell .user-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin: 0;
    padding: 8px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--ink);
    text-align: left;
    text-decoration: none;
    font-size: 14px;
    box-shadow: none;
    transform: none;
}
body.portal-shell .user-menu .logout-btn:hover,
body.portal-shell .user-menu-item:hover { background: var(--hover); }
body.portal-shell .user-menu svg { width: 18px; height: 18px; color: var(--ink-2); }

body.portal-shell .workspace {
    flex: 1;
    min-width: 0;
    display: flex;
    background: var(--surface);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}
body.portal-shell .page-layout,
body.portal-shell .main-layout {
    display: flex;
    flex: 1;
    min-width: 0;
    min-height: 0;
    width: 100%;
    height: auto;
}
body.portal-shell:not(.portal-editor) .sidebar {
    width: 300px;
    flex: none;
    display: flex;
    flex-direction: column;
    gap: 0;
    background: #fff;
    border-right: 1px solid var(--line);
    padding: 16px 12px 8px;
    overflow: auto;
}
body.portal-shell .sidebar-head {
    padding: 0 4px 12px;
    margin-bottom: 12px;
    border-bottom: 2px solid #ff0000;
}
body.portal-shell .sidebar-head h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 650;
    display: flex;
    align-items: center;
    gap: 8px;
}
body.portal-shell .sidebar-head i,
body.portal-shell .sidebar-title { display: none; }
body.portal-shell.portal-dev .sidebar-head h2::after {
    content: "DEV";
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    background: var(--accent);
    color: #1b1b1b;
    border-radius: 999px;
    padding: 2px 8px;
}
body.portal-shell:not(.portal-editor) .sidebar-nav { gap: 2px; }
body.portal-shell .sidebar-link {
    border: 0;
    border-radius: 10px;
    padding: 9px 10px;
    color: var(--ink);
    font-weight: 500;
}
body.portal-shell .sidebar-link i { color: var(--ink-2); width: 18px; text-align: center; }
body.portal-shell .sidebar-link:hover { background: var(--hover); color: var(--ink); }
body.portal-shell .sidebar-link.active {
    background: var(--selected);
    color: var(--ink);
    border-color: transparent;
    font-weight: 600;
}
body.portal-shell .sidebar-link.active i { color: var(--ink); }
body.portal-shell .nav-badge {
    margin-left: auto;
    background: var(--error-color);
    color: #fff;
    border-radius: 999px;
    font-size: 11px;
    padding: 1px 7px;
}
body.portal-shell .create-btn {
    width: 100%;
    height: 38px;
    margin: 0 0 12px;
    padding: 0 14px;
    border: 0;
    border-radius: 10px;
    background: var(--accent);
    color: #1b1b1b;
    font-weight: 600;
    box-shadow: none;
    justify-content: center;
}
body.portal-shell .create-btn:hover,
body.portal-shell .create-btn:active {
    background: var(--accent-hover);
    transform: none;
    box-shadow: none;
}
body.portal-shell .dev-controls {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 12px 4px 4px;
    border-top: 1px solid var(--line);
}
body.portal-shell .dev-status {
    font-size: 12.5px;
    color: var(--ink-2);
}
body.portal-shell .theme-toggle,
body.portal-shell .portal-header-hidden { display: none !important; }
body.portal-shell .form-check-input:checked {
    background-color: var(--accent);
    border-color: #e0b400;
}
body.portal-shell .form-check-input:focus {
    border-color: #e0b400;
    box-shadow: 0 0 0 3px rgba(255, 219, 77, .45);
}

body.portal-shell .main-content {
    flex: 1;
    min-width: 0;
    max-width: none;
    overflow: auto;
    padding: 16px 20px 0;
    background: #fff;
}
body.portal-shell .portal-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 18px;
    padding: 10px 4px 12px;
    font-size: 12px;
    color: var(--ink-3);
}
body.portal-shell .portal-foot a {
    color: var(--ink-3);
    text-decoration: none;
    background: none !important;
    border: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
}
body.portal-shell .portal-foot a:hover { color: var(--ink); }
body.portal-shell .portal-foot-right { display: flex; align-items: center; gap: 12px; }
body.portal-shell .lang-btn {
    border: 0;
    background: none;
    color: var(--ink-3);
    font-size: 12px;
    padding: 2px 4px;
    border-radius: 4px;
    text-transform: uppercase;
}
body.portal-shell .lang-btn:hover,
body.portal-shell .lang-btn[aria-expanded="true"] { color: var(--ink); background: var(--hover); }
body.portal-shell .lang-menu {
    position: fixed;
    z-index: 90;
    width: 210px;
    max-height: min(360px, calc(100vh - 24px));
    overflow: auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 6px;
}
body.portal-shell .lang-option {
    display: flex;
    width: 100%;
    text-align: left;
    border: 0;
    background: none;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 14px;
    color: var(--ink);
}
body.portal-shell .lang-option:hover { background: var(--hover); }
body.portal-shell .lang-option.active { background: var(--accent-soft); font-weight: 600; }
body.portal-shell .hidden { display: none !important; }

body.portal-shell .app-card,
body.portal-shell .intro-card,
body.portal-shell .notification-card,
body.portal-shell .card {
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: none;
    background: #fff;
}
body.portal-shell .app-card { margin-bottom: 10px; overflow: hidden; }
body.portal-shell .app-card:hover { transform: none; box-shadow: none; background: #fafbfc; }
body.portal-shell .app-card-header,
body.portal-shell .app-body { background: transparent; }
body.portal-shell .app-card-header { border-bottom-color: var(--line); }
body.portal-shell .app-name { color: var(--ink); font-size: 16px; }
body.portal-shell .app-id,
body.portal-shell .app-description,
body.portal-shell .app-meta { color: var(--ink-2); }
body.portal-shell .app-icon {
    background: var(--surface-2);
    border: 1px solid var(--line);
    box-shadow: none;
}
body.portal-shell .app-category-badge {
    background: var(--accent-soft);
    color: #5a4700;
}
body.portal-shell .app-card-header { align-items: flex-start; gap: 8px; }
body.portal-shell .app-actions { flex-wrap: wrap; justify-content: flex-end; }
body.portal-shell .app-actions button { box-shadow: none !important; transform: none !important; }
body.portal-shell .app-actions .edit-btn,
body.portal-shell .btn-primary,
body.portal-shell .btn-success {
    background: var(--accent) !important;
    border-color: transparent !important;
    color: #1b1b1b !important;
    box-shadow: none !important;
}
body.portal-shell .app-actions .edit-btn:hover,
body.portal-shell .btn-primary:hover,
body.portal-shell .btn-success:hover {
    background: var(--accent-hover) !important;
    transform: none;
    box-shadow: none !important;
}
body.portal-shell .app-actions .publish-btn,
body.portal-shell .app-actions .unpublish-btn {
    background: var(--surface-2) !important;
    color: var(--ink) !important;
    border-color: transparent !important;
}
body.portal-shell .app-actions .publish-btn:hover:not(:disabled),
body.portal-shell .app-actions .unpublish-btn:hover {
    background: var(--hover) !important;
    transform: none;
    box-shadow: none !important;
}
body.portal-shell .app-actions .delete-btn {
    background: #fff !important;
    color: var(--error-color) !important;
    border: 1px solid #f3c7c8 !important;
}
body.portal-shell .app-actions .delete-btn:hover {
    background: #fff5f5 !important;
    transform: none;
    box-shadow: none !important;
}
body.portal-shell .btn {
    border-radius: 10px;
    font-weight: 500;
}
body.portal-shell .btn-outline-secondary {
    background: var(--surface-2);
    border-color: transparent;
    color: var(--ink);
}
body.portal-shell .btn-outline-secondary:hover { background: var(--hover); color: var(--ink); }
body.portal-shell .form-control,
body.portal-shell .form-select,
body.portal-shell .apps-search-input,
body.portal-shell .apps-filter-select {
    border-color: var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
}
body.portal-shell .apps-toolbar { align-items: center; }
body.portal-shell .apps-filter-row { flex: 1 1 auto; }
body.portal-shell .apps-filter-wrap { flex: 1 1 220px; min-width: 220px; }
body.portal-shell .apps-search-input { height: 36px; background: var(--surface-2); }
body.portal-shell .apps-filter-select {
    height: 36px;
    padding: 0 34px 0 12px;
    line-height: 36px;
    background: var(--surface-2);
    text-overflow: ellipsis;
}
body.portal-shell .form-control:focus,
body.portal-shell .form-select:focus,
body.portal-shell .apps-search-input:focus,
body.portal-shell .apps-filter-select:focus {
    border-color: #c9ccd2;
    box-shadow: 0 0 0 3px rgba(255, 219, 77, .45);
}
body.portal-shell .modal-content { border: 0; border-radius: 16px; box-shadow: var(--shadow); }
body.portal-shell .modal-header,
body.portal-shell .modal-footer { border-color: var(--line); }
body.portal-shell .wizard-step.active .step-number,
body.portal-shell .wizard-step.active .step-label { color: #1b1b1b; }
body.portal-shell .wizard-step.active .step-number {
    background: var(--accent);
    border-color: var(--accent);
}

body.portal-shell.portal-editor .workspace { flex-direction: column; }
body.portal-shell.portal-editor .header {
    display: flex;
    position: static;
    background: #fff;
    box-shadow: none;
    border-bottom: 1px solid var(--line);
    border-radius: 16px 16px 0 0;
}
body.portal-shell.portal-editor .back-btn {
    display: inline-flex;
    align-items: center;
    height: 36px;
    padding: 0 14px;
    border: 0;
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--ink);
    text-decoration: none;
    box-shadow: none;
}
body.portal-shell.portal-editor .back-btn:hover { background: var(--hover); transform: none; }
body.portal-shell.portal-editor .main-layout { flex: 1; min-height: 0; }
body.portal-shell.portal-editor .sidebar { background: #fff; }

@media (max-width: 800px) {
    body.portal-shell { overflow: auto; }
    body.portal-shell .portal-app { height: auto; min-height: 100dvh; }
    body.portal-shell:not(.portal-editor) .page-layout { flex-direction: column; }
    body.portal-shell:not(.portal-editor) .sidebar { width: 100%; border-right: 0; border-bottom: 1px solid var(--line); }
    body.portal-shell .main-content { overflow: visible; }
}
