
/* ============================================================
   App Store - Tema claro/escuro
   ============================================================ */

html[data-theme="dark"] {
    color-scheme: dark;
}

html[data-theme="dark"] body {
    background: #0b1120 !important;
    color: #e5e7eb !important;
}

html[data-theme="dark"] a {
    color: #93c5fd;
}

html[data-theme="dark"] .site-header {
    background: #020617 !important;
    color: #f8fafc !important;
}

html[data-theme="dark"] .site-header p {
    color: #94a3b8 !important;
}

html[data-theme="dark"] .back-link {
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .path-card,
html[data-theme="dark"] .app-card,
html[data-theme="dark"] .app-detail-card,
html[data-theme="dark"] .search-section,
html[data-theme="dark"] .empty-state {
    background: #111827 !important;
    color: #e5e7eb !important;
    border-color: #374151 !important;
}

html[data-theme="dark"] .path-card h2,
html[data-theme="dark"] .app-card h2,
html[data-theme="dark"] .app-detail-info h1,
html[data-theme="dark"] .app-detail-section h2,
html[data-theme="dark"] .empty-state h2 {
    color: #f8fafc !important;
}

html[data-theme="dark"] .app-description,
html[data-theme="dark"] .app-detail-description,
html[data-theme="dark"] .app-detail-info,
html[data-theme="dark"] .empty-state p {
    color: #cbd5e1 !important;
}

html[data-theme="dark"] #appSearch,
html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
    background: #111827 !important;
    color: #f8fafc !important;
    border-color: #475569 !important;
}

html[data-theme="dark"] #appSearch::placeholder,
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
    color: #94a3b8 !important;
}

html[data-theme="dark"] .filter-button {
    background: #1e293b !important;
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .filter-button:hover {
    background: #334155 !important;
}

html[data-theme="dark"] .filter-button.active {
    background: #2563eb !important;
    color: #fff !important;
}

html[data-theme="dark"] .app-detail-version,
html[data-theme="dark"] .app-filter-badge {
    background: #1e293b !important;
    color: #cbd5e1 !important;
}

html[data-theme="dark"] .instruction {
    background: #172033 !important;
    border-color: #334155 !important;
}

html[data-theme="dark"] .instruction h3 {
    color: #f8fafc !important;
}

html[data-theme="dark"] .instruction-content {
    color: #cbd5e1 !important;
}

/* Admin */
html[data-theme="dark"] .admin-wrapper,
html[data-theme="dark"] .admin-content,
html[data-theme="dark"] .admin-page-title,
html[data-theme="dark"] .admin-section,
html[data-theme="dark"] .admin-card,
html[data-theme="dark"] .empty-admin {
    color: #e5e7eb;
}

html[data-theme="dark"] .admin-section,
html[data-theme="dark"] .admin-card,
html[data-theme="dark"] .empty-admin {
    background: #111827 !important;
    border-color: #374151 !important;
}

html[data-theme="dark"] .admin-header {
    background: #020617 !important;
    color: #f8fafc !important;
}

html[data-theme="dark"] .admin-header p,
html[data-theme="dark"] .admin-page-title p,
html[data-theme="dark"] small {
    color: #94a3b8 !important;
}

html[data-theme="dark"] .admin-table,
html[data-theme="dark"] table {
    color: #e5e7eb !important;
}

html[data-theme="dark"] .admin-table th,
html[data-theme="dark"] table th {
    background: #1e293b !important;
    color: #f8fafc !important;
    border-color: #475569 !important;
}

html[data-theme="dark"] .admin-table td,
html[data-theme="dark"] table td {
    border-color: #334155 !important;
}

html[data-theme="dark"] .admin-table tr:hover,
html[data-theme="dark"] table tr:hover {
    background: #172033 !important;
}

html[data-theme="dark"] .form-group label,
html[data-theme="dark"] label {
    color: #e5e7eb !important;
}

html[data-theme="dark"] .success-message {
    background: #052e16 !important;
    color: #bbf7d0 !important;
    border-color: #166534 !important;
}

html[data-theme="dark"] .error-message {
    background: #450a0a !important;
    color: #fecaca !important;
    border-color: #991b1b !important;
}

html[data-theme="dark"] .status-badge,
html[data-theme="dark"] .count-badge {
    border-color: #475569 !important;
}

/* Botão de tema */
.theme-toggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 40px;
    padding: 9px 13px;
    border: 1px solid rgba(148, 163, 184, .45);
    border-radius: 10px;
    background: rgba(255,255,255,.10);
    color: inherit;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    line-height: 1;
    transition: background .15s ease, transform .15s ease, border-color .15s ease;
}

.theme-toggle:hover {
    background: rgba(255,255,255,.18);
    transform: translateY(-1px);
}

html[data-theme="dark"] .theme-toggle {
    background: #1e293b;
    color: #f8fafc;
    border-color: #475569;
}

html[data-theme="dark"] .theme-toggle:hover {
    background: #334155;
}

/* Header público */
.theme-toggle-wrap {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
}

/* Header admin */
.admin-header .theme-toggle-wrap {
    margin: 0;
}

/* Páginas de erro / login */
html[data-theme="dark"] .error-page,
html[data-theme="dark"] .login-card,
html[data-theme="dark"] .login-container,
html[data-theme="dark"] .login-box {
    background: #111827 !important;
    color: #e5e7eb !important;
}

@media (max-width: 700px) {
    .theme-toggle {
        min-height: 38px;
        padding: 8px 11px;
        font-size: 13px;
    }
}


/* ============================================================
   Tema público — seletor claro/escuro e downloads
   ============================================================ */
.theme-toggle-wrap {
    display: flex;
    justify-content: flex-end;
    margin: 0 0 12px;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 9px 14px;
    border: 1px solid rgba(148, 163, 184, .55);
    border-radius: 999px;
    background: #ffffff;
    color: #0f172a;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 3px 10px rgba(15, 23, 42, .10);
    transition: background .15s ease, transform .15s ease, border-color .15s ease;
}

.theme-toggle:hover {
    background: #f1f5f9;
    transform: translateY(-1px);
}

.theme-toggle-icon {
    font-size: 17px;
}

html[data-theme="dark"] .theme-toggle {
    background: #1e293b;
    color: #f8fafc;
    border-color: #475569;
}

html[data-theme="dark"] .theme-toggle:hover {
    background: #334155;
}

html[data-theme="dark"] .app-detail-card {
    background: #111827 !important;
    color: #e5e7eb !important;
}

html[data-theme="dark"] .app-detail-image {
    background: #1f2937 !important;
}

html[data-theme="dark"] .instruction {
    background: #172033 !important;
    color: #e5e7eb !important;
    border: 1px solid #334155;
}

html[data-theme="dark"] .instruction-content {
    color: #cbd5e1 !important;
}

@media (max-width: 700px) {
    .theme-toggle {
        min-height: 38px;
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* ============================================================
   ADMIN - CORREÇÃO DO TEMA ESCURO
   ============================================================ */

html[data-theme="dark"] body:has(.admin-wrapper) {
    background: #0b1120 !important;
    color: #e5e7eb !important;
}

html[data-theme="dark"] body:has(.admin-wrapper) .admin-wrapper,
html[data-theme="dark"] body:has(.admin-wrapper) .admin-content {
    background: transparent !important;
    color: #e5e7eb !important;
}

html[data-theme="dark"] body:has(.admin-wrapper) .admin-page-title,
html[data-theme="dark"] body:has(.admin-wrapper) .admin-page-title h2 {
    color: #f8fafc !important;
}

html[data-theme="dark"] body:has(.admin-wrapper) .admin-page-title p,
html[data-theme="dark"] body:has(.admin-wrapper) .admin-page-title span,
html[data-theme="dark"] body:has(.admin-wrapper) small {
    color: #94a3b8 !important;
}

/* Cartões dos contadores do dashboard */
html[data-theme="dark"] body:has(.admin-wrapper) .dashboard-card {
    background: #111827 !important;
    color: #e5e7eb !important;
    border: 1px solid #1f2937 !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .22) !important;
}

html[data-theme="dark"] body:has(.admin-wrapper) .dashboard-card strong {
    color: #f8fafc !important;
}

html[data-theme="dark"] body:has(.admin-wrapper) .dashboard-card span {
    color: #cbd5e1 !important;
}

html[data-theme="dark"] body:has(.admin-wrapper) .dashboard-card-link {
    color: #93c5fd !important;
}

html[data-theme="dark"] body:has(.admin-wrapper) .dashboard-card-link:hover {
    color: #bfdbfe !important;
}

/* Blocos do dashboard */
html[data-theme="dark"] body:has(.admin-wrapper) .admin-section,
html[data-theme="dark"] body:has(.admin-wrapper) .admin-card,
html[data-theme="dark"] body:has(.admin-wrapper) .empty-admin {
    background: #111827 !important;
    color: #e5e7eb !important;
    border-color: #1f2937 !important;
}

html[data-theme="dark"] body:has(.admin-wrapper) .admin-section h2,
html[data-theme="dark"] body:has(.admin-wrapper) .admin-section h3,
html[data-theme="dark"] body:has(.admin-wrapper) .admin-section h4 {
    color: #f8fafc !important;
}

html[data-theme="dark"] body:has(.admin-wrapper) .admin-section p,
html[data-theme="dark"] body:has(.admin-wrapper) .admin-section small {
    color: #94a3b8 !important;
}

/* Tabelas */
html[data-theme="dark"] body:has(.admin-wrapper) .admin-table-wrapper,
html[data-theme="dark"] body:has(.admin-wrapper) .admin-table,
html[data-theme="dark"] body:has(.admin-wrapper) table {
    background: #111827 !important;
    color: #e5e7eb !important;
}

html[data-theme="dark"] body:has(.admin-wrapper) .admin-table th,
html[data-theme="dark"] body:has(.admin-wrapper) table th {
    background: #1e293b !important;
    color: #f8fafc !important;
    border-color: #334155 !important;
}

html[data-theme="dark"] body:has(.admin-wrapper) .admin-table td,
html[data-theme="dark"] body:has(.admin-wrapper) table td {
    color: #e5e7eb !important;
    border-color: #334155 !important;
}

/* Formulários */
html[data-theme="dark"] body:has(.admin-wrapper) input,
html[data-theme="dark"] body:has(.admin-wrapper) select,
html[data-theme="dark"] body:has(.admin-wrapper) textarea {
    background: #111827 !important;
    color: #f8fafc !important;
    border-color: #475569 !important;
}

html[data-theme="dark"] body:has(.admin-wrapper) input::placeholder,
html[data-theme="dark"] body:has(.admin-wrapper) textarea::placeholder {
    color: #64748b !important;
}

html[data-theme="dark"] body:has(.admin-wrapper) label {
    color: #e5e7eb !important;
}

/* ============================================================
   Admin - seletores de Caminhos/Filtros
   Corrige os checkboxes que estavam a herdar o estilo dos inputs
   de texto e ficavam enormes e com pouco contraste.
   ============================================================ */

html[data-theme="dark"] body:has(.admin-wrapper) .selection-grid {
    gap: 12px !important;
}

html[data-theme="dark"] body:has(.admin-wrapper) .selection-item {
    background: #1e293b !important;
    color: #f8fafc !important;
    border: 1px solid #475569 !important;
    border-radius: 8px !important;
    padding: 12px 14px !important;
    min-height: 64px !important;
    box-sizing: border-box !important;
}

html[data-theme="dark"] body:has(.admin-wrapper) .selection-item:hover {
    background: #263449 !important;
    border-color: #64748b !important;
}

html[data-theme="dark"] body:has(.admin-wrapper) .selection-item > span,
html[data-theme="dark"] body:has(.admin-wrapper) .selection-item strong {
    color: #f8fafc !important;
}

html[data-theme="dark"] body:has(.admin-wrapper) .selection-item small {
    color: #94a3b8 !important;
}

/* Checkbox: tamanho normal, sem herdar width/height dos inputs de texto */
html[data-theme="dark"] body:has(.admin-wrapper) .selection-item input[type="checkbox"],
html[data-theme="dark"] body:has(.admin-wrapper) .form-checks input[type="checkbox"],
html[data-theme="dark"] body:has(.admin-wrapper) input[type="checkbox"] {
    width: 18px !important;
    min-width: 18px !important;
    max-width: 18px !important;
    height: 18px !important;
    min-height: 18px !important;
    max-height: 18px !important;
    margin: 0 10px 0 0 !important;
    padding: 0 !important;
    flex: 0 0 18px !important;
    background: transparent !important;
    border: 0 !important;
    accent-color: #2563eb !important;
}

html[data-theme="dark"] body:has(.admin-wrapper) .selection-item {
    display: flex !important;
    align-items: center !important;
}

html[data-theme="dark"] body:has(.admin-wrapper) .selection-item > span {
    flex: 1 1 auto !important;
    min-width: 0 !important;
}

html[data-theme="dark"] body:has(.admin-wrapper) .selection-item .status-badge {
    display: inline-block !important;
    margin-top: 5px !important;
}
