/* ============================================================
   Ultra - tema visual estilo iOS (iOS 17 dark mode): cores de
   sistema (systemBlue/systemGreen/systemRed), superfícies "grouped"
   (systemGray6), barras translúcidas com blur, cantos bem
   arredondados, tab bar fixa embaixo (como todo app nativo).
   ============================================================ */
:root {
    --bg: #000000;              /* systemBackground (dark) */
    --bg-elevado: #1c1c1e;      /* secondarySystemBackground (dark) */
    --surface: #1c1c1e;         /* systemGray6 dark - cartões/linhas */
    --surface-2: #2c2c2e;       /* systemGray5 dark - hover/pressed */
    --surface-3: #3a3a3c;       /* systemGray4 dark */
    --separador: rgba(84, 84, 88, .48);
    --text: #ffffff;
    --muted: rgba(235, 235, 245, .6);   /* secondaryLabel dark */
    --muted-2: rgba(235, 235, 245, .3); /* tertiaryLabel dark */
    --tint: #0a84ff;            /* systemBlue dark */
    --tint-2: #64d2ff;          /* systemTeal dark, usado em detalhe */
    --brand: #bf5af2;           /* systemPurple dark - marca/ícone do app */
    --brand-2: #0a84ff;
    --danger: #ff453a;          /* systemRed dark */
    --danger-bg: rgba(255, 69, 58, .16);
    --ok: #32d74b;              /* systemGreen dark */
    --ok-bg: rgba(50, 215, 75, .16);
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 26px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, .4);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, .55);
    --ease: cubic-bezier(.25, .1, .25, 1);
    --font: -apple-system, "SF Pro Text", "SF Pro Display", "Segoe UI Variable", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { color-scheme: dark; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: none;
}
::selection { background: rgba(10, 132, 255, .35); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; }

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

button {
    font-family: inherit; font-size: .95rem; font-weight: 600; cursor: pointer;
    background: var(--surface-2); color: var(--text); border: none;
    border-radius: var(--radius-md); padding: 10px 16px;
    transition: background-color .15s var(--ease), opacity .15s var(--ease), transform .08s var(--ease);
    display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
}
button svg { flex: none; }
button:active { transform: scale(.96); opacity: .85; }
button.primario { background: var(--tint); color: #fff; }
button.primario:active { background: #0972d9; }
button.perigo { color: var(--danger); background: transparent; }
button.perigo:active { background: var(--danger-bg); }
button:disabled { opacity: .35; cursor: not-allowed; transform: none; }
button.icone-only { padding: 9px; background: transparent; color: var(--tint); }
button.icone-only:active { background: var(--surface-2); }

input, textarea {
    font-family: inherit; font-size: 1rem; background: var(--surface-2); color: var(--text);
    border: none; border-radius: var(--radius-sm); padding: 11px 13px; width: 100%;
    transition: box-shadow .15s var(--ease);
}
input:focus, textarea:focus { outline: none; box-shadow: 0 0 0 2px var(--tint); }
input::placeholder, textarea::placeholder { color: var(--muted-2); }

/* ============================================================
   LOGIN - tela cheia estilo "app lock" da iOS
   ============================================================ */
.login-body {
    display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px;
    background: var(--bg);
}
.login-card {
    position: relative; width: 100%; max-width: 340px; text-align: center;
    animation: loginIn .45s var(--ease) both;
}
@keyframes loginIn { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
.login-logo {
    width: 72px; height: 72px; margin: 0 auto 20px; border-radius: 20px;
    background: linear-gradient(160deg, var(--brand), var(--tint));
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-md);
}
.login-logo svg { width: 32px; height: 32px; color: #fff; }
.login-card h1 { font-size: 1.4rem; margin: 0 0 28px; font-weight: 700; letter-spacing: -.02em; }
.login-grupo {
    background: var(--surface); border-radius: var(--radius-md); overflow: hidden; text-align: left;
}
.login-card label {
    display: block; padding: 10px 14px; border-bottom: .5px solid var(--separador);
    font-size: .72rem; font-weight: 500; color: var(--muted); letter-spacing: .01em;
}
.login-grupo label:last-child { border-bottom: none; }
.login-card label input {
    margin-top: 3px; background: transparent; padding: 2px 0; border-radius: 0; font-size: 1rem;
}
.login-card label input:focus { box-shadow: none; }
.login-card button {
    width: 100%; margin-top: 22px; padding: 13px; justify-content: center; font-size: 1rem;
    border-radius: var(--radius-md);
}
.login-erro {
    display: flex; align-items: center; gap: 8px; text-align: left;
    background: var(--danger-bg); color: var(--danger);
    border-radius: var(--radius-sm); padding: 11px 13px; font-size: .85rem; margin-bottom: 18px;
}

/* ============================================================
   APP SHELL - navbar translúcida em cima, tab bar translúcida embaixo
   ============================================================ */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; border-bottom: .5px solid var(--separador);
    background: rgba(28, 28, 30, .78); backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%);
    position: sticky; top: 0; z-index: 30;
}
.topbar .marca { font-weight: 700; font-size: 1.05rem; letter-spacing: -.01em; display: flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.topbar .marca .marca-ic {
    width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(160deg, var(--brand), var(--tint));
}
.topbar .marca .marca-ic svg { width: 14px; height: 14px; color: #fff; }
.topbar .conta { display: flex; align-items: center; gap: 4px; font-size: .82rem; color: var(--muted); }
.topbar .conta > span { margin-right: 6px; }
.topbar .conta a { color: var(--tint); text-decoration: none; display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 10px; font-weight: 600; }
.topbar .conta a:active { background: var(--surface-2); }
.topbar .conta button.icone-only { padding: 8px; border-radius: 10px; }

/* Tab bar fixa embaixo, como todo app iOS - ícone em cima, rótulo embaixo */
.abas {
    display: flex; gap: 0; padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
    border-top: .5px solid var(--separador); border-bottom: none;
    background: rgba(28, 28, 30, .85); backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    overflow-x: auto;
}
.abas button {
    flex: 1 0 56px; min-width: 56px; flex-direction: column; gap: 3px;
    background: transparent; color: var(--muted); border-radius: 0;
    padding: 6px 4px; font-size: .64rem; font-weight: 500; letter-spacing: 0;
}
.abas button svg { width: 24px; height: 24px; }
.abas button:active { opacity: .6; }
.abas button.ativa { color: var(--tint); }

.conteudo { padding: 20px 16px calc(96px + env(safe-area-inset-bottom, 0px)); max-width: 1180px; margin: 0 auto; }
.painel { display: none; }
.painel.ativo { display: block; animation: painelIn .3s var(--ease) both; }
@keyframes painelIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Início ---------- */
.inicio-saudacao { font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; margin: 8px 0 4px; }
.inicio-sub { color: var(--muted); font-size: .95rem; margin: 0 0 24px; }
.inicio-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; max-width: 700px; }
.inicio-card {
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    padding: 26px 16px 20px; border-radius: var(--radius-lg); font-size: .95rem; font-weight: 600;
    background: var(--surface); position: relative; overflow: hidden;
}
.inicio-card:active { background: var(--surface-2); }
.inicio-card .ic {
    width: 54px; height: 54px; border-radius: 15px; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(160deg, var(--tint-grad-a, var(--tint)), var(--tint-grad-b, var(--brand)));
}
.inicio-card[data-aba="fotos"] .ic { --tint-grad-a: #ff9f0a; --tint-grad-b: #ff375f; }
.inicio-card[data-aba="videos"] .ic { --tint-grad-a: #bf5af2; --tint-grad-b: #ff375f; }
.inicio-card[data-aba="outros"] .ic { --tint-grad-a: #64d2ff; --tint-grad-b: #0a84ff; }
.inicio-card[data-aba="senhas"] .ic { --tint-grad-a: #ffd60a; --tint-grad-b: #ff9f0a; }
.inicio-card .ic svg { width: 25px; height: 25px; color: #fff; }
.inicio-card .contagem { font-size: .76rem; font-weight: 500; color: var(--muted); }

.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; font-size: .88rem; color: var(--muted); margin-bottom: 14px; }
.breadcrumb button { padding: 5px 10px; font-size: .85rem; background: transparent; color: var(--tint); font-weight: 500; }
.breadcrumb button:active { background: var(--surface-2); }
.breadcrumb .sep { color: var(--muted-2); font-size: .8rem; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; align-items: center; }
.toolbar .espaco { flex: 1; }
.selecao-info { font-size: .85rem; color: var(--muted); font-weight: 500; }

.dropzone { border: 2px dashed transparent; border-radius: var(--radius-lg); transition: border-color .15s, background .15s; min-height: 160px; }
.dropzone.arrastando { border-color: var(--tint); background: rgba(10, 132, 255, .06); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 3px; }
.grid.lista { grid-template-columns: 1fr; gap: 1px; background: var(--separador); border-radius: var(--radius-md); overflow: hidden; }

/* Grid tipo "Fotos" da iOS: sem cartão, só a miniatura colada nas vizinhas */
.item {
    background: transparent; border-radius: 6px;
    padding: 0; cursor: pointer; position: relative; user-select: none;
    display: flex; flex-direction: column; gap: 6px; transition: transform .1s var(--ease);
}
.item:active { transform: scale(.97); }
.item.selecionado .thumb { outline: 2.5px solid var(--tint); outline-offset: -2.5px; }
.item.arrastando-item { opacity: .35; }
.item.alvo-drop .thumb { outline: 2.5px dashed var(--ok); outline-offset: -2.5px; }

/* Lista (seção "Outros") continua em linhas estilo iOS Settings */
.grid.lista .item { flex-direction: row; align-items: center; padding: 10px 14px; background: var(--surface); border-radius: 0; }
.grid.lista .item:active { background: var(--surface-2); }

.item .check {
    position: absolute; top: 6px; left: 6px; width: 22px; height: 22px; border-radius: 50%;
    background: rgba(0, 0, 0, .38); border: 1.5px solid rgba(255, 255, 255, .7);
    display: flex; align-items: center; justify-content: center; z-index: 2; transition: background-color .15s, border-color .15s;
}
.item .check svg { width: 12px; height: 12px; color: #fff; opacity: 0; transition: opacity .1s; }
.item.selecionado .check { background: var(--tint); border-color: var(--tint); }
.item.selecionado .check svg { opacity: 1; }

.item .thumb {
    width: 100%; aspect-ratio: 1; border-radius: 6px; background: var(--surface);
    display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative;
}
.item .thumb svg { width: 26px; height: 26px; color: var(--muted-2); }
.item .thumb img { width: 100%; height: 100%; object-fit: cover; }
.item .thumb .play {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    background: rgba(0, 0, 0, .18);
}
.item .thumb .play svg { width: 28px; height: 28px; color: #fff; filter: drop-shadow(0 1px 4px rgba(0, 0, 0, .5)); }
.grid.lista .item .thumb { width: 40px; height: 40px; aspect-ratio: unset; border-radius: 9px; flex: none; background: var(--surface-2); }
.grid.lista .item .thumb svg { width: 19px; height: 19px; }
.grid.lista .item .check { position: static; margin-right: 12px; background: transparent; border-color: var(--muted-2); flex: none; }
.grid.lista .item.selecionado .check { background: var(--tint); border-color: var(--tint); }

/* Nas fotos/vídeos o nome/tamanho fica embaixo, discreto (como o app Fotos
   não mostra nada - aqui mostramos por causa das seções "outros" e listas
   de pastas, mas mínimo e sem chamar atenção) */
.item .nome { font-size: .74rem; font-weight: 500; word-break: break-word; line-height: 1.25; color: var(--muted); padding: 0 1px; }
.item .meta { font-size: .68rem; color: var(--muted-2); margin-top: 1px; }
.grid.lista .item .nome { font-size: .92rem; color: var(--text); }
.grid.lista .item .nome-wrap { flex: 1; min-width: 0; }
.grid.lista .item .nome { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Pastas continuam como "cartão" pra se distinguirem do grid de fotos */
.item.item-pasta { background: var(--surface); border-radius: var(--radius-md); padding: 10px; }
.item.item-pasta:active { background: var(--surface-2); }
.item.item-pasta .thumb { background: transparent; }
.item.item-pasta .thumb svg { color: var(--tint); width: 34px; height: 34px; }

.vazio { text-align: center; padding: 70px 20px; color: var(--muted); font-size: .92rem; }
.vazio .icone { width: 46px; height: 46px; margin: 0 auto 14px; color: var(--muted-2); }

/* ---------- Modal (sheet estilo iOS) ---------- */
.modal-fundo {
    position: fixed; inset: 0; background: rgba(0, 0, 0, .5); display: none;
    align-items: flex-end; justify-content: center; z-index: 100;
}
.modal-fundo.aberto { display: flex; animation: modalFundoIn .15s var(--ease) both; }
@keyframes modalFundoIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
    background: var(--bg-elevado); border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: 22px 20px calc(26px + env(safe-area-inset-bottom, 0px)); width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto;
    box-shadow: var(--shadow-lg); animation: sheetIn .25s var(--ease) both;
}
@keyframes sheetIn { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 561px) {
    .modal-fundo { align-items: center; }
    .modal { border-radius: var(--radius-lg); }
}
.modal h3 { margin: 0 0 18px; font-size: 1.1rem; font-weight: 700; text-align: center; }
.modal .campo { margin-bottom: 14px; }
.modal .campo label { display: block; font-size: .78rem; font-weight: 500; color: var(--muted); margin-bottom: 6px; }
.modal .acoes { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal .acoes button { flex: 1; justify-content: center; }
.senha-mostrar { display: flex; gap: 6px; }
.senha-mostrar input { flex: 1; }

/* ---------- Configurações (engrenagem) ---------- */
.config-item {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 14px 2px; border-bottom: .5px solid var(--separador);
}
.config-item:last-of-type { border-bottom: none; }
.config-texto { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.config-texto strong { font-size: .92rem; font-weight: 500; }
.config-texto span { font-size: .8rem; color: var(--muted); line-height: 1.4; }

/* Switch idêntico ao da iOS: trilho cinza -> verde, bolinha branca */
.toggle { position: relative; flex: none; display: inline-flex; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-trilho {
    width: 51px; height: 31px; border-radius: 999px; background: rgba(120, 120, 128, .32);
    display: flex; align-items: center; padding: 2px;
    transition: background-color .18s var(--ease);
}
.toggle-bola {
    width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, .25);
    transition: transform .18s var(--ease);
}
.toggle input:checked + .toggle-trilho { background: var(--ok); }
.toggle input:checked + .toggle-trilho .toggle-bola { transform: translateX(20px); }
.toggle input:focus-visible + .toggle-trilho { box-shadow: 0 0 0 3px rgba(10, 132, 255, .35); }

/* ---------- Preview (lightbox) ---------- */
.preview-fundo {
    position: fixed; inset: 0; background: rgba(0, 0, 0, .97); display: none;
    align-items: center; justify-content: center; z-index: 200; flex-direction: column;
}
.preview-fundo.aberto { display: flex; animation: modalFundoIn .18s var(--ease) both; }
.preview-fundo img, .preview-fundo video { max-width: 94vw; max-height: 84vh; border-radius: 14px; }
.preview-topo { position: absolute; top: 18px; right: 18px; display: flex; gap: 8px; }
.preview-topo button { background: rgba(120, 120, 128, .32); backdrop-filter: blur(10px); color: #fff; }
.preview-topo button:active { background: rgba(120, 120, 128, .5); }
.preview-nome { position: absolute; top: 22px; left: 22px; color: #fff; font-size: .86rem; opacity: .8; font-weight: 500; }

/* ---------- Senhas ---------- */
.senha-item {
    display: flex; align-items: center; justify-content: space-between; padding: 12px 4px;
    background: transparent; border-bottom: .5px solid var(--separador);
}
.senha-item:last-child { border-bottom: none; }
.senha-item:active { background: var(--surface-2); }
.senha-item .info { display: flex; align-items: center; gap: 12px; min-width: 0; }
.senha-item .info .ic { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(160deg, #ffd60a, #ff9f0a); display: flex; align-items: center; justify-content: center; flex: none; }
.senha-item .info .ic svg { width: 16px; height: 16px; color: #1c1c1e; }
.senha-item .info .txt { min-width: 0; }
.senha-item .info strong { display: block; font-size: .95rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.senha-item .info span { font-size: .8rem; color: var(--muted); }
.senha-item .acoes { display: flex; gap: 2px; flex: none; }

.toast-wrap { position: fixed; top: calc(12px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 300; max-width: min(90vw, 340px); align-items: center; }
.toast {
    background: rgba(44, 44, 46, .92); backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: 14px; padding: 11px 18px;
    font-size: .86rem; font-weight: 500; box-shadow: var(--shadow-md); animation: toastIn .2s var(--ease) both;
    display: flex; align-items: center; gap: 8px;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.toast.erro { color: var(--danger); }
.toast.ok { color: var(--ok); }

.progresso-wrap { margin: -6px 0 16px; font-size: .82rem; color: var(--muted); }
.progresso-barra { height: 5px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.progresso-barra > div { height: 100%; background: var(--tint); width: 0%; transition: width .2s; }

@media (max-width: 560px) {
    .conteudo { padding: 16px 12px calc(96px + env(safe-area-inset-bottom, 0px)); }
    .topbar { padding: 10px 14px; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
    .inicio-grid { grid-template-columns: repeat(2, 1fr); }
}
