/* EMU - Painel Administrativo - Customização de Cores */
/* Usa CSS custom properties do Django admin para suportar light e dark mode */

/* === VARIÁVEIS - LIGHT MODE === */
:root,
html[data-theme="light"],
[data-theme="light"] {
    --primary: #ef9032 !important;
    --primary-hover: #d67d1f;
    --secondary: #ef9032 !important;
    --accent: #ef9032 !important;
    --header-bg: #ef9032 !important;
    --header-link-color: #fff;
    --breadcrumbs-bg: #ef9032 !important;
    --breadcrumbs-fg: #fff;
    --breadcrumbs-link-fg: #fff;
    --link-fg: #8b4513 !important;
    --link-hover-color: #6b3410 !important;
    --link-selected-fg: #a0522d !important;
    --button-bg: #ef9032 !important;
    --button-hover-bg: #d67d1f !important;
    --default-button-bg: #ef9032 !important;
    --default-button-hover-bg: #d67d1f !important;
    --object-tools-bg: #ef9032 !important;
    --object-tools-hover-bg: #d67d1f !important;
    --body-fg: #333;
    --body-bg: #fff;
    --darkened-bg: #f8f8f8;
    --selected-row: #fff4e6;
    --hairline-color: #ddd;
    --border-color: #ccc;
}

/* === VARIÁVEIS - DARK MODE === */
@media (prefers-color-scheme: dark) {
    :root {
        --primary: #ef9032 !important;
        --primary-hover: #f5a856;
        --secondary: #ef9032 !important;
        --accent: #ef9032 !important;
        --header-bg: #ef9032 !important;
        --header-link-color: #fff;
        --breadcrumbs-bg: #c47228 !important;
        --breadcrumbs-fg: #fff;
        --breadcrumbs-link-fg: #fff;
        --link-fg: #f5a856 !important;
        --link-hover-color: #ffc080 !important;
        --link-selected-fg: #ef9032 !important;
        --button-bg: #ef9032 !important;
        --button-hover-bg: #f5a856 !important;
        --default-button-bg: #ef9032 !important;
        --default-button-hover-bg: #f5a856 !important;
        --object-tools-bg: #ef9032 !important;
        --object-tools-hover-bg: #d67d1f !important;
        --body-fg: #f7f7f7;
        --body-bg: #121212;
        --darkened-bg: #212121;
        --selected-row: #2e2000;
        --hairline-color: #333;
        --border-color: #444;
    }
}

/* Django 4.2+ usa [data-theme="dark"] com maior especificidade */
[data-theme="dark"] {
    --primary: #ef9032 !important;
    --primary-hover: #f5a856;
    --secondary: #ef9032 !important;
    --accent: #ef9032 !important;
    --header-bg: #ef9032 !important;
    --header-link-color: #fff;
    --breadcrumbs-bg: #c47228 !important;
    --breadcrumbs-fg: #fff;
    --breadcrumbs-link-fg: #fff;
    --link-fg: #f5a856 !important;
    --link-hover-color: #ffc080 !important;
    --link-selected-fg: #ef9032 !important;
    --button-bg: #ef9032 !important;
    --button-hover-bg: #f5a856 !important;
    --default-button-bg: #ef9032 !important;
    --default-button-hover-bg: #f5a856 !important;
    --object-tools-bg: #ef9032 !important;
    --object-tools-hover-bg: #d67d1f !important;
}

/* === HEADER === */
#header {
    background: var(--header-bg) !important;
}

#header *,
#header a:link,
#header a:visited,
#header a:hover {
    color: #fff !important;
}

/* Logo no header */
#site-name a {
    display: flex;
    align-items: center;
    text-decoration: none;
    line-height: 40px;
}

#site-name img {
    display: inline-block;
    vertical-align: middle;
    height: 40px;
    max-height: 40px;
    width: auto;
    margin-right: 10px;
}

/* === BREADCRUMBS === */
.breadcrumbs {
    background: var(--breadcrumbs-bg) !important;
    color: var(--breadcrumbs-fg) !important;
}

.breadcrumbs a {
    color: var(--breadcrumbs-link-fg) !important;
}

/* === MODULE HEADERS === */
.module h2,
.module caption,
.inline-group h2 {
    background: var(--primary) !important;
    color: #fff !important;
}

/* === BOTÕES === */
.button,
input[type=submit],
input[type=button],
.submit-row input,
a.button {
    background: var(--button-bg) !important;
    border-color: var(--button-bg) !important;
    color: #fff !important;
}

.button:hover,
input[type=submit]:hover,
input[type=button]:hover,
.submit-row input:hover,
a.button:hover {
    background: var(--button-hover-bg) !important;
    border-color: var(--button-hover-bg) !important;
}

.button.default,
input[type=submit].default,
.submit-row input.default {
    background: var(--default-button-bg) !important;
    border-color: var(--default-button-bg) !important;
}

.button.default:hover,
input[type=submit].default:hover,
.submit-row input.default:hover {
    background: var(--default-button-hover-bg) !important;
    border-color: var(--default-button-hover-bg) !important;
}

/* === OBJECT TOOLS (botões de acção no topo) === */
.object-tools a {
    background: var(--object-tools-bg) !important;
    color: #fff !important;
}

.object-tools a:hover {
    background: var(--object-tools-hover-bg) !important;
}

/* === LINKS === */
/* Links gerais dentro do conteúdo */
a:link, a:visited {
    color: var(--link-fg);
}

a:hover {
    color: var(--link-hover-color);
}

/* Links nos módulos do dashboard */
.module ul li a {
    color: var(--link-fg) !important;
}

.module ul li a:hover {
    color: var(--link-hover-color) !important;
}

/* Addlink e changelink como botões nos módulos */
.module .addlink,
.module .changelink {
    background: var(--primary) !important;
    color: #fff !important;
    border: 1px solid var(--primary) !important;
    padding: 3px 10px !important;
    border-radius: 3px !important;
    text-decoration: none !important;
    display: inline-block !important;
}

.module .addlink:hover,
.module .changelink:hover {
    background: var(--primary-hover) !important;
    border-color: var(--primary-hover) !important;
    color: #fff !important;
}

/* === CHANGELIST === */
/* Filtros seleccionados */
#changelist-filter li.selected a {
    color: var(--primary) !important;
}

/* Links de acção inline */
.add-row a,
.inline-group .add-row a {
    color: var(--link-fg) !important;
}

/* Related widget links */
.related-widget-wrapper-link {
    color: var(--link-fg) !important;
}

/* Calendar/Clock links */
.calendarlink, .clocklink,
.calendarbox-shortcut, .clockbox-shortcut {
    color: var(--link-fg) !important;
}

/* Delete/Change links como texto */
a.deletelink {
    color: #ba2121 !important;
}

a.changelink {
    color: var(--link-fg) !important;
}

/* === SELECTED ROWS === */
.selected {
    background: var(--selected-row) !important;
}

/* === RECENT ACTIONS === */
.recent-actions-module h2 {
    background: var(--primary) !important;
    color: #fff !important;
}

/* Não colorir o corpo do módulo de acções recentes */
.recent-actions-module {
    background: var(--body-bg) !important;
}

/* === SUCCESS/ERROR MESSAGES === */
.success,
.messagelist .success {
    background: #d4edda !important;
    color: #155724 !important;
}

.warning,
.messagelist .warning {
    background: #fff3cd !important;
    color: #856404 !important;
}

.error,
.messagelist .error {
    background: #f8d7da !important;
    color: #721c24 !important;
}

.info,
.messagelist .info {
    background: #d1ecf1 !important;
    color: #0c5460 !important;
}

@media (prefers-color-scheme: dark) {
    .success, .messagelist .success {
        background: #1a3a1a !important;
        color: #a3d9a5 !important;
    }
    .warning, .messagelist .warning {
        background: #3a3000 !important;
        color: #f5d680 !important;
    }
    .error, .messagelist .error {
        background: #3a1a1a !important;
        color: #f5a5a5 !important;
    }
    .info, .messagelist .info {
        background: #1a2a3a !important;
        color: #a5d5e5 !important;
    }
}

[data-theme="dark"] .success, [data-theme="dark"] .messagelist .success {
    background: #1a3a1a !important;
    color: #a3d9a5 !important;
}
[data-theme="dark"] .warning, [data-theme="dark"] .messagelist .warning {
    background: #3a3000 !important;
    color: #f5d680 !important;
}
[data-theme="dark"] .error, [data-theme="dark"] .messagelist .error {
    background: #3a1a1a !important;
    color: #f5a5a5 !important;
}
[data-theme="dark"] .info, [data-theme="dark"] .messagelist .info {
    background: #1a2a3a !important;
    color: #a5d5e5 !important;
}

/* === TABULAR RESULTS === */
#result_list th {
    background: var(--darkened-bg);
}

#result_list td a {
    color: var(--link-fg);
}
