/* Novo layout — mobile first, estilo iOS Settings */
:root {
    --bg: #F2F2F7;
    --card: #FFFFFF;
    --text: #1C1C1E;
    --text-secondary: #8E8E93;
    --label: #6C6C70;
    --separator: rgba(60, 60, 67, 0.18);
    --orange: #FF6B00;
    --orange-soft: #FFF0E6;
    --pink: #ff0080;
    --pink-soft: #ffe0f0;
    --green: #34C759;
    --radius: 12px;
    --tab-h: 56px;
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-t: env(safe-area-inset-top, 0px);
    --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    height: 100dvh;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.35;
    overflow: hidden;
    padding: 0;
    margin: 0;
}

button, input, a {
    font: inherit;
    color: inherit;
}

/* ===== Shell ===== */
.app-shell {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    height: 100%;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    background: var(--bg);
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.04);
}

.login-shell {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-page {
    display: none;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    background: var(--bg);
}

.tab-page.active {
    display: flex;
}

.page-scroll {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 16px 20px;
}

.login-main {
    padding: 8px 16px calc(24px + var(--safe-b));
}

/* ===== Headers ===== */
.page-header {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    min-height: 48px;
    padding: calc(8px + var(--safe-t)) 12px 8px;
    background: #fff;
    border-bottom: 0.5px solid var(--separator);
}

.page-header.with-actions .page-title,
.page-header .page-title {
    grid-column: 2;
    text-align: center;
}

.page-title {
    font-size: 17px;
    font-weight: 650;
    letter-spacing: -0.2px;
}

.page-title.compact {
    font-size: 16px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.2px;
}

.header-actions {
    grid-column: 3;
    justify-self: end;
    display: flex;
    gap: 4px;
    align-items: center;
}

.header-actions.empty {
    min-width: 44px;
}

.icon-btn.left {
    grid-column: 1;
    justify-self: start;
}

.top-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: calc(10px + var(--safe-t)) 14px 4px;
    background: #fff;
}

.top-actions-right {
    display: flex;
    gap: 2px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border: 0;
    background: transparent;
    color: var(--orange);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    cursor: pointer;
    text-decoration: none;
}

.icon-btn svg {
    display: block;
}

.theme-pink .icon-btn {
    color: var(--pink);
}

.nav-header {
    background: #fff;
}

.nav-back,
.nav-edit {
    border: 0;
    background: transparent;
    color: var(--orange);
    font-size: 17px;
    font-weight: 400;
    cursor: pointer;
    padding: 8px 4px;
}

.nav-back {
    grid-column: 1;
    justify-self: start;
}

.nav-edit {
    grid-column: 3;
    justify-self: end;
}

.login-header-bar {
    background: #fff;
}

/* ===== Sections / Cards ===== */
.section-block {
    margin-top: 18px;
}

.section-label {
    font-size: 13px;
    font-weight: 400;
    color: var(--label);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0 4px 8px;
}

.section-label.with-icon {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ios-card {
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 0.5px 0 rgba(0,0,0,0.04);
}

.list-card .list-row + .list-row,
.action-card .list-row + .list-row {
    border-top: 0.5px solid var(--separator);
}

.list-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    background: transparent;
    border: 0;
    text-align: left;
    min-height: 48px;
}

.list-row.link-row {
    cursor: pointer;
    text-decoration: none;
}

.list-row.link-row:active {
    background: rgba(0,0,0,0.04);
}

.row-text {
    font-size: 16px;
    color: var(--text);
}

.row-text.grow {
    flex: 1;
}

.row-stack {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.row-stack.wide {
    gap: 4px;
}

.row-stack strong {
    font-size: 16px;
    font-weight: 650;
}

.row-stack small,
.path-line {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 15px !important;
}

.chevron {
    color: #C7C7CC;
    font-size: 22px;
    line-height: 1;
    font-weight: 300;
}

.status-ok {
    color: var(--green);
    font-size: 16px;
    font-weight: 500;
}

.row-icon {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.orange-icon { color: var(--orange); }
.pink-icon { color: var(--pink); }
.folder-icon { color: var(--orange); }

.footnote {
    margin: 8px 4px 0;
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-secondary);
}

/* ===== Toggle ===== */
.toggle {
    position: relative;
    width: 51px;
    height: 31px;
    flex-shrink: 0;
    cursor: pointer;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-track {
    position: absolute;
    inset: 0;
    background: #E9E9EB;
    border-radius: 999px;
    transition: background .2s;
}

.toggle-track::after {
    content: "";
    position: absolute;
    width: 27px;
    height: 27px;
    left: 2px;
    top: 2px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
    transition: transform .2s;
}

.toggle input:checked + .toggle-track {
    background: var(--orange);
}

.toggle input:checked + .toggle-track::after {
    transform: translateX(20px);
}

.feature-toggle {
    pointer-events: auto;
}

.tab-item.is-hidden {
    display: none !important;
}

/* ===== Search ===== */
.search-wrap {
    padding: 8px 0 4px;
}

.search-field {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #E5E5EA;
    border-radius: 10px;
    padding: 9px 12px;
    color: var(--text-secondary);
}

.search-field input {
    border: 0;
    outline: 0;
    background: transparent;
    width: 100%;
    font-size: 16px;
    color: var(--text);
}

.search-field input::placeholder {
    color: #8E8E93;
}

/* ===== Patches extras ===== */
.rule-hash {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--orange);
    font-size: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    max-width: 100%;
    overflow: hidden;
}

.rule-hash span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.patch-rule-row {
    align-items: flex-start;
}

.patch-rule-row .chevron {
    margin-top: 2px;
}

.accent-text {
    color: var(--orange) !important;
    font-weight: 500;
}

.restore-text {
    color: #FF3B30 !important;
    font-weight: 500;
}

.restore-icon {
    color: #FF3B30;
}

.action-row {
    cursor: pointer;
}

.action-row:active {
    background: rgba(255, 107, 0, 0.06);
}

.action-row.is-hidden {
    display: none !important;
}

/* ===== Alert modal (white) ===== */
.app-alert-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
}

.app-alert-overlay[hidden] {
    display: none !important;
}

.app-alert {
    width: min(300px, 100%);
    background: #fff;
    border-radius: 16px;
    padding: 22px 18px 16px;
    text-align: center;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22);
    animation: appAlertIn .2s ease;
}

@keyframes appAlertIn {
    from { opacity: 0; transform: scale(0.94); }
    to { opacity: 1; transform: scale(1); }
}

.app-alert-title {
    margin: 0 0 8px;
    font-size: 17px;
    font-weight: 700;
    color: #1C1C1E;
    letter-spacing: -0.2px;
}

.app-alert-msg {
    margin: 0 0 18px;
    font-size: 14px;
    line-height: 1.4;
    color: #8E8E93;
}

.app-alert-btn {
    width: 100%;
    border: 0;
    border-radius: 12px;
    padding: 13px 16px;
    font-size: 16px;
    font-weight: 650;
    background: #F2F2F7;
    color: var(--orange);
    cursor: pointer;
}

.app-alert-btn.danger {
    color: #FF3B30;
}

.app-alert-btn:active {
    filter: brightness(0.96);
}

/* ===== Cleaner ===== */
.cleaner-card {
    padding: 14px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 2px;
    font-size: 15px;
}

.muted {
    color: var(--text-secondary);
}

.btn-clean {
    margin-top: 12px;
    width: 100%;
    border: 0;
    border-radius: 12px;
    padding: 14px 16px;
    background: #E5E5EA;
    color: #8E8E93;
    font-size: 16px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: not-allowed;
}

/* ===== Wallpapers ===== */
.poster-card {
    padding: 14px 14px 12px;
}

.poster-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.poster-ready {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--green);
    font-size: 16px;
    font-weight: 500;
}

.code-tag {
    font-size: 13px;
}

.poster-divider {
    height: 0.5px;
    background: var(--separator);
    margin: 12px 0;
}

.poster-meta {
    font-size: 13px;
    color: var(--text-secondary);
}

.empty-packages {
    padding: 28px 20px 22px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.empty-packages strong {
    font-size: 17px;
    margin-top: 4px;
}

.empty-packages p {
    font-size: 14px;
    color: var(--text-secondary);
}

.btn-soft {
    margin-top: 10px;
    border: 0;
    border-radius: 10px;
    padding: 10px 18px;
    background: var(--orange-soft);
    color: var(--orange);
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
}

.btn-soft:active {
    filter: brightness(0.96);
}

/* ===== Tab bar (fix no fluxo — evita sumir atrás do Safari) ===== */
.tab-bar {
    position: relative;
    flex: 0 0 auto;
    width: 100%;
    min-height: var(--tab-h);
    padding-bottom: max(8px, var(--safe-b));
    padding-top: 6px;
    display: grid !important;
    grid-template-columns: repeat(5, 1fr);
    background: #ffffff;
    border-top: 0.5px solid var(--separator);
    z-index: 100;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
}

.tab-item {
    border: 0;
    background: transparent;
    color: #8E8E93;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    min-height: 48px;
    padding: 4px 2px;
}

.tab-item.active {
    color: var(--orange);
}

.tab-item svg,
.tab-svg {
    display: block;
    flex-shrink: 0;
    width: 26px;
    height: 26px;
}

/* ===== Login (rosa) ===== */
.theme-pink {
    --accent: var(--pink);
}

.login-brand-row {
    display: flex;
    gap: 14px;
    align-items: center;
    padding: 16px 14px;
}

.login-brand-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--pink-soft);
    color: var(--pink);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-brand-title {
    font-size: 17px;
    display: block;
}

.login-brand-sub {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.form-card .form-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 14px;
}

.form-row-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.form-row input {
    border: 0;
    outline: 0;
    background: transparent;
    font-size: 17px;
    color: var(--text);
    width: 100%;
    padding: 4px 0;
}

.btn-accent {
    margin-top: 14px;
    width: 100%;
    border: 0;
    border-radius: 12px;
    padding: 15px 16px;
    font-size: 17px;
    font-weight: 650;
    color: #fff;
    cursor: pointer;
}

.btn-accent.pink {
    background: var(--pink);
    box-shadow: 0 0 18px rgba(255, 0, 128, 0.35);
}

.btn-accent.pink:active {
    background: #d1006a;
}

.btn-accent:disabled {
    opacity: 0.65;
    cursor: wait;
}

.ios-alert {
    margin: 12px 0 0;
    padding: 12px 14px;
    border-radius: var(--radius);
    font-size: 14px;
    background: #fff;
}

.ios-alert.error {
    color: #FF3B30;
    border: 0.5px solid rgba(255, 59, 48, 0.25);
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--tab-h) + var(--safe-b) + 28px);
    transform: translateX(-50%);
    background: rgba(28,28,30,0.92);
    color: #fff;
    padding: 10px 16px;
    border-radius: 999px;
    font-size: 13px;
    z-index: 200;
    max-width: calc(100% - 40px);
    text-align: center;
}

.toast[hidden] {
    display: none;
}

/* ===== Responsive ===== */
@media (min-width: 481px) {
    body.app-page,
    body.login-page {
        background: #D8D8DE;
    }

    .app-shell {
        border-radius: 18px;
        margin-top: 12px;
        margin-bottom: 12px;
        height: calc(100dvh - 24px);
        overflow: hidden;
    }
}

@media (max-width: 360px) {
    .page-title { font-size: 15px; }
    .tab-item { font-size: 9px; }
    .row-text, .list-row { font-size: 15px; }
}
