/*
 * Portal MBike: estilo novo (baseado no SAC) e modo escuro.
 *
 * O header.php define, antes de carregar os estilos:
 *   html[data-style="new" | "classic"]  -> estilo escolhido (padrão: new)
 *   html[data-theme="light" | "dark"]   -> modo escuro (só tem efeito no estilo novo)
 *   html.ui-ready                       -> a página já foi adaptada ao estilo novo (define UI_READY)
 *
 * Topo, menu e moldura do conteúdo mudam em todas as páginas.
 * O interior do conteúdo só muda nas páginas com html.ui-ready; as demais seguem com o visual
 * atual dentro de um card claro, inclusive no modo escuro, até serem adaptadas.
 */

html[data-style="new"] {
    --bg: #f2f4f8;
    --card: #ffffff;
    --card-2: #f7f8fb;
    --border: #e5e8ef;
    --text: #1d2233;
    --muted: #7a8196;
    --primary: #3557f5;
    --primary-soft: #e9edff;
    --danger: #e5484d;
    --danger-soft: #fdecec;
    --warn: #f08c00;
    --warn-soft: #fff3e0;
    --success: #1f9d61;
    --success-soft: #e5f6ee;
    --badge: #e8457c;
    --shadow: 0 1px 2px rgba(20, 30, 60, .06);
    --shadow-pop: 0 10px 34px rgba(20, 30, 60, .16);
    --font: 'Inter', -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    --header-h: 60px;
    --menu-w: 250px;
    --menu-rail: 72px;
}

html[data-style="new"][data-theme="dark"] {
    --bg: #11141c;
    --card: #1a1e29;
    --card-2: #222736;
    --border: #2c3243;
    --text: #e8eaf2;
    --muted: #9198ad;
    --primary: #6f87ff;
    --primary-soft: #26305a;
    --danger: #ff6b6f;
    --danger-soft: #3d2226;
    --warn: #ffa94d;
    --warn-soft: #3b2e1d;
    --success: #3ccf8e;
    --success-soft: #1c3a2d;
    --shadow: none;
    --shadow-pop: 0 10px 34px rgba(0, 0, 0, .45);
}

/* Campos nativos escuros só nas páginas adaptadas; nas demais o conteúdo continua claro (R33) */
html[data-style="new"][data-theme="dark"].ui-ready { color-scheme: dark; }

/* ---------------- Botões de estilo e tema (os dois estilos) ---------------- */

#header .ui-toggles { display: flex; align-items: center; gap: 6px; height: 100%; }

/* Clique único (CLICK_LOCK no header.php): elemento aguardando a resposta do servidor (os dois estilos) */
html.click-lock .is-busy { opacity: .55; cursor: progress !important; }
html.click-lock .is-busy:hover { filter: none; }

#header .ui-btn {
    margin: 0; padding: 0; width: 35px; height: 30px; border: none; border-radius: 5px;
    background: #ddd; color: #111; font-size: 15px; line-height: 1; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; box-shadow: none;
}
#header .ui-btn:hover { background: #fff; }
#header .ui-btn:focus { outline: none; box-shadow: none; }

#header .ui-theme .fa-sun { display: none; }
html[data-theme="dark"] #header .ui-theme .fa-sun { display: inline-block; }
html[data-theme="dark"] #header .ui-theme .fa-moon { display: none; }

/* Logo antigo no clássico; logo novo (preto no claro, branco no escuro) no estilo novo */
#header .logos .logo-new-black,
#header .logos .logo-new-white { display: none; }

.ui-new-only { display: none; }
html[data-style="new"] .ui-new-only { display: block; }

/* Estilo clássico: botões à direita, como os demais itens; modo escuro não se aplica */
html:not([data-style="new"]) #header .ui-toggles { float: right; padding-right: 20px; }
html:not([data-style="new"]) #header .ui-theme { display: none; }

/* ---------------- Base do estilo novo ---------------- */

html[data-style="new"] body { background: var(--bg); }

/* ---------------- Barra superior ---------------- */

html[data-style="new"] #header {
    height: var(--header-h); display: flex; align-items: center; gap: 8px; padding: 0 18px 0 10px;
    background: var(--card); color: var(--text); border-bottom: 1px solid var(--border); box-shadow: var(--shadow);
    font-family: var(--font); font-size: 14px;
}
html[data-style="new"] #header > div { float: none; height: auto; padding: 0; }

html[data-style="new"] #header .icon-open-menu { order: 1; }
html[data-style="new"] #header .logos { order: 2; margin-right: auto; display: flex; align-items: center; }
html[data-style="new"] #header .macros { order: 3; }
html[data-style="new"] #header .notification { order: 4; }
html[data-style="new"] #header .ui-toggles { order: 5; }
html[data-style="new"] #header .usuario { order: 6; }

html[data-style="new"] #header .icon-open-menu i {
    width: 38px; height: 38px; padding: 0; border-radius: 9px; font-size: 17px; color: var(--muted);
    display: flex; align-items: center; justify-content: center;
}
html[data-style="new"] #header .icon-open-menu i:hover { background: var(--card-2); color: var(--text); }

html[data-style="new"] #header .logos img { max-height: 32px; margin-left: 6px; }
html[data-style="new"] #header .logos .logo-classic { display: none; }
html[data-style="new"] #header .logos .logo-new-black { display: block; }
html[data-style="new"][data-theme="dark"] #header .logos .logo-new-black { display: none; }
html[data-style="new"][data-theme="dark"] #header .logos .logo-new-white { display: block; }

html[data-style="new"] #header .macros { display: flex; align-items: center; gap: 5px; margin-right: 6px; }
html[data-style="new"] #header .macros div {
    width: 26px; height: 26px; margin: 0; border-radius: 7px; color: #fff;
    font-family: var(--font); font-size: 11px; font-weight: 700;
}

html[data-style="new"] #header .ui-btn,
html[data-style="new"] #header .notification .fa-bell {
    width: 38px; height: 38px; border-radius: 9px; font-size: 16px;
    background: transparent; color: var(--muted); border: 1px solid transparent;
}
html[data-style="new"] #header .ui-btn:hover,
html[data-style="new"] #header .notification .fa-bell:hover { background: var(--card-2); color: var(--text); }

html[data-style="new"] #header .notification { display: flex; align-items: center; position: relative; }
html[data-style="new"] #header .notification .total {
    top: 3px; left: 22px; width: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
    background: var(--badge); color: #fff; font-size: 10px; font-weight: 700;
}

html[data-style="new"] #notification-list {
    top: calc(100% + 10px); right: 0; width: 380px; height: auto; max-height: 440px; padding: 6px 12px 12px;
    background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 12px;
    box-shadow: var(--shadow-pop); cursor: default;
}
html[data-style="new"] #notification-list h4 {
    margin: 10px 4px 12px; font-size: 11px; letter-spacing: .5px; color: var(--muted); text-transform: uppercase;
}
html[data-style="new"] #notification-list .separate {
    background: var(--card-2); color: var(--text); font-size: 13px; padding: 10px 12px; border-radius: 9px; margin-bottom: 8px;
}
html[data-style="new"] #notification-list .active { border-left: 3px solid var(--danger); }
html[data-style="new"] #notification-list .date { color: var(--muted); font-size: 11px; }
html[data-style="new"] #notification-list::-webkit-scrollbar { width: 6px; }
html[data-style="new"] #notification-list::-webkit-scrollbar-thumb { -webkit-box-shadow: none; background: var(--border); border-radius: 6px; }
html[data-style="new"] #notification-list::-webkit-scrollbar-track { -webkit-box-shadow: none; }

html[data-style="new"] #header .usuario { display: flex; align-items: center; min-width: 0; margin-left: 4px; color: var(--text); }
html[data-style="new"] #header .usuario .usuario-info {
    height: 38px; align-items: center; padding: 0 4px 0 2px; border-radius: 20px;
    background: var(--card-2); border: 1px solid var(--border); font-size: 13px; font-weight: 600;
}
html[data-style="new"] #header .usuario .usuario-info:hover { border-color: var(--primary); }
html[data-style="new"] #header .usuario .fa-user {
    margin: 0 8px 0 4px; padding: 0; width: 28px; height: 28px; border-radius: 50%; font-size: 13px;
    display: flex; align-items: center; justify-content: center; background: var(--primary-soft); color: var(--primary);
}
html[data-style="new"] #header .usuario span { line-height: 1; }
html[data-style="new"] #header .usuario .fa-sort-down { margin: -5px 0 0; padding: 0 10px; font-size: 13px; color: var(--muted); }

html[data-style="new"] #header #usuario-menu {
    top: calc(100% + 8px); left: auto; right: 0; width: 210px; padding: 6px;
    background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-pop);
}
html[data-style="new"] #header #usuario-menu .opcao { padding: 9px 12px; border-radius: 8px; font-size: 13px; }
html[data-style="new"] #header #usuario-menu .opcao:hover { background: var(--card-2); }
html[data-style="new"] #header #usuario-menu .opcao i { width: 18px; color: var(--muted); font-size: 13px; }

/* ---------------- Menu lateral ---------------- */

html[data-style="new"] #menu {
    top: var(--header-h); height: calc(100vh - var(--header-h)); width: var(--menu-w);
    padding: 14px 12px 40px; overflow-x: hidden; cursor: default;
    background: var(--card); color: var(--text); border-right: 1px solid var(--border);
    font-family: var(--font); font-size: 14px; transition: width .15s, transform .2s;
}
html[data-style="new"] #menu::-webkit-scrollbar { width: 6px; }
html[data-style="new"] #menu::-webkit-scrollbar-thumb { -webkit-box-shadow: none; background: var(--border); border-radius: 6px; }
html[data-style="new"] #menu::-webkit-scrollbar-track { -webkit-box-shadow: none; }

html[data-style="new"] #menu .opcao {
    display: flex; align-items: center; gap: 12px; position: relative; margin-bottom: 2px; padding: 9px 12px;
    border-top: none; border-radius: 9px; line-height: 1.3; white-space: nowrap;
    color: var(--muted); font-weight: 500; opacity: 1; cursor: pointer;
}
html[data-style="new"] #menu .opcao:hover { background: var(--card-2); color: var(--text); }
html[data-style="new"] #menu .opcao span { float: none; flex-shrink: 0; width: 20px; margin: 0; display: flex; justify-content: center; }
html[data-style="new"] #menu .opcao span i {
    width: auto; height: auto; border: none; border-radius: 0; font-size: 16px; color: inherit; display: inline-block;
}
html[data-style="new"] #menu .opcao .fa-angle-down { position: static; margin-left: auto; font-size: 14px; color: var(--muted); }

html[data-style="new"] #menu .opcao.active { background: var(--card-2); color: var(--text); font-weight: 600; }
html[data-style="new"] #menu .opcao.active::before {
    content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--warn);
}
html[data-style="new"] #menu .sub-opcoes.active { background: transparent; }

html[data-style="new"] #menu .sub-opcoes { margin-left: 21px; padding-left: 9px; border-left: 1px solid var(--border); }
html[data-style="new"] #menu .sub-opcoes.open-submenu { margin-bottom: 6px; padding-bottom: 4px; }
html[data-style="new"] #menu .sub-opcao {
    padding: 6px 10px; border-radius: 7px; line-height: 1.35; font-size: 13px; color: var(--muted); opacity: 1; cursor: pointer;
}
html[data-style="new"] #menu .sub-opcao:hover { background: var(--card-2); color: var(--text); }
html[data-style="new"] #menu .sub-opcao span { display: none; }
html[data-style="new"] #menu .link:hover { text-decoration: none; }

/* Menu recolhido no computador: só os ícones (o nome aparece ao passar o mouse) */
@media only screen and (min-width: 1001px) {
    html[data-style="new"] #menu.open-menu { width: var(--menu-rail) !important; }
    html[data-style="new"] #menu.open-menu .opcao { justify-content: center; gap: 0; padding: 10px 0; font-size: 0; }
    html[data-style="new"] #menu.open-menu .opcao .fa-angle-down,
    html[data-style="new"] #menu.open-menu .sub-opcoes { display: none; }
}

/* ---------------- Moldura do conteúdo (todas as páginas) ---------------- */

html[data-style="new"] #content {
    margin: calc(var(--header-h) + 24px) 28px 24px calc(var(--menu-w) + 28px);
    padding: 28px; border-radius: 14px; border: 1px solid #e5e8ef;
    background: #fff; box-shadow: 0 1px 2px rgba(20, 30, 60, .06);
    transition: margin .15s;
}
html[data-style="new"] #content.content-full-width {
    margin: calc(var(--header-h) + 24px) 28px 24px calc(var(--menu-rail) + 28px) !important;
}
html[data-style="new"] #content.no-margin { margin-top: 0 !important; }
html[data-style="new"] #content.background-none { border-color: transparent; }

/* ---------------- Mensagens do portal (todas as páginas) ---------------- */

html[data-style="new"] #main_message { top: calc(var(--header-h) + 16px); font-family: var(--font); }
html[data-style="new"] #main_message > div {
    width: auto; margin: 0; padding: 12px 16px; border-radius: 10px; line-height: 1.5; font-size: 13px; box-shadow: var(--shadow-pop);
}
html[data-style="new"] #main_message .success { background: var(--success-soft); color: var(--success); border: 1px solid var(--success); }
html[data-style="new"] #main_message .error { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger); }

/* ---------------- Páginas adaptadas (html.ui-ready) ---------------- */

html[data-style="new"].ui-ready body { font-family: var(--font); font-size: 14px; color: var(--text); }
html[data-style="new"].ui-ready #content {
    background: var(--card); color: var(--text); border-color: var(--border); box-shadow: var(--shadow);
}

html[data-style="new"].ui-ready input:not([type="checkbox"]):not([type="radio"]),
html[data-style="new"].ui-ready select,
html[data-style="new"].ui-ready textarea {
    background-color: var(--card); color: var(--text); border-color: var(--border);
    border-radius: 8px; font-family: var(--font); font-size: 14px;
}
html[data-style="new"].ui-ready input:focus,
html[data-style="new"].ui-ready select:focus,
html[data-style="new"].ui-ready textarea:focus {
    background-color: var(--card); color: var(--text); border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}

/* Títulos de seção, botões e tabelas das páginas adaptadas */
html[data-style="new"].ui-ready #content h2,
html[data-style="new"].ui-ready #content h3 { font-family: var(--font); color: var(--text); letter-spacing: -.2px; }
html[data-style="new"].ui-ready #content h2 { font-size: 17px; font-weight: 700; }
html[data-style="new"].ui-ready #content h3 { font-size: 15px; font-weight: 600; }

html[data-style="new"].ui-ready #content button,
html[data-style="new"].ui-ready .main_popup button {
    height: 36px; padding: 0 16px; border-radius: 9px; border: 1px solid var(--primary);
    background: var(--primary); color: #fff; font-family: var(--font); font-size: 13px; font-weight: 600;
}
html[data-style="new"].ui-ready #content button:hover,
html[data-style="new"].ui-ready .main_popup button:hover { background: var(--primary); filter: brightness(.9); }
html[data-style="new"].ui-ready #content button.red-Button,
html[data-style="new"].ui-ready .main_popup button.red-Button { background: var(--danger); border-color: var(--danger); }
html[data-style="new"].ui-ready #content button[disabled],
html[data-style="new"].ui-ready .main_popup button[disabled] { opacity: .5; filter: none; cursor: default; }

html[data-style="new"].ui-ready table { font-family: var(--font); color: var(--text); }
html[data-style="new"].ui-ready table tr { border-bottom-color: var(--border); }
html[data-style="new"].ui-ready table th { color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
html[data-style="new"].ui-ready table tbody tr:hover > td { background: var(--card-2); }
html[data-style="new"].ui-ready table tfoot td { border-top-color: var(--border); }
html[data-style="new"].ui-ready table td.total span { background: var(--primary); }
/* Linhas zebradas com cor fixa no HTML gerado (ex.: search.php das listagens) */
html[data-style="new"].ui-ready table tr[style*="#f5f5f5"] { background: var(--card-2) !important; }
html[data-style="new"].ui-ready table tr[style*="#f9f9f9"] { background: var(--card-2) !important; }
html[data-style="new"].ui-ready table tr[style*="#ffffff"] { background: transparent !important; }
html[data-style="new"].ui-ready table tr[style*="solid #000"] { border-top-color: var(--text) !important; }

html[data-style="new"].ui-ready #titulo-divisao { font-family: var(--font); color: var(--text); font-size: 18px; font-weight: 700; }

/* Botão com cara de link (classe "clean" usada em Receitas/Programação) */
html[data-style="new"].ui-ready #content button.clean,
html[data-style="new"].ui-ready .main_popup button.clean {
    background: none; border-color: transparent; color: var(--primary); text-decoration: underline; padding: 0 6px;
}
html[data-style="new"].ui-ready #content button.clean:hover,
html[data-style="new"].ui-ready .main_popup button.clean:hover { background: none; filter: none; }

/* Formulários, chaves liga/desliga, upload, paginação e avisos das páginas adaptadas */
html[data-style="new"].ui-ready form { color: var(--text); }
html[data-style="new"].ui-ready .form-detail { border-bottom-color: var(--border); }

html[data-style="new"].ui-ready .switch_Button .slider { background-color: var(--border); }
html[data-style="new"].ui-ready .switch_Button input:checked + .slider { background-color: var(--primary); }

html[data-style="new"].ui-ready #upload_arquivos { outline: 2px dashed var(--border); border-radius: 12px; }
html[data-style="new"].ui-ready #upload_arquivos:hover,
html[data-style="new"].ui-ready .drag_and_drop_border { outline: 2px dashed var(--primary); box-shadow: none; }
html[data-style="new"].ui-ready #upload_arquivos .texto i { color: var(--primary); }

html[data-style="new"].ui-ready .paginacao { color: var(--text); }
html[data-style="new"].ui-ready #content .paginacao button {
    margin: 0 4px 0 0; min-width: 36px; padding: 0 12px; background: var(--card-2); color: var(--text); border-color: var(--border);
}
html[data-style="new"].ui-ready #content .paginacao button:hover { border-color: var(--primary); filter: none; }
html[data-style="new"].ui-ready #content .paginacao .active { background: var(--primary) !important; border-color: var(--primary); color: #fff; }

html[data-style="new"].ui-ready #content .error,
html[data-style="new"].ui-ready .main_popup .error { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); border-radius: 8px; }
html[data-style="new"].ui-ready #content .success,
html[data-style="new"].ui-ready .main_popup .success { background: var(--success-soft); border-color: var(--success); color: var(--success); border-radius: 8px; }

html[data-style="new"].ui-ready .main_popup .popup h1 { margin: 22px 40px 12px 0; font-size: 20px; font-weight: 700; letter-spacing: -.3px; }
html[data-style="new"].ui-ready .main_popup .popup .content > h1:first-child { margin-top: 0; }

html[data-style="new"].ui-ready #titulo-pagina { display: flex; align-items: center; gap: 14px; overflow: visible; font-family: var(--font); color: var(--text); }
html[data-style="new"].ui-ready #titulo-pagina div { float: none; }
html[data-style="new"].ui-ready #titulo-pagina .icone i {
    width: 46px; height: 46px; margin: 0; border-radius: 12px; font-size: 20px; background: var(--primary-soft); color: var(--primary);
}
html[data-style="new"].ui-ready #titulo-pagina .info { color: var(--muted); font-size: 12px; }
html[data-style="new"].ui-ready #titulo-pagina .nome { font-size: 22px; font-weight: 700; letter-spacing: -.3px; }

html[data-style="new"].ui-ready .main_popup { background: rgba(10, 14, 30, .45); }
html[data-style="new"].ui-ready .main_popup .popup {
    padding: 26px 28px; border-radius: 14px; border: 1px solid var(--border);
    background: var(--card); color: var(--text); box-shadow: var(--shadow-pop); font-family: var(--font);
}
html[data-style="new"].ui-ready .main_popup .popup .fa-times { top: 14px; right: 14px; padding: 8px; font-size: 18px; color: var(--muted); }
html[data-style="new"].ui-ready .main_popup .popup .fa-times:hover { color: var(--text); }
html[data-style="new"].ui-ready .main_popup .popup h2 { margin: 0 40px 18px 0; font-size: 18px; }

/* ---------------- Telas menores ---------------- */

@media only screen and (max-width: 1000px) {
    html[data-style="new"] { --header-h: 56px; }

    html[data-style="new"] #header { padding: 0 10px 0 4px; }
    html[data-style="new"] #header .logos img { max-height: 26px; margin: 0 0 0 4px; }

    html[data-style="new"] #menu { width: 270px; transform: translateX(-100%); }
    html[data-style="new"] #menu.open-menu { width: 270px !important; transform: none; box-shadow: var(--shadow-pop); }

    html[data-style="new"] #content { margin: calc(var(--header-h) + 14px) 12px 14px 12px; padding: 18px; }
    html[data-style="new"] #content.content-full-width { margin: calc(var(--header-h) + 14px) 12px 14px 12px !important; }
    html[data-style="new"] #content.no-margin { margin-top: 0 !important; }
}

/* ---------------- Impressão (R34) ---------------- */
/* Fica por último para vencer as margens do menu, inclusive as de tela menor. Imprime sempre claro. */

@media print {
    html[data-style="new"][data-theme],
    html[data-style="new"][data-theme].ui-ready {
        --bg: #ffffff; --card: #ffffff; --card-2: #f7f8fb; --border: #e5e8ef; --text: #1d2233; --muted: #7a8196;
        --primary: #3557f5; --primary-soft: #e9edff; --danger: #e5484d; --danger-soft: #fdecec;
        --warn: #f08c00; --warn-soft: #fff3e0; --success: #1f9d61; --success-soft: #e5f6ee; --shadow: none;
        color-scheme: light;
    }
    html[data-style="new"] body { background: #fff; }
    html[data-style="new"] #content,
    html[data-style="new"] #content.content-full-width,
    html[data-style="new"] #content.no-margin {
        margin: 0 !important; border: none; border-radius: 0; box-shadow: none !important;
    }
    /* Popups impressos (ex.: receita das bicicletas): sem a moldura de tela (borda, cantos e sombra) */
    html[data-style="new"] .main_popup,
    html[data-style="new"].ui-ready .main_popup { background: none !important; } /* vence a camada escura de tela das páginas adaptadas (R43) */
    html[data-style="new"] .main_popup .popup,
    html[data-style="new"].ui-ready .main_popup .popup {
        border: none !important; border-radius: 0 !important; box-shadow: none !important;
    }
}
