/* =================================================================
   Drive Share - Estilos
   Design limpo e profissional. Tema claro/escuro automático.
   ================================================================= */

:root {
    --bg:          #f4f6fb;
    --surface:     #ffffff;
    --surface-2:   #f8fafc;
    --border:      #e4e8f0;
    --text:        #1a2233;
    --text-soft:   #5b6577;
    --text-mute:   #8a93a6;
    --primary:     #2563eb;
    --primary-600: #1d4ed8;
    --primary-050: #eff4ff;
    --success:     #10b981;
    --success-bg:  #e7f8f1;
    --danger:      #ef4444;
    --danger-bg:   #fdecec;
    --warn:        #d97706;
    --warn-bg:     #fef3e2;
    --shadow:      0 1px 2px rgba(16,24,40,.04), 0 8px 24px rgba(16,24,40,.06);
    --shadow-sm:   0 1px 2px rgba(16,24,40,.06);
    --radius:      14px;
    --radius-sm:   10px;
    --font:        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg:          #0e1420;
        --surface:     #161d2b;
        --surface-2:   #1c2434;
        --border:      #29324a;
        --text:        #e8ecf4;
        --text-soft:   #a9b2c6;
        --text-mute:   #6f7a92;
        --primary:     #3b82f6;
        --primary-600: #2563eb;
        --primary-050: #17233d;
        --success:     #34d399;
        --success-bg:  #10291f;
        --danger:      #f87171;
        --danger-bg:   #2a1616;
        --warn:        #fbbf24;
        --warn-bg:     #2a2210;
        --shadow:      0 1px 2px rgba(0,0,0,.3), 0 12px 32px rgba(0,0,0,.35);
        --shadow-sm:   0 1px 2px rgba(0,0,0,.3);
    }
}

* { box-sizing: border-box; }

/* Garante que o atributo `hidden` esconde sempre (mesmo com display: flex/grid) */
[hidden] { display: none !important; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

svg.ico, svg.dz-icon {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ---------------------------------------------------- Botões */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 11px 18px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn .ico { width: 18px; height: 18px; }

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--primary-600); }

.btn-ghost {
    background: transparent;
    color: var(--text-soft);
    border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: transparent;
}
.btn-danger:hover { background: var(--danger-bg); }

.btn-sm { padding: 8px 13px; font-size: 13.5px; }
.btn-block { width: 100%; }

/* ---------------------------------------------------- Login */
.login-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    gap: 18px;
}
.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 38px 34px;
    width: 100%;
    max-width: 380px;
    text-align: center;
}
.login-logo { font-size: 42px; }
.login-card h1 { margin: 10px 0 2px; font-size: 22px; }
.login-sub { margin: 0 0 22px; color: var(--text-mute); font-size: 14px; }
.field { display: block; text-align: left; margin-bottom: 16px; }
.field span { display: block; font-size: 13px; font-weight: 600; color: var(--text-soft); margin-bottom: 6px; }
.field input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
}
.field input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-050);
}
.footer-note { color: var(--text-mute); font-size: 12.5px; }

.alert { border-radius: var(--radius-sm); padding: 11px 14px; font-size: 14px; margin-bottom: 16px; text-align: left; }
.alert-error { background: var(--danger-bg); color: var(--danger); }

/* ---------------------------------------------------- Topbar */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 20;
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand-logo {
    width: 44px; height: 44px; flex-shrink: 0;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
    box-shadow: 0 4px 12px rgba(37,99,235,.28);
    display: inline-flex; align-items: center; justify-content: center;
}
.brand-logo svg {
    width: 25px; height: 25px;
    fill: none; stroke: #fff; stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 16.5px; letter-spacing: -.01em; }
.brand-text small { color: var(--text-mute); font-size: 12.5px; }

/* ---------------------------------------------------- Como funciona (passos) */
.steps {
    display: flex;
    align-items: stretch;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 24px;
}
.step {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 16px 20px;
}
.step + .step { border-left: 1px solid var(--border); }
.step-num {
    width: 30px; height: 30px; flex-shrink: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
    color: #fff;
    font-size: 14px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
    box-shadow: 0 3px 8px rgba(37,99,235,.28);
}
.step-body { display: flex; flex-direction: column; line-height: 1.32; min-width: 0; }
.step-body strong { font-size: 14px; letter-spacing: -.01em; }
.step-body span { font-size: 12.5px; color: var(--text-mute); }

/* ---------------------------------------------------- Layout */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 26px 22px 60px;
}

/* ---------------------------------------------------- Tabs (os 2 botões) */
.tabs {
    display: flex;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 7px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}
.tab {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    border: none;
    background: transparent;
    color: var(--text-soft);
    font-size: 15.5px;
    font-weight: 600;
    font-family: inherit;
    padding: 13px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background .15s, color .15s;
}
.tab .ico { width: 20px; height: 20px; }
.tab:hover { color: var(--text); }
.tab.is-active {
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-sm);
}
.badge-count {
    background: rgba(255,255,255,.25);
    color: inherit;
    font-size: 12.5px;
    min-width: 22px;
    padding: 1px 7px;
    border-radius: 20px;
    font-weight: 700;
}
.tab:not(.is-active) .badge-count { background: var(--surface-2); color: var(--text-mute); }

/* ---------------------------------------------------- Vistas */
.view { display: none; animation: fade .2s ease; }
.view.is-active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------- Dropzone */
.dropzone {
    background: var(--surface);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 52px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--primary); background: var(--primary-050); outline: none; }
.dropzone.dragover { border-color: var(--primary); background: var(--primary-050); transform: scale(1.005); }
.dz-icon { width: 54px; height: 54px; color: var(--primary); margin-bottom: 6px; }
.dz-title { font-size: 18px; font-weight: 600; margin: 8px 0 2px; }
.dz-sub { color: var(--text-mute); margin: 0 0 14px; font-size: 14.5px; }
.dz-link { color: var(--primary); font-weight: 600; }
.dz-limit { color: var(--text-mute); font-size: 12.5px; margin: 0; }

/* ---------------------------------------------------- Prontos a enviar (compose) */
.compose {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 16px 18px;
    margin-top: 16px;
    animation: fade .2s ease;
}
.compose-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.compose-head strong { font-size: 14.5px; }

.staging { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.stg-item {
    display: flex; align-items: center; gap: 11px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
}
.stg-item.over { border-color: var(--danger); background: var(--danger-bg); }
.stg-ico {
    width: 30px; height: 30px; flex-shrink: 0;
    border-radius: 8px;
    background: var(--primary-050); color: var(--primary);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; text-transform: uppercase;
}
.stg-name { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stg-size { font-size: 12.5px; color: var(--text-mute); flex-shrink: 0; }
.stg-item.over .stg-size { color: var(--danger); font-weight: 600; }
.stg-del {
    flex-shrink: 0; width: 26px; height: 26px;
    border: none; background: transparent; cursor: pointer;
    color: var(--text-mute); font-size: 20px; line-height: 1;
    border-radius: 7px;
}
.stg-del:hover { background: var(--danger-bg); color: var(--danger); }

/* Palavra-passe do envio */
.pw-box {
    margin: 14px 0;
    padding: 14px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}
.pw-field { display: block; }
.pw-label {
    display: inline-flex; align-items: center; gap: 7px;
    font-size: 13px; font-weight: 600; color: var(--text-soft);
    margin-bottom: 8px;
}
.pw-label .ico { width: 15px; height: 15px; }
.pw-field input {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 14.5px; font-family: inherit;
}
.pw-field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-050); }
.pw-hint { margin: 9px 0 0; font-size: 12px; color: var(--text-mute); line-height: 1.45; }

/* ---------------------------------------------------- Fila de uploads */
.upload-queue { list-style: none; margin: 18px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.uq-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 13px 15px;
    box-shadow: var(--shadow-sm);
    animation: fade .2s ease;
}
.uq-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.uq-name { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uq-name svg { width: 14px; height: 14px; vertical-align: -2px; fill: none; stroke: var(--warn); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.uq-state { font-size: 13px; color: var(--text-mute); flex-shrink: 0; }
.uq-state.ok { color: var(--success); }
.uq-state.err { color: var(--danger); }
.uq-bar { height: 7px; background: var(--surface-2); border-radius: 20px; margin-top: 9px; overflow: hidden; }
.uq-fill { height: 100%; width: 0; background: var(--primary); border-radius: 20px; transition: width .2s ease; }
.uq-fill.ok { background: var(--success); }
.uq-fill.err { background: var(--danger); }

/* ---------------------------------------------------- Lista de ficheiros */
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 10px 14px; flex-wrap: wrap; margin-bottom: 14px; }
.list-head h2 { font-size: 18px; margin: 0; }

/* Ações globais ao lado do título (Atualizar / Descarregar todos / Apagar todos) */
.list-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.list-actions .btn-danger { border-color: var(--border); }
.list-actions .btn-danger:hover { border-color: var(--danger); }

.empty { text-align: center; padding: 54px 20px; color: var(--text-mute); }
.empty-icon { font-size: 46px; margin-bottom: 8px; }
.empty p { margin: 0 0 16px; font-size: 15px; }

.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}
table.files { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.files th {
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-mute);
    font-weight: 700;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
table.files td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.files tr:last-child td { border-bottom: none; }
table.files tbody tr { transition: background .12s; }
table.files tbody tr:hover { background: var(--surface-2); }

.file-name { display: flex; align-items: center; gap: 11px; min-width: 0; }
.file-ico {
    width: 34px; height: 34px; flex-shrink: 0;
    border-radius: 9px;
    background: var(--primary-050);
    color: var(--primary);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 15px; font-weight: 700;
    text-transform: uppercase;
}
.file-name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.lock-badge { display: inline-flex; flex-shrink: 0; color: var(--warn); }
.lock-badge svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.col-size, .col-date { color: var(--text-soft); white-space: nowrap; }
.col-actions { text-align: right; white-space: nowrap; }

/* Estado */
.status {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12.5px; font-weight: 600;
    padding: 5px 11px; border-radius: 20px; white-space: nowrap;
}
.status .ico { width: 14px; height: 14px; }
.status.pending { background: var(--warn-bg); color: var(--warn); }
.status.done    { background: var(--success-bg); color: var(--success); }
.status-sub { display: block; font-size: 11px; color: var(--text-mute); margin-top: 3px; font-weight: 500; }

/* Ações da linha */
.row-actions { display: inline-flex; gap: 6px; }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 9px;
    cursor: pointer;
    color: var(--text-soft);
    transition: background .12s, color .12s, border-color .12s;
}
.icon-btn .ico { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.download:hover { color: var(--primary); border-color: var(--primary); }
.icon-btn.delete:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-bg); }

/* ---------------------------------------------------- Footer */
.app-footer { text-align: center; color: var(--text-mute); font-size: 12.5px; padding: 20px; }
.app-footer .footer-sep { margin: 0 7px; opacity: .55; }
.app-footer .footer-link {
    color: var(--text-mute);
    text-decoration: none;
    border-bottom: 1px solid var(--border);
    transition: color .15s, border-color .15s;
}
.app-footer .footer-link:hover,
.app-footer .footer-link:focus-visible { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------------------------------------------------- Toasts */
.toast-wrap {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
    display: flex; flex-direction: column; gap: 10px; z-index: 60; width: min(92vw, 400px);
}
.toast {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    padding: 13px 16px;
    font-size: 14px;
    animation: toastIn .25s ease;
}
.toast.ok  { border-left-color: var(--success); }
.toast.err { border-left-color: var(--danger); }
.toast.fade { opacity: 0; transform: translateY(8px); transition: opacity .3s, transform .3s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------- Modal de confirmação */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(10,15,25,.5);
    display: flex; align-items: center; justify-content: center;
    padding: 20px; z-index: 80; animation: fade .15s ease;
}
.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 26px;
    width: 100%; max-width: 420px;
    text-align: center;
}
.modal-icon { font-size: 38px; }
.modal h3 { margin: 8px 0 6px; font-size: 19px; }
.modal p { margin: 0 0 22px; color: var(--text-soft); font-size: 14.5px; }
.modal-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    font-size: 15px; font-family: inherit;
    margin-bottom: 12px;
}
.modal-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-050); }
.modal-err {
    background: var(--danger-bg); color: var(--danger);
    border-radius: var(--radius-sm);
    padding: 9px 12px; font-size: 13.5px; margin-bottom: 14px;
}
.modal .warn-line { color: var(--warn); font-weight: 600; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

/* ---------------------------------------------------- Responsivo */
/* Passos empilham a partir de tablet estreito */
@media (max-width: 720px) {
    .steps { flex-direction: column; }
    .step + .step { border-left: none; border-top: 1px solid var(--border); }
}

@media (max-width: 560px) {
    .tab { font-size: 14px; padding: 12px 8px; }
    .tab .ico { width: 18px; height: 18px; }
    .col-date { display: none; }
    .dropzone { padding: 40px 16px; }
    table.files th, table.files td { padding: 12px 12px; }
    .topbar { padding: 12px 16px; }
    .brand-text small { display: none; }
    .step { padding: 14px 16px; }
    /* Barra de ações compacta: só ícones (o title/aria-label mantém o significado) */
    .list-actions .btn-label { display: none; }
    .list-actions .btn-sm { padding: 8px 10px; }
}
