/* ============================================================
   Portal Transparência Seropédica — CSS Base
   Mobile-first | Light default | Dark toggle
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-primary-light: #dbeafe;
    --color-success: #16a34a;
    --color-success-light: #dcfce7;
    --color-warning: #d97706;
    --color-warning-light: #fef3c7;
    --color-danger: #dc2626;
    --color-danger-light: #fee2e2;

    --bg-body: #f1f5f9;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-topbar: #ffffff;
    --bg-input: #ffffff;
    --bg-hover: #f8fafc;
    --sidebar-border: #e2e8f0;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    --text-inverse: #f8fafc;

    --border-color: #e2e8f0;
    --border-radius: 8px;
    --border-radius-sm: 4px;
    --border-radius-lg: 12px;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1);

    --sidebar-width: 260px;
    --topbar-height: 60px;

    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', monospace;
}

[data-theme="dark"] {
    --bg-body: #0f172a;
    --bg-card: #1e293b;
    --bg-sidebar: #0f172a;
    --bg-topbar: #1e293b;
    --bg-input: #334155;
    --bg-hover: #334155;
    --sidebar-border: rgba(255,255,255,.1);

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;

    --border-color: #334155;

    --color-primary-light: #1e3a5f;
    --color-success-light: #14532d;
    --color-warning-light: #451a03;
    --color-danger-light: #450a0a;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.2);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.3);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.4);
}

/* --- Tema "Prefeitura" — sidebar + topbar em magenta, body cinza claro --- */
[data-theme="prefeitura"] {
    --bg-sidebar: #E5326E;
    --bg-topbar: #E5326E;
    --sidebar-border: rgba(255,255,255,.15);
}
[data-theme="prefeitura"] .sidebar { color: rgba(255,255,255,.85); }
[data-theme="prefeitura"] .sidebar-brand { color: #fff; }
[data-theme="prefeitura"] .sidebar-brand:hover { color: #fff; opacity: .85; }
[data-theme="prefeitura"] .sidebar-section-title { color: rgba(255,255,255,.55); }
[data-theme="prefeitura"] .sidebar-link { color: rgba(255,255,255,.85); }
[data-theme="prefeitura"] .sidebar-link:hover { background: rgba(255,255,255,.12); color: #fff; }
[data-theme="prefeitura"] .sidebar-link.active {
    background: rgba(255,255,255,.18); color: #fff;
    border-left-color: #fff; font-weight: 600;
}
[data-theme="prefeitura"] .topbar {
    background: var(--bg-topbar);
    border-bottom-color: rgba(255,255,255,.15);
}
[data-theme="prefeitura"] .topbar .btn-icon { color: #fff; }
[data-theme="prefeitura"] .topbar .btn-icon:hover { background: rgba(255,255,255,.12); }
[data-theme="prefeitura"] .topbar-user-btn {
    color: #fff; border-color: rgba(255,255,255,.3); background: transparent;
}
[data-theme="prefeitura"] .topbar-user-btn:hover { background: rgba(255,255,255,.12); }
[data-theme="prefeitura"] .topbar-user-avatar {
    background: rgba(255,255,255,.2); color: #fff;
}

html { font-size: 16px; }
body {
    font-family: var(--font-family);
    color: var(--text-primary);
    background: var(--bg-body);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
code { font-family: var(--font-mono); font-size: .875em; background: var(--bg-hover); padding: .125em .375em; border-radius: var(--border-radius-sm); }
small, .form-help { font-size: .8125rem; color: var(--text-tertiary); }

/* --- Theme toggle icons --- */
.theme-icon-dark, .theme-icon-prefeitura { display: none; }
[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="dark"] .theme-icon-dark { display: inline-flex; }
[data-theme="prefeitura"] .theme-icon-light,
[data-theme="prefeitura"] .theme-icon-dark { display: none; }
[data-theme="prefeitura"] .theme-icon-prefeitura { display: inline-flex; }
[x-cloak] { display: none !important; }

/* --- Utilities --- */
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }

/* --- Buttons --- */
.btn {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .625rem 1.25rem;
    font-size: .875rem; font-weight: 500; font-family: inherit;
    border: 1px solid transparent; border-radius: var(--border-radius);
    cursor: pointer; transition: all .15s;
    text-decoration: none; white-space: nowrap;
    line-height: 1.4;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-secondary { background: var(--bg-card); color: var(--text-primary); border-color: var(--border-color); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: .375rem .75rem; font-size: .8125rem; }
.btn-icon { background: none; border: none; cursor: pointer; color: var(--text-secondary); padding: .5rem; border-radius: var(--border-radius); display: inline-flex; align-items: center; }
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }

/* --- Forms --- */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .375rem; color: var(--text-primary); }
.form-input {
    width: 100%; padding: .625rem .875rem;
    font-size: .875rem; font-family: inherit;
    border: 1px solid var(--border-color); border-radius: var(--border-radius);
    background: var(--bg-input); color: var(--text-primary);
    transition: border-color .15s;
}
.form-input:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.form-input::placeholder { color: var(--text-tertiary); }
.form-input:disabled { opacity: .6; cursor: not-allowed; }
.form-input-lg { padding: .875rem 1rem; font-size: 1rem; }
select.form-input { cursor: pointer; }
.form-actions { display: flex; gap: .75rem; margin-top: 1.5rem; }
.form-help { display: block; margin-top: .25rem; }

.input-password-wrapper { position: relative; }
.input-password-wrapper .form-input { padding-right: 3rem; }
.btn-toggle-password { position: absolute; right: .5rem; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: var(--text-tertiary); padding: .25rem; }
.btn-toggle-password:hover { color: var(--text-primary); }

.checkbox-label { display: flex; align-items: center; gap: .5rem; cursor: pointer; font-size: .875rem; }
.checkbox-label input[type="checkbox"] { width: 1rem; height: 1rem; accent-color: var(--color-primary); cursor: pointer; }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .75rem; margin-top: .75rem; }

.password-strength { height: 4px; border-radius: 2px; margin-top: .5rem; background: var(--border-color); overflow: hidden; }
.password-strength-bar { height: 100%; transition: width .3s, background .3s; border-radius: 2px; }

.filters-bar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.filters-bar .form-group { margin-bottom: 0; }

/* --- Cards --- */
.card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--border-radius-lg); box-shadow: var(--shadow-sm); margin-bottom: 1rem; }
.card-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border-color); font-weight: 600; font-size: .9375rem; }
.card-body { padding: 1.25rem; }

/* --- Tables --- */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th { text-align: left; padding: .75rem 1rem; font-weight: 600; color: var(--text-secondary); border-bottom: 2px solid var(--border-color); white-space: nowrap; }
.table td { padding: .75rem 1rem; border-bottom: 1px solid var(--border-color); }
.table tbody tr:hover { background: var(--bg-hover); }
.table tbody tr:last-child td { border-bottom: none; }

/* --- Badges --- */
.badge {
    display: inline-flex; align-items: center; gap: .25rem;
    padding: .125rem .5rem; font-size: .75rem; font-weight: 500;
    border-radius: 999px;
    background: var(--bg-hover); color: var(--text-secondary);
}
.badge-primary { background: var(--color-primary-light); color: var(--color-primary); }
.badge-success { background: var(--color-success-light); color: var(--color-success); }
.badge-warning { background: var(--color-warning-light); color: var(--color-warning); }
.badge-danger { background: var(--color-danger-light); color: var(--color-danger); }
.badge-default { background: var(--bg-hover); color: var(--text-secondary); }

/* --- Alerts --- */
.alert { padding: .875rem 1rem; border-radius: var(--border-radius); margin-bottom: 1rem; font-size: .875rem; }
.alert-success { background: var(--color-success-light); color: var(--color-success); border: 1px solid var(--color-success); }
.alert-error { background: var(--color-danger-light); color: var(--color-danger); border: 1px solid var(--color-danger); }
.alert-info { background: var(--color-primary-light); color: var(--color-primary); border: 1px solid var(--color-primary); }

/* --- Pagination --- */
.pagination { display: flex; gap: .25rem; padding: 1rem; justify-content: center; flex-wrap: wrap; }
.pagination-link {
    padding: .5rem .875rem; font-size: .875rem;
    border: 1px solid var(--border-color); border-radius: var(--border-radius);
    color: var(--text-secondary); text-decoration: none;
}
.pagination-link:hover { background: var(--bg-hover); text-decoration: none; }
.pagination-link.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* --- Toast --- */
.toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 10000; display: flex; flex-direction: column; gap: .5rem; }
.toast {
    padding: .875rem 1.25rem; border-radius: var(--border-radius);
    font-size: .875rem; color: #fff; box-shadow: var(--shadow-lg);
    animation: toast-in .3s ease-out;
    max-width: 400px;
}
.toast-success { background: var(--color-success); }
.toast-error { background: var(--color-danger); }
.toast-info { background: var(--color-primary); }
@keyframes toast-in { from { opacity: 0; transform: translateX(100%); } to { opacity: 1; transform: translateX(0); } }

/* --- Dropdown --- */
.dropdown { position: relative; }
.dropdown-menu {
    position: absolute; top: 100%; right: 0; z-index: 100;
    min-width: 200px; padding: .375rem 0;
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--border-radius); box-shadow: var(--shadow-lg);
    margin-top: .375rem;
}
.dropdown-menu-right { right: 0; left: auto; }
.dropdown-item { display: flex; align-items: center; gap: .5rem; padding: .5rem 1rem; font-size: .875rem; color: var(--text-primary); text-decoration: none; transition: background .1s; }
.dropdown-item:hover { background: var(--bg-hover); text-decoration: none; }
.dropdown-item-danger { color: var(--color-danger); }
.dropdown-divider { height: 1px; background: var(--border-color); margin: .25rem 0; }

/* --- Info list --- */
.info-list { display: flex; flex-direction: column; gap: .75rem; }
.info-item { display: flex; flex-direction: column; gap: .125rem; }
.info-label { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-tertiary); }
.info-value { font-size: .875rem; }

/* --- Grid --- */
.grid-2col { display: grid; gap: 1.5rem; }
@media (min-width: 768px) { .grid-2col { grid-template-columns: 2fr 1fr; } }

/* ============================================================
   LAYOUT — Auth pages
   ============================================================ */
.auth-body { display: flex; min-height: 100vh; background: var(--bg-body); }
.auth-container { display: flex; align-items: center; justify-content: center; flex: 1; padding: 1rem; }
.auth-card { background: var(--bg-card); border-radius: var(--border-radius-lg); box-shadow: var(--shadow-lg); padding: 2.5rem; width: 100%; max-width: 440px; }
.auth-logo { text-align: center; margin-bottom: 2rem; }
.auth-logo-icon { color: var(--color-primary); margin-bottom: .75rem; }
.auth-logo h1 { font-size: 1.25rem; font-weight: 700; margin: 0; }
.auth-logo p { font-size: .875rem; color: var(--text-secondary); margin: .25rem 0 0; }
.auth-card h2 { font-size: 1.125rem; font-weight: 600; margin-bottom: 1.5rem; text-align: center; }
.auth-subtitle { font-size: .875rem; color: var(--text-secondary); text-align: center; margin-bottom: 1.5rem; }
.auth-current-user {
    display: flex; align-items: center; justify-content: center; gap: .375rem;
    padding: .625rem .875rem;
    margin-bottom: 1.5rem;
    background: var(--bg-subtle, #F1F5F9);
    border: 1px solid var(--border, #E2E8F0);
    border-radius: 8px;
    font-size: .8125rem;
    color: var(--text-secondary);
}
.auth-current-user strong { color: var(--text-primary); font-weight: 600; }
.auth-links { text-align: center; margin-top: 1.5rem; font-size: .875rem; }
.auth-links-separator { margin: 0 .5rem; color: var(--text-tertiary); }

/* ============================================================
   LAYOUT — App (sidebar + topbar + content)
   ============================================================ */
.app-body { display: flex; min-height: 100vh; background: var(--bg-body); }

/* --- Sidebar --- */
.sidebar {
    position: fixed; top: 0; left: 0; z-index: 200;
    width: var(--sidebar-width); height: 100vh;
    background: var(--bg-sidebar); color: var(--text-secondary);
    border-right: 1px solid var(--sidebar-border);
    overflow-y: auto; transition: transform .3s;
    display: flex; flex-direction: column;
}
.sidebar-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--sidebar-border); }
.sidebar-brand { display: flex; align-items: center; gap: .75rem; color: var(--text-primary); text-decoration: none; }
.sidebar-brand:hover { text-decoration: none; }
.sidebar-brand-logo {
    flex-shrink: 0;
    width: 40px; height: 40px;
    object-fit: contain;
    transition: transform .15s ease;
}
.sidebar-brand:hover .sidebar-brand-logo { transform: scale(1.05); }
.sidebar-brand-text {
    display: flex; flex-direction: column;
    line-height: 1.2; min-width: 0;
}
.sidebar-brand-text strong {
    font-size: 15px; font-weight: 800;
    color: var(--color-primary, #E5326E);
    letter-spacing: -.01em;
    line-height: 1.15;
}
.sidebar-brand-text small {
    font-size: 11px; font-weight: 600;
    color: var(--text-secondary, #475569);
    margin-top: 2px;
    line-height: 1.25;
}
[data-theme="prefeitura"] .sidebar-brand-text strong { color: #fff; }
[data-theme="prefeitura"] .sidebar-brand-text small { color: rgba(255,255,255,.85); }
.sidebar-nav { flex: 1; padding: .75rem 0; overflow-y: auto; }
.sidebar-section-title { padding: 1.25rem 1.25rem .5rem; font-size: .6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-tertiary); }
.sidebar-link {
    display: flex; align-items: center; gap: .75rem;
    padding: .625rem 1.25rem; font-size: .875rem;
    color: var(--text-secondary); text-decoration: none;
    transition: all .15s; border-left: 3px solid transparent;
}
.sidebar-link:hover { background: var(--bg-hover); color: var(--text-primary); text-decoration: none; }
.sidebar-link.active { background: var(--color-primary-light); color: var(--color-primary); border-left-color: var(--color-primary); font-weight: 600; }
[data-theme="dark"] .sidebar-link.active { background: rgba(37,99,235,.15); }

/* Mobile sidebar */
@media (max-width: 1023px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay { position: fixed; inset: 0; z-index: 199; background: rgba(0,0,0,.5); display: none; }
    .sidebar.open ~ .app-main .sidebar-overlay,
    body.sidebar-open .sidebar-overlay { display: block; }
}
@media (min-width: 1024px) {
    .sidebar-overlay { display: none !important; }
    .topbar-menu-btn { display: none !important; }
}

/* --- Main area --- */
.app-main { flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
@media (min-width: 1024px) { .app-main { margin-left: var(--sidebar-width); } }

/* --- Topbar --- */
.topbar {
    position: sticky; top: 0; z-index: 100;
    height: var(--topbar-height); padding: 0 1.25rem;
    background: var(--bg-topbar); border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; justify-content: space-between;
    box-shadow: var(--shadow-sm);
}
.topbar-left { display: flex; align-items: center; gap: .75rem; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: .5rem; }
.topbar-user-btn {
    display: flex; align-items: center; gap: .5rem;
    background: none; border: 1px solid var(--border-color);
    border-radius: var(--border-radius); padding: .375rem .75rem;
    font-size: .875rem; cursor: pointer; color: var(--text-primary);
    font-family: inherit;
}
.topbar-user-btn:hover { background: var(--bg-hover); }
.topbar-user-avatar { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--color-primary-light); color: var(--color-primary); }
.topbar-user-name { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) { .topbar-user-name { display: none; } }

/* --- Content --- */
.app-content { flex: 1; padding: 1.5rem; max-width: 1200px; width: 100%; margin: 0 auto; }
.app-footer { text-align: center; padding: 1rem; font-size: .8125rem; color: var(--text-tertiary); border-top: 1px solid var(--border-color); }

/* --- Page header --- */
.page-header { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; display: flex; align-items: center; gap: .5rem; }
.page-subtitle { color: var(--text-secondary); font-size: .875rem; width: 100%; }

/* --- Breadcrumb --- */
.breadcrumb { display: flex; align-items: center; gap: .375rem; font-size: .8125rem; margin-bottom: 1rem; flex-wrap: wrap; }
.breadcrumb-link { color: var(--text-secondary); }
.breadcrumb-link:hover { color: var(--color-primary); }
.breadcrumb-current { color: var(--text-primary); font-weight: 500; }
.breadcrumb-separator { color: var(--text-tertiary); display: flex; }

/* --- Dashboard cards --- */
.dashboard-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; }
.dashboard-card {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: .875rem;
    padding: 1.5rem 1rem; background: var(--bg-card);
    border: 1px solid var(--border-color); border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm); text-decoration: none; color: inherit;
    text-align: center;
    min-height: 140px;
    transition: box-shadow .2s ease, transform .15s ease, border-color .15s ease;
}
.dashboard-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
    border-color: var(--color-primary);
    text-decoration: none;
}
.dashboard-card-icon {
    color: var(--color-primary);
    display: inline-flex; align-items: center; justify-content: center;
    width: 64px; height: 64px;
    border-radius: 50%;
    background: var(--color-primary-light);
    transition: transform .2s ease, background .15s ease;
}
.dashboard-card:hover .dashboard-card-icon {
    transform: scale(1.08);
}
.dashboard-card-icon .icon { width: 32px; height: 32px; }
.dashboard-card-title {
    font-size: .9375rem; font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

/* --- Search bar (topbar) --- */
.search-bar { position: relative; flex: 1; max-width: 400px; }
.search-bar-input-wrapper { position: relative; display: flex; align-items: center; }
.search-bar-input-wrapper .icon { position: absolute; left: .75rem; color: var(--text-tertiary); pointer-events: none; }
.search-bar-input {
    width: 100%; padding: .5rem .75rem .5rem 2.5rem;
    border: 1px solid var(--border-color); border-radius: var(--border-radius);
    font-size: .875rem; background: var(--bg-input); color: var(--text-primary);
    font-family: inherit;
}
.search-bar-input:focus { outline: none; border-color: var(--color-primary); }
.search-bar-results {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 200;
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--border-radius); box-shadow: var(--shadow-lg);
    margin-top: .25rem; max-height: 400px; overflow-y: auto;
}
.search-bar-result-item { display: flex; flex-direction: column; padding: .625rem 1rem; text-decoration: none; color: var(--text-primary); border-bottom: 1px solid var(--border-color); }
.search-bar-result-item:hover { background: var(--bg-hover); text-decoration: none; }
.search-bar-result-type { font-size: .6875rem; font-weight: 600; text-transform: uppercase; color: var(--color-primary); }
.search-bar-result-title { font-size: .875rem; }
.search-bar-loading, .search-bar-empty { padding: 1rem; text-align: center; font-size: .875rem; color: var(--text-secondary); }
.search-bar-view-all { display: block; padding: .75rem; text-align: center; font-size: .875rem; font-weight: 500; border-top: 1px solid var(--border-color); }
.search-bar-view-all:hover { background: var(--bg-hover); text-decoration: none; }

@media (max-width: 640px) { .search-bar { display: none; } }

/* --- Search results page --- */
.search-results { display: flex; flex-direction: column; gap: .75rem; }
.search-result-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--border-radius-lg); padding: 1.25rem; box-shadow: var(--shadow-sm); }
.search-result-header { display: flex; gap: .5rem; margin-bottom: .5rem; }
.search-result-title { font-size: 1.0625rem; font-weight: 600; margin-bottom: .375rem; }
.search-result-excerpt { font-size: .875rem; color: var(--text-secondary); margin-bottom: .75rem; }

/* --- Accessibility --- */
:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }

/* --- Print --- */
@media print {
    .sidebar, .topbar, .app-footer, .btn, .search-bar, .filters-bar { display: none !important; }
    .app-main { margin-left: 0 !important; }
    .app-content { max-width: 100%; padding: 0; }
    body { background: #fff; color: #000; }
}

/* --- SVG icons --- */
.icon { display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; flex-shrink: 0; }

/* ============================================================
   STATUS DE IMPLEMENTAÇÃO (sidebar + dashboard)
   ============================================================ */

/* --- Sidebar: bolinha verde/cinza no fim do link --- */
.sidebar-link { position: relative; }
.sidebar-link .sidebar-status {
    margin-left: auto;
    width: 8px; height: 8px; border-radius: 50%;
    flex-shrink: 0;
    transition: transform .15s;
}
.sidebar-link.is-ready .sidebar-status {
    background: var(--color-success);
    box-shadow: 0 0 0 3px rgba(22,163,74,.22);
}
.sidebar-link.is-soon .sidebar-status {
    background: rgba(255,255,255,.25);
}
.sidebar-link.is-soon { opacity: .65; }
.sidebar-link.is-soon:hover { opacity: 1; }
.sidebar-link.is-ready:hover .sidebar-status { transform: scale(1.25); }

/* --- Dashboard: resumo + badges --- */
.dashboard-summary {
    display: flex; gap: .5rem; flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.dash-pill {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .375rem .875rem; border-radius: 999px;
    font-size: .8125rem; font-weight: 600;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
}
.dash-pill .dash-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--text-tertiary);
    flex-shrink: 0;
}
.dash-pill--ready {
    color: var(--color-success);
    border-color: var(--color-success);
    background: var(--color-success-light);
}
.dash-pill--ready .dash-dot {
    background: var(--color-success);
    box-shadow: 0 0 0 3px rgba(22,163,74,.22);
}

/* Dashboard cards */
.dashboard-card { position: relative; overflow: hidden; }
.dashboard-card-badge {
    position: absolute; top: .625rem; right: .625rem;
    display: inline-flex; align-items: center; gap: .25rem;
    padding: .1875rem .5rem; border-radius: 999px;
    font-size: .6875rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .04em;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    line-height: 1;
    z-index: 2;
}
.dashboard-card-badge .icon { width: 12px; height: 12px; }
.dashboard-card.is-ready .dashboard-card-badge {
    color: var(--color-success);
    border-color: var(--color-success);
    background: var(--color-success-light);
}
.dashboard-card.is-soon { opacity: .68; }
.dashboard-card.is-soon:hover { opacity: 1; }

/* Faixa lateral verde nos cards prontos */
.dashboard-card.is-ready::before {
    content: ''; position: absolute; top: 0; left: 0; bottom: 0;
    width: 4px; background: var(--color-success);
    z-index: 1;
}

/* ============================================================
   FORM — UPLOAD DE ARQUIVO (admin)
   ============================================================ */

/* Linha "Arquivo atual" (mostrada quando editando) */
.form-current-file {
    display: flex; align-items: center; gap: .5rem;
    padding: .625rem .875rem;
    background: var(--color-primary-light);
    border: 1px solid var(--color-primary);
    border-radius: var(--border-radius);
    font-size: .8125rem;
    color: var(--text-primary);
    margin-bottom: .75rem;
    flex-wrap: wrap;
}
.form-current-file > .icon { color: var(--color-primary); flex-shrink: 0; }
.form-current-file > span { color: var(--text-secondary); }
.form-current-file a {
    color: var(--color-primary);
    font-weight: 600;
    text-decoration: underline;
    word-break: break-all;
}

/* Dropzone */
.form-file-zone {
    display: block;
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem 1rem;
    text-align: center;
    background: var(--bg-hover);
    transition: border-color .15s, background .15s;
    cursor: pointer;
    position: relative;
    margin: 0;
}
.form-file-zone:hover {
    border-color: var(--color-primary);
    background: var(--bg-card);
}
.form-file-zone.is-dragover {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}
.form-file-zone input[type="file"] {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    opacity: 0; cursor: pointer;
}
.form-file-zone-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 48px; height: 48px; border-radius: 50%;
    background: var(--bg-card);
    color: var(--text-secondary);
    margin-bottom: .5rem;
    border: 1px solid var(--border-color);
}
.form-file-zone-icon .icon { width: 24px; height: 24px; }
.form-file-zone-text {
    font-size: .9375rem;
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.4;
}
.form-file-zone-hint {
    font-size: .75rem;
    color: var(--text-tertiary);
    margin-top: .25rem;
}
.form-file-zone-name {
    display: none;
    align-items: center; gap: .375rem;
    font-size: .8125rem;
    color: var(--color-success);
    font-weight: 600;
    margin-top: .625rem;
    padding: .375rem .75rem;
    background: var(--color-success-light);
    border-radius: 999px;
    border: 1px solid var(--color-success);
    max-width: 100%;
    word-break: break-all;
}
.form-file-zone.has-file .form-file-zone-name { display: inline-flex; }
.form-file-zone.has-file .form-file-zone-icon {
    background: var(--color-success-light);
    color: var(--color-success);
    border-color: var(--color-success);
}

/* Divisor "OU cole uma URL externa" */
.form-divider-or {
    text-align: center;
    font-size: .6875rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: .1em;
    margin: 1rem 0 .75rem;
    position: relative;
    font-weight: 700;
}
.form-divider-or::before,
.form-divider-or::after {
    content: '';
    position: absolute; top: 50%;
    width: calc(50% - 60px);
    height: 1px;
    background: var(--border-color);
}
.form-divider-or::before { left: 0; }
.form-divider-or::after  { right: 0; }

/* ============================================================
   ANEXOS NA LISTAGEM (admin) — badges mini
   ============================================================ */
.anx-listagem {
    display: inline-flex; align-items: center;
    gap: .25rem; flex-wrap: wrap;
}
.anx-mini {
    display: inline-flex; align-items: center; justify-content: center;
    padding: .1875rem .4375rem;
    border-radius: 4px;
    font-size: .625rem; font-weight: 800;
    color: #fff;
    letter-spacing: .04em;
    line-height: 1;
    min-width: 36px;
    text-decoration: none;
    font-family: var(--font-mono);
    transition: transform .1s, opacity .15s;
}
.anx-mini:hover {
    transform: translateY(-1px);
    text-decoration: none; opacity: .9;
}
.anx-mini--red    { background: #DC2626; }
.anx-mini--blue   { background: #2563EB; }
.anx-mini--green  { background: #16A34A; }
.anx-mini--orange { background: #EA580C; }
.anx-mini--amber  { background: #D97706; }
.anx-mini--purple { background: #7C3AED; }
.anx-mini--cyan   { background: #0891B2; }
.anx-mini--pink   { background: #DB2777; }
.anx-mini--rose   { background: #E11D48; }
.anx-mini--gray   { background: #64748B; }
.anx-mini--more {
    background: var(--bg-hover); color: var(--text-secondary);
    border: 1px solid var(--border-color);
    cursor: default;
}
.anx-mini--more:hover { transform: none; }

/* Tag de "legado" ao lado do badge único */
.anx-legado-tag {
    display: inline-flex; align-items: center; gap: .1875rem;
    font-size: .625rem; font-weight: 700;
    color: var(--color-warning);
    background: var(--color-warning-light);
    padding: .125rem .375rem;
    border-radius: 4px;
    text-transform: uppercase; letter-spacing: .04em;
    line-height: 1;
}
.anx-legado-tag .icon { width: 11px; height: 11px; }

/* ============================================================
   AUDITORIA — rodapé "criado/modificado por" no form admin
   ============================================================ */
.auditoria-rodape {
    display: flex; flex-direction: column; gap: .375rem;
    background: var(--bg-hover);
    border-left: 3px solid var(--color-primary);
    padding: .625rem .875rem;
    border-radius: var(--border-radius-sm);
    font-size: .8125rem;
    color: var(--text-secondary);
}
.auditoria-linha {
    display: flex; flex-wrap: wrap; gap: .375rem;
    align-items: baseline;
}
.auditoria-label {
    color: var(--text-tertiary);
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    font-weight: 700;
    min-width: 140px;
}
.auditoria-rodape strong {
    color: var(--text-primary);
    font-weight: 600;
}
.auditoria-data {
    font-size: .75rem;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
}

/* ============================================================
   HISTÓRICO DE AUDITORIA — timeline + diff
   ============================================================ */
.historico-vazio {
    display: flex; align-items: center; gap: .5rem;
    padding: .75rem 1rem;
    background: var(--bg-hover);
    border-radius: var(--border-radius-sm);
    color: var(--text-tertiary);
    font-size: .8125rem;
    margin-top: 1rem;
}

.historico-section {
    margin-top: 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
}
.historico-summary {
    display: flex; align-items: center; gap: .5rem;
    padding: .75rem 1rem;
    cursor: pointer;
    background: var(--bg-hover);
    list-style: none;
    user-select: none;
    border-bottom: 1px solid transparent;
    transition: background .15s, border-color .15s;
}
.historico-summary::-webkit-details-marker,
.historico-summary::marker { display: none; content: ''; }
.historico-section[open] .historico-summary {
    border-bottom-color: var(--border-color);
}
.historico-summary:hover { background: var(--bg-body); }
.historico-summary strong { font-size: .9375rem; color: var(--text-primary); flex: 1; }

.historico-timeline {
    list-style: none; padding: 1rem;
    margin: 0;
    display: flex; flex-direction: column; gap: .75rem;
    counter-reset: histlog;
}
.historico-item {
    position: relative;
    padding: .75rem .875rem .75rem 2rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--text-tertiary);
    border-radius: var(--border-radius-sm);
}
.historico-item--success { border-left-color: var(--color-success); }
.historico-item--primary { border-left-color: var(--color-primary); }
.historico-item--danger  { border-left-color: var(--color-danger); }
.historico-item--warning { border-left-color: var(--color-warning); }

.historico-item::before {
    content: '';
    position: absolute; left: -8px; top: .875rem;
    width: 14px; height: 14px; border-radius: 50%;
    background: var(--bg-card); border: 3px solid var(--text-tertiary);
}
.historico-item--success::before { border-color: var(--color-success); }
.historico-item--primary::before { border-color: var(--color-primary); }
.historico-item--danger::before  { border-color: var(--color-danger); }
.historico-item--warning::before { border-color: var(--color-warning); }

.historico-item-head {
    display: flex; flex-wrap: wrap; align-items: center;
    gap: .375rem .625rem;
    font-size: .8125rem;
}
.historico-acao {
    font-size: .6875rem !important;
    text-transform: uppercase;
    letter-spacing: .04em;
    font-weight: 700;
}
.historico-data {
    color: var(--text-tertiary);
    font-family: var(--font-mono);
    font-size: .75rem;
}
.historico-usuario { color: var(--text-secondary); }
.historico-usuario strong { color: var(--text-primary); }
.historico-tag-legado {
    background: var(--color-warning-light);
    color: var(--color-warning);
    padding: .0625rem .375rem;
    border-radius: 4px;
    font-size: .625rem;
    font-weight: 700;
    margin-left: .25rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.historico-diff {
    list-style: none; padding: 0;
    margin: .625rem 0 0;
    display: flex; flex-direction: column; gap: .25rem;
    font-size: .8125rem;
    border-top: 1px dashed var(--border-color);
    padding-top: .5rem;
}
.historico-diff-linha {
    display: flex; flex-wrap: wrap; align-items: center;
    gap: .375rem;
    line-height: 1.5;
}
.historico-diff-campo {
    background: var(--bg-hover);
    color: var(--color-primary);
    font-weight: 600;
    padding: .0625rem .375rem;
    border-radius: 3px;
    font-size: .75rem;
}
.historico-diff-antes {
    background: var(--color-danger-light);
    color: var(--color-danger);
    padding: .0625rem .375rem;
    border-radius: 3px;
    text-decoration: line-through;
    text-decoration-color: rgba(220,38,38,.4);
}
.historico-diff-depois {
    background: var(--color-success-light);
    color: var(--color-success);
    padding: .0625rem .375rem;
    border-radius: 3px;
    font-weight: 600;
}
.historico-diff em { color: var(--text-tertiary); font-style: italic; }
.historico-diff .icon { color: var(--text-tertiary); flex-shrink: 0; }

/* ============================================================
   MODAL DE HISTÓRICO DE AUDITORIA (global)
   ============================================================ */
.historico-modal {
    border: 0; padding: 0; background: transparent;
    max-width: min(720px, calc(100vw - 2rem));
    width: 100%;
    max-height: calc(100vh - 4rem);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(15,23,42,.25);
    color: var(--text-primary);
}
.historico-modal::backdrop {
    background: rgba(15,23,42,.55);
    backdrop-filter: blur(2px);
}
.historico-modal[open] {
    animation: historico-modal-in .2s ease-out;
}
@keyframes historico-modal-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.historico-modal-box {
    background: var(--bg-card);
    display: flex; flex-direction: column;
    max-height: calc(100vh - 4rem);
    border-radius: var(--border-radius-lg);
}
.historico-modal-head {
    display: flex; align-items: center; gap: .75rem;
    padding: .875rem 1.125rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-hover);
}
.historico-modal-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--color-primary-light); color: var(--color-primary);
    flex-shrink: 0;
}
.historico-modal-head h2 {
    flex: 1; margin: 0;
    font-size: 1rem; font-weight: 700; color: var(--text-primary);
    line-height: 1.3;
}
.historico-modal-close {
    width: 32px; height: 32px; border-radius: 50%;
    border: 0; background: transparent;
    color: var(--text-secondary); cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: background .15s, color .15s, transform .15s;
}
.historico-modal-close:hover {
    background: var(--color-danger); color: #fff; transform: rotate(90deg);
}

.historico-modal-body {
    padding: 1rem 1.125rem;
    overflow-y: auto;
    flex: 1;
}
.historico-modal-body .historico-section {
    margin-top: 0;
    border: 0;
}
.historico-modal-body .historico-summary {
    display: none; /* já abre direto no modal — não precisa de toggle */
}
.historico-modal-body .historico-timeline {
    padding: 0;
}

.historico-modal-foot {
    padding: .75rem 1.125rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-hover);
    display: flex; justify-content: flex-end;
}

.historico-loading {
    display: flex; align-items: center; justify-content: center;
    padding: 2rem;
    color: var(--text-tertiary);
    font-size: .875rem;
}

@media (max-width: 600px) {
    .historico-modal {
        max-width: 100%;
        max-height: 100vh; height: 100vh;
        border-radius: 0;
    }
    .historico-modal-box { border-radius: 0; max-height: 100vh; }
}

/* ============================================================
   AÇÕES — botões na coluna "Ações" sempre em linha
   ============================================================ */
.acoes-row {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    flex-wrap: nowrap;
    white-space: nowrap;
}
.acoes-row > form {
    display: inline-flex;
    margin: 0;
}
.acoes-row .btn {
    padding: .375rem .5rem;     /* compacto pra caber 3+ ícones */
    line-height: 1;
}
.acoes-row .btn .icon {
    flex-shrink: 0;
}

/* ============================================================
   MODAL DE HISTÓRICO — centralização forçada
   ============================================================ */
.historico-modal {
    /* <dialog> nativo: usa inset+margin pra centralizar de forma
       confiável independente de overflow do body */
    inset: 0 !important;
    margin: auto !important;
    position: fixed;
}
