/* ===== PerfektMail safe theme overrides ===== */

:root {
  --pm-primary: #5E131B;
  --pm-primary-dark: #3F0C12;
  --pm-primary-light: #7A1B26;
  --pm-rose: #D9A3A8;
}

/* Przyciski główne */
.btn-primary,
button.btn-primary,
input.button.mainaction,
button.mainaction,
#rcmloginsubmit {
  background-color: var(--pm-primary) !important;
  border-color: var(--pm-primary) !important;
  color: #fff !important;
}

.btn-primary:hover,
button.btn-primary:hover,
input.button.mainaction:hover,
button.mainaction:hover,
#rcmloginsubmit:hover {
  background-color: var(--pm-primary-dark) !important;
  border-color: var(--pm-primary-dark) !important;
  color: #fff !important;
}

/* Lewy pasek aplikacji */
#taskmenu a.selected,
#taskmenu a:hover,
#taskmenu a:focus {
  background-color: var(--pm-primary) !important;
  color: #fff !important;
}

/* Ikony w lewym pasku */
#taskmenu a.selected:before,
#taskmenu a:hover:before,
#taskmenu a:focus:before {
  color: #fff !important;
}

/* Aktywna skrzynka/folder */
#mailboxlist li.selected > a,
#mailboxlist li.mailbox.selected > a,
ul.treelist li.selected > a,
ul.treelist li.selected > div > a {
  background-color: rgba(94, 19, 27, 0.22) !important;
  border-left-color: var(--pm-primary) !important;
}

/* Hover folderów */
#mailboxlist li > a:hover,
ul.treelist li > a:hover {
  background-color: rgba(94, 19, 27, 0.10) !important;
}

/* Zaznaczone wiadomości */
.listing li.selected,
.listing tbody tr.selected td,
.listing tr.selected td,
#messagelist tbody tr.selected td {
  background-color: rgba(94, 19, 27, 0.16) !important;
}

/* Hover wiadomości */
.listing li:hover,
.listing tbody tr:hover td,
#messagelist tbody tr:hover td {
  background-color: rgba(94, 19, 27, 0.06) !important;
}

/* Nie ruszaj kolorów tytułów maili */
#messagelist .subject,
#messagelist .subject a,
#messagelist .fromto,
#messagelist .date,
.messagelist td.subject span.subject,
.messagelist td.subject span.subject a {
  color: inherit !important;
}

/* Focus bez niebieskiego */
input:focus,
textarea:focus,
select:focus,
.form-control:focus,
.recipient-input.focus,
.tagedit-list[tabindex="-1"],
.multi-input > .content.focused {
  border-color: var(--pm-primary) !important;
  box-shadow: 0 0 0 0.15rem rgba(94, 19, 27, 0.25) !important;
}

/* Liczniki */
.count,
.unreadcount,
.badge,
.folderlist li .count,
.folderlist li.mailbox .unreadcount,
.folderlist li.mailbox.recent > a > .unreadcount {
  background-color: var(--pm-primary) !important;
  color: #fff !important;
}

/* Linki/ikony UI, ale nie treść wiadomości */
.toolbar a.button:hover,
.toolbar a.button.selected,
.toolbar a.button:focus,
a.button.icon:hover,
a.button.icon.selected,
button.icon:hover,
button.icon.selected,
.input-group a:focus,
.searchbar a.selected,
.popupmenu .listing li > a:not(.disabled):hover,
.popupmenu .listing li.selected {
  color: var(--pm-primary) !important;
}

/* Tła popup menu po hover */
.popupmenu .listing li > a:not(.disabled):hover,
.popupmenu .listing li.selected {
  background-color: var(--pm-primary) !important;
  color: #fff !important;
}

/* Bootstrap primary/info */
.bg-primary {
  background-color: var(--pm-primary) !important;
}

.text-primary,
.text-info,
a.text-primary,
a.text-info {
  color: var(--pm-primary) !important;
}

.border-primary {
  border-color: var(--pm-primary) !important;
}

/* Scrollbar */
::-webkit-scrollbar-thumb {
  background: var(--pm-primary) !important;
  border-radius: 8px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--pm-primary-light) !important;
}

/* Logo login */
body.task-login #logo,
#login-form #logo {
  display: block !important;
  width: fit-content !important;
  max-width: 90vw !important;
  height: auto !important;
  margin: 0 auto 24px auto !important;
  padding: 0 !important;
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

body.task-login #logo img,
#login-form #logo img {
  display: block !important;
  width: auto !important;
  height: auto !important;
  max-width: 340px !important;
  max-height: 120px !important;
  object-fit: contain !important;
  border: none !important;
  box-shadow: none !important;
}

/* Logo w menu */
#layout-menu #logo {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 58px !important;
  height: 58px !important;
  padding: 8px !important;
  margin: 0 !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  overflow: hidden !important;
}

#layout-menu #logo img {
  display: block !important;
  width: auto !important;
  height: auto !important;
  max-width: 38px !important;
  max-height: 38px !important;
  object-fit: contain !important;
}

/* Login box */
#login-form .box-inner {
  border-top: 4px solid var(--pm-primary) !important;
}

/* ===== PerfektMail blue leftovers fix ===== */

/* Dark mode scrollbar */
html.dark-mode {
  scrollbar-color: #5E131B #4d6066 !important;
}

/* Ikony typu Utwórz w lewym menu */
html.dark-mode #taskmenu .action-buttons a,
#taskmenu .action-buttons a {
  color: #D9A3A8 !important;
}

html.dark-mode #taskmenu .action-buttons a:hover,
#taskmenu .action-buttons a:hover {
  color: #fff !important;
  background-color: #5E131B !important;
}

/* Zaznaczone elementy w ciemnym trybie */
html.dark-mode .listing li.selected,
html.dark-mode .listing li.selected > a,
html.dark-mode .listing li.selected > div > a,
html.dark-mode .listing tr.selected td {
  color: #D9A3A8 !important;
  background-color: rgba(94, 19, 27, 0.28) !important;
}

/* Zaznaczony mail w ciemnym trybie */
html.dark-mode .messagelist tr:not(.flagged):not(.deleted).selected td.subject a,
html.dark-mode .messagelist tr:not(.flagged):not(.deleted).selected td.subject span.msgicon.status {
  color: #D9A3A8 !important;
}

/* Focus border zamiast jasnoniebieskiego */
html:not(.touch) .listing li > a:focus,
html:not(.touch) .listing.focus tbody tr.focused > td:first-child,
html:not(.touch) .listing.focus:not(.withselection) tbody tr.focused > td.selection + td {
  border-left: 2px solid #5E131B !important;
  outline: 0 !important;
}

/* Jasny tryb - niebieski przy zaznaczeniu/focus */
html:not(.dark-mode) .listing li.selected,
html:not(.dark-mode) .listing li.selected > a,
html:not(.dark-mode) .listing li.selected > div > a,
html:not(.dark-mode) .listing tr.selected td {
  background-color: rgba(94, 19, 27, 0.16) !important;
  color: inherit !important;
}

/* Licznik wiadomości */
#messagelistfooter .countdisplay,
#messagelistfooter input,
.pagenav input {
  border-color: #5E131B !important;
}




/* ===== Jedno logo logowania zależne od motywu ===== */

body.task-login #logo.pm-login-logo {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: auto !important;
    height: 110px !important;
    margin: 0 auto 24px !important;
    padding: 0 !important;
    background: none !important;
    border: 0 !important;
    box-shadow: none !important;
}

body.task-login #logo.pm-login-logo img {
    width: auto !important;
    height: auto !important;
    max-width: 340px !important;
    max-height: 110px !important;
    object-fit: contain !important;
}

/* Domyślnie jasny motyw */
body.task-login .pm-logo-color {
    display: block !important;
}

body.task-login .pm-logo-white {
    display: none !important;
}

/* Ciemny motyw Roundcube */
html.dark-mode body.task-login .pm-logo-color {
    display: none !important;
}

html.dark-mode body.task-login .pm-logo-white {
    display: block !important;
}

/* Ciemny motyw systemowy przed zalogowaniem */
@media (prefers-color-scheme: dark) {
    html:not(.light-mode) body.task-login .pm-logo-color {
        display: none !important;
    }

    html:not(.light-mode) body.task-login .pm-logo-white {
        display: block !important;
    }
}

/* Ręcznie ustawiony jasny motyw */
html.light-mode body.task-login .pm-logo-color {
    display: block !important;
}

html.light-mode body.task-login .pm-logo-white {
    display: none !important;
}


/* Ostateczne przełączanie logo login */
#logo.pm-login-logo .pm-logo-color {
    display: block !important;
}

#logo.pm-login-logo .pm-logo-white {
    display: none !important;
}

html.dark-mode #logo.pm-login-logo .pm-logo-color {
    display: none !important;
}

html.dark-mode #logo.pm-login-logo .pm-logo-white {
    display: block !important;
}

@media (prefers-color-scheme: dark) {
    html:not(.light-mode) #logo.pm-login-logo .pm-logo-color {
        display: none !important;
    }

    html:not(.light-mode) #logo.pm-login-logo .pm-logo-white {
        display: block !important;
    }
}

html.light-mode #logo.pm-login-logo .pm-logo-color {
    display: block !important;
}

html.light-mode #logo.pm-login-logo .pm-logo-white {
    display: none !important;
}


/* ===== Kolory linków i ikon w nagłówku wiadomości ===== */

#message-header .header-links a,
#message-header .header-summary a,
#message-header a.extwin,
#message-header a.rcmContactAddress {
    color: var(--pm-primary) !important;
}

/* Hover i focus */
#message-header .header-links a:hover,
#message-header .header-links a:focus,
#message-header .header-summary a:hover,
#message-header .header-summary a:focus,
#message-header a.extwin:hover,
#message-header a.extwin:focus,
#message-header a.rcmContactAddress:hover,
#message-header a.rcmContactAddress:focus {
    color: var(--pm-primary-light) !important;
}

/* Ikony generowane przez :before */
#message-header .header-links a:before,
#message-header a.extwin:before,
#message-header a.rcmaddcontact:before {
    color: var(--pm-primary) !important;
}

/* Hover ikon */
#message-header .header-links a:hover:before,
#message-header .header-links a:focus:before,
#message-header a.extwin:hover:before,
#message-header a.extwin:focus:before,
#message-header a.rcmaddcontact:hover:before,
#message-header a.rcmaddcontact:focus:before {
    color: var(--pm-primary-light) !important;
}

/* Dodaj kontakt — ukryty tekstowo, ale ikona ma właściwy kolor */
#message-header .rcmaddcontact {
    color: var(--pm-primary) !important;
}

/* Ciemny motyw */
html.dark-mode #message-header .header-links a,
html.dark-mode #message-header .header-summary a,
html.dark-mode #message-header a.extwin,
html.dark-mode #message-header a.rcmContactAddress,
html.dark-mode #message-header .header-links a:before,
html.dark-mode #message-header a.extwin:before,
html.dark-mode #message-header a.rcmaddcontact:before {
    color: var(--pm-rose) !important;
}

html.dark-mode #message-header .header-links a:hover,
html.dark-mode #message-header .header-links a:focus,
html.dark-mode #message-header .header-summary a:hover,
html.dark-mode #message-header .header-summary a:focus,
html.dark-mode #message-header a.extwin:hover,
html.dark-mode #message-header a.extwin:focus,
html.dark-mode #message-header .header-links a:hover:before,
html.dark-mode #message-header .header-links a:focus:before,
html.dark-mode #message-header a.extwin:hover:before,
html.dark-mode #message-header a.extwin:focus:before,
html.dark-mode #message-header a.rcmaddcontact:hover:before,
html.dark-mode #message-header a.rcmaddcontact:focus:before {
    color: #fff !important;
}

