/*
 * AOGAMO application theme foundation.
 *
 * Theme styles are intentionally scoped to html.app-theme-enabled so screens
 * that have not opted in (including skill sheets) keep their existing look.
 */
html.app-theme-enabled {
    color-scheme: light;
    --app-bg: #f2f6fa;
    --app-header-bg: #ffffff;
    --app-surface: #ffffff;
    --app-surface-raised: #ffffff;
    --app-control-bg: #fbfdff;
    --app-text: #172033;
    --app-text-muted: #5b6b7f;
    --app-border: #d8e1eb;
    --app-border-strong: #bdcad8;
    --app-primary: #0b67a3;
    --app-primary-hover: #0f4c81;
    --app-on-primary: #ffffff;
    --app-link: #0b67a3;
    --app-focus-ring: #38a3d7;
    --app-focus-soft: rgba(56, 163, 215, 0.24);
    --app-secondary-action-bg: #e5f3fa;
    --app-secondary-action-hover: #d5ecf8;
    --app-secondary-action-text: #0b5a8e;
    --app-secondary-action-border: #6db9df;
    --app-shadow: rgba(15, 76, 129, 0.08);
    --app-overlay: rgba(15, 23, 42, 0.48);
    --app-danger-bg: #fff1f2;
    --app-danger-text: #a31836;
    --app-danger-border: #fda4af;
    --app-success-bg: #ecfdf3;
    --app-success-text: #166534;
    --app-success-border: #86efac;
    --app-warning-bg: #fffbeb;
    --app-warning-text: #92400e;
    --app-warning-border: #fcd34d;
    --app-code-bg: #0f172a;
    --app-code-text: #e2e8f0;
    --app-table-header: #3b414e;
    --app-table-header-text: #ffffff;
    --app-table-row: #ffffff;
    --app-table-row-alt: #f8fafc;
    --app-table-border: #d8e1eb;
    --sidebar-bg: #3b414e;
    --sidebar-submenu-bg: #343a46;
    --sidebar-hover: #4a5160;
    --sidebar-active: #00bbbb;
    --sidebar-active-marker: transparent;
    --sidebar-text: #ffffff;
    --sidebar-text-muted: #d6dde6;
}

html.app-theme-enabled[data-theme="dark"] {
    color-scheme: dark;
    --app-bg: #0f1723;
    --app-header-bg: #121c2a;
    --app-surface: #182638;
    --app-surface-raised: #213249;
    --app-control-bg: #101a28;
    --app-text: #dce6f0;
    --app-text-muted: #9fb0c2;
    --app-border: #41566f;
    --app-border-strong: #58718c;
    --app-primary: #1b5f84;
    --app-primary-hover: #23739e;
    --app-on-primary: #ffffff;
    --app-link: #59bcea;
    --app-focus-ring: #67c7ed;
    --app-focus-soft: rgba(103, 199, 237, 0.22);
    --app-secondary-action-bg: #23435a;
    --app-secondary-action-hover: #2b506b;
    --app-secondary-action-text: #d9f2ff;
    --app-secondary-action-border: #5ea8c7;
    --app-shadow: rgba(0, 0, 0, 0.28);
    --app-overlay: rgba(3, 8, 15, 0.68);
    --app-danger-bg: #3a1d25;
    --app-danger-text: #ffb4c2;
    --app-danger-border: #7d3444;
    --app-success-bg: #173528;
    --app-success-text: #9ee8bc;
    --app-success-border: #286044;
    --app-warning-bg: #3a2d16;
    --app-warning-text: #f5cd78;
    --app-warning-border: #735a28;
    --app-code-bg: #0a111c;
    --app-code-text: #dce7f1;
    --app-table-header: #111b29;
    --app-table-header-text: #e6eef6;
    --app-table-row: #1a2839;
    --app-table-row-alt: #1e2e41;
    --app-table-border: #526b86;
    --sidebar-bg: #1b344b;
    --sidebar-submenu-bg: #1f3a52;
    --sidebar-hover: #29465f;
    --sidebar-active: #1b5f87;
    --sidebar-active-marker: #49b4e5;
    --sidebar-text: #e3ebf3;
    --sidebar-text-muted: #aebdcd;
}

html.app-theme-enabled body {
    background: var(--app-bg);
    color: var(--app-text);
}

html.app-theme-enabled .header {
    background: var(--app-header-bg);
    border-bottom: 1px solid var(--app-border);
    box-shadow: 0 3px 12px var(--app-shadow);
}

html.app-theme-enabled .header_title span,
html.app-theme-enabled .profile .pr {
    color: var(--app-text);
}

html.app-theme-enabled .header-search input[type="text"] {
    border-bottom-color: var(--app-border);
    color: var(--app-text);
}

html.app-theme-enabled .header-search input[type="text"]:focus {
    border-bottom-color: var(--app-primary);
}

html.app-theme-enabled .header-search input[type="text"]::placeholder,
html.app-theme-enabled .header-search button[type="submit"] {
    color: var(--app-text-muted);
}

html.app-theme-enabled .header-search button[type="submit"]:hover {
    color: var(--app-primary);
}

html.app-theme-enabled .profile .card {
    background: var(--app-surface-raised);
    color: var(--app-text);
    border: 1px solid var(--app-border);
    box-shadow: 0 10px 28px var(--app-shadow);
}

html.app-theme-enabled .profile .card span {
    color: var(--app-text);
}

html.app-theme-enabled .profile .card button {
    border-color: var(--app-border);
    background: var(--app-control-bg);
    color: var(--app-text);
}

html.app-theme-enabled .profile .card button:hover {
    border-color: var(--app-primary);
    background: var(--app-primary);
    color: var(--app-on-primary);
}

html.app-theme-enabled .main-menu,
html.app-theme-enabled .menu-toggle-btn {
    background: var(--sidebar-bg);
    background-color: var(--sidebar-bg);
}

html.app-theme-enabled .main-menu {
    height: 100vh !important;
    height: 100dvh !important;
}

html.app-theme-enabled .main-menu .menu-item-has-submenu .submenu {
    background-color: var(--sidebar-submenu-bg);
}

html.app-theme-enabled .main-menu li > a,
html.app-theme-enabled .main-menu .nav-icon,
html.app-theme-enabled .menu-mobile-account .menu-mobile-email,
html.app-theme-enabled .menu-mobile-account .menu-mobile-role {
    color: var(--sidebar-text);
}

html.app-theme-enabled .main-menu li > a:hover {
    background-color: var(--sidebar-hover);
}

html.app-theme-enabled nav.main-menu li.active > a,
html.app-theme-enabled .main-menu a[aria-current="page"] {
    color: var(--sidebar-text);
    background-color: var(--sidebar-active);
    box-shadow: inset 3px 0 var(--sidebar-active-marker);
}

html.app-theme-enabled .menu-mobile-account .menu-mobile-role {
    color: var(--sidebar-text-muted);
}

.app-theme-switch {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px;
    border: 1px solid var(--app-border);
    border-radius: 9px;
    background: var(--app-control-bg);
    flex-shrink: 0;
}

.app-theme-switch button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-width: 0;
    min-height: 30px;
    margin: 0;
    padding: 5px 8px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--app-text-muted);
    box-shadow: none;
    font-family: 'Meiryo', sans-serif;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
}

.app-theme-switch button:hover {
    background: var(--app-surface-raised);
    color: var(--app-text);
}

.app-theme-switch button[aria-pressed="true"] {
    background: var(--app-primary);
    color: var(--app-on-primary) !important;
    box-shadow: 0 1px 5px var(--app-shadow), inset 0 0 0 1px var(--app-primary-hover);
}

.app-theme-switch button:focus-visible {
    outline: 3px solid var(--app-focus-soft);
    outline-offset: 1px;
}

.app-theme-switch svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.menu-theme-control {
    display: none !important;
}

.menu-theme-control-inner {
    padding: 0.8rem 1rem 0.9rem;
}

.menu-theme-control-label {
    display: block;
    margin-bottom: 0.55rem;
    color: var(--sidebar-text-muted);
    font-size: 12px;
}

.menu-theme-control .app-theme-switch {
    width: 100%;
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(0, 0, 0, 0.12);
}

.menu-theme-control .app-theme-switch button {
    flex: 1 1 0;
    color: var(--sidebar-text-muted);
}

.menu-theme-control .app-theme-switch button:hover,
.menu-theme-control .app-theme-switch button[aria-pressed="true"] {
    background: var(--sidebar-hover);
    color: var(--sidebar-text) !important;
}

@media screen and (max-width: 1100px) {
    .header .app-theme-switch .app-theme-switch-label {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }
}

html.app-theme-enabled.app-mobile-layout .menu-theme-control {
    display: block !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

@media print {
    .app-theme-switch,
    .menu-theme-control {
        display: none !important;
    }
}
