/**
 * SGPM Brand Styling for Roundcube Webmail
 * Société de Gestion et de Participations Mobilières
 */

:root {
    --sgpm-navy-900: #001a2e;
    --sgpm-navy-800: #002b49;
    --sgpm-navy-700: #0b1f3a;
    --sgpm-navy-600: #0f3460;
    --sgpm-navy-500: #1d4e89;
    --sgpm-gold-500: #c8a45c;
    --sgpm-gold-400: #dfbc68;
    --sgpm-gold-600: #936d24;
    --sgpm-gold-soft: #fbf8f1;
    --sgpm-surface: #ffffff;
    --sgpm-surface-muted: #f8fafc;
    --sgpm-border-soft: #e2e8f0;
    --sgpm-text-strong: #002b49;
    --sgpm-text-body: #334155;
    --sgpm-text-muted: #64748b;
}

/* ==========================================================================
   1. LOGIN PAGE (Matching Platform Login)
   ========================================================================== */
body.task-login {
    margin: 0 !important;
    padding: 1.5rem 0 !important;
    min-height: 100vh !important;
    box-sizing: border-box !important;
    overflow-y: auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background:
        radial-gradient(1100px 620px at 12% -10%, #1d4e89 0%, transparent 55%),
        radial-gradient(900px 520px at 95% 108%, #4a7fc1 0%, transparent 50%),
        linear-gradient(160deg, #001a2e 0%, #002b49 55%, #0b1f3a 100%) !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
    color: #1e293b !important;
}

body.task-login #layout {
    width: 100% !important;
    max-width: 980px !important;
    margin: auto !important;
    padding: 0 1rem !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    position: relative !important;
    background: transparent !important;
    box-shadow: none !important;
    box-sizing: border-box !important;
}

.sgpm-login-container {
    width: 100%;
    max-width: 960px;
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(200, 164, 92, 0.3);
    overflow: hidden;
    animation: sgpmFadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes sgpmFadeIn {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Left Column: Brand Signature */
.sgpm-login-aside {
    background: linear-gradient(155deg, #001a2e 0%, #002b49 55%, #0b1f3a 100%);
    padding: 3.25rem 2.75rem;
    color: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    border-right: 1px solid rgba(200, 164, 92, 0.25);
}

.sgpm-login-aside::before {
    content: '';
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    background: radial-gradient(circle at 10% 20%, rgba(200, 164, 92, 0.15) 0%, transparent 45%);
    pointer-events: none;
}

.sgpm-aside-logo {
    max-height: 50px;
    max-width: 220px;
    height: auto;
    display: block;
    margin-bottom: 1.5rem;
}

.sgpm-aside-title {
    font-size: 1.85rem;
    font-weight: 700;
    color: #ffffff;
    margin: 0;
    letter-spacing: 1px;
    line-height: 1.2;
}

.sgpm-aside-rule {
    width: 56px;
    height: 3px;
    background: linear-gradient(90deg, #dfbc68, #c8a45c);
    border-radius: 2px;
    margin: 1.25rem 0;
}

.sgpm-aside-lead {
    font-size: 0.95rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.82);
    margin-bottom: 2rem;
}

.sgpm-trust-points {
    list-style: none;
    padding: 0;
    margin: 0 0 2rem 0;
}

.sgpm-trust-points li {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
    font-size: 0.88rem;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.45;
}

.sgpm-trust-bullet {
    color: #dfbc68;
    font-size: 1rem;
    line-height: 1;
    margin-top: 2px;
    flex-shrink: 0;
}

.sgpm-aside-footer {
    padding-top: 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.45;
}

/* Right Column: Form Container */
.sgpm-login-main {
    padding: 3.25rem 2.75rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: #ffffff;
}

/* Mobile Brand Logo Header (Matching Platform Login) */
.sgpm-mobile-logo {
    display: none;
    text-align: center;
    margin-bottom: 1.25rem;
}

.sgpm-mobile-logo img {
    max-height: 44px;
    max-width: 210px;
    height: auto;
}

.sgpm-main-header {
    text-align: center;
    margin-bottom: 1.75rem;
}

.sgpm-emblem-badge {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #001a2e 0%, #002b49 100%);
    border-radius: 14px;
    border: 1px solid #c8a45c;
    box-shadow: 0 6px 16px rgba(0, 43, 73, 0.2);
}

.sgpm-emblem-badge img {
    max-height: 44px;
    max-width: 44px;
    height: auto;
    object-fit: contain;
}

.sgpm-main-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: #002b49;
    margin: 0 0 0.35rem 0;
    letter-spacing: -0.2px;
}

.sgpm-main-subtitle {
    font-size: 0.88rem;
    color: #64748b;
    margin: 0;
}

/* Roundcube Form Integration */
body.task-login #layout-content {
    background: transparent !important;
    position: static !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: none !important;
    box-shadow: none !important;
    height: auto !important;
}

body.task-login #layout-content > #logo {
    display: none !important;
}

body.task-login #login-form {
    margin: 0 !important;
    top: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    position: static !important;
}

body.task-login #login-form table {
    width: 100% !important;
    margin-bottom: 1rem !important;
    border-collapse: separate !important;
    border-spacing: 0 0.85rem !important;
}

body.task-login #login-form td.title {
    display: block !important;
    padding: 0 0 0.3rem 0 !important;
    width: 100% !important;
}

body.task-login #login-form td.title label {
    font-size: 0.86rem !important;
    font-weight: 600 !important;
    color: #002b49 !important;
    margin: 0 !important;
}

body.task-login #login-form td.input {
    display: block !important;
    width: 100% !important;
    padding: 0 !important;
}

body.task-login #login-form input.form-control {
    width: 100% !important;
    height: 46px !important;
    padding: 0.65rem 1rem !important;
    font-size: 0.95rem !important;
    background: #f8fafc !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 8px !important;
    color: #0f172a !important;
    transition: all 0.2s ease !important;
    box-sizing: border-box !important;
}

body.task-login #login-form input.form-control:focus {
    background: #ffffff !important;
    border-color: #002b49 !important;
    box-shadow: 0 0 0 3px rgba(0, 43, 73, 0.12), 0 0 0 1px #c8a45c !important;
    outline: none !important;
}

body.task-login #login-form .formbuttons {
    margin: 1.25rem 0 1rem 0 !important;
}

body.task-login #login-form button#rcmloginsubmit {
    width: 100% !important;
    height: 48px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.5rem !important;
    background: linear-gradient(135deg, #dfbc68 0%, #c8a45c 50%, #936d24 100%) !important;
    color: #001a2e !important;
    font-weight: 700 !important;
    font-size: 0.98rem !important;
    letter-spacing: 0.5px !important;
    border: none !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 14px rgba(200, 164, 92, 0.35) !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    text-transform: uppercase !important;
}

body.task-login #login-form button#rcmloginsubmit:hover {
    background: linear-gradient(135deg, #fae08c 0%, #dfbc68 50%, #b88f3e 100%) !important;
    box-shadow: 0 6px 18px rgba(200, 164, 92, 0.45) !important;
    transform: translateY(-1px) !important;
}

/* Security Notice */
.sgpm-security-notice {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-left: 3px solid #c8a45c;
    border-radius: 6px;
    padding: 0.75rem 0.9rem;
    font-size: 0.77rem;
    line-height: 1.45;
    color: #64748b;
    margin-top: 1rem;
}

.sgpm-security-notice strong {
    color: #002b49;
}

/* Login Footer */
body.task-login #login-footer {
    border-top: 1px solid #f1f5f9 !important;
    margin-top: 1.25rem !important;
    padding-top: 0.85rem !important;
    text-align: center !important;
    font-size: 0.78rem !important;
    color: #94a3b8 !important;
    position: static !important;
}

body.task-login #login-footer strong {
    color: #002b49;
}

@media (max-width: 860px) {
    .sgpm-login-container {
        grid-template-columns: 1fr;
        max-width: 440px;
        margin: 1rem auto;
    }
    .sgpm-login-aside {
        display: none !important;
    }
    .sgpm-mobile-logo {
        display: block !important;
    }
    .sgpm-login-main {
        padding: 2.25rem 1.75rem;
    }
}

/* ==========================================================================
   2. INTERNAL INTERFACE (Elastic Skin Customization)
   ========================================================================== */

/* Left Taskmenu / Navbar */
#layout-menu {
    background-color: #002b49 !important;
    border-right: 1px solid #001a2e !important;
}

#layout-menu .popover-header,
#layout-menu .sgpm-nav-header {
    background-color: #001a2e !important;
    border-bottom: 1px solid rgba(200, 164, 92, 0.25) !important;
    padding: 0.5rem 0.25rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 52px !important;
    line-height: normal !important;
    box-sizing: border-box !important;
}

/* CRITICAL FIX: Elastic skin's styles.min.css has '#layout-menu .popover-header a { display: none !important; }'.
   We explicitly override it for the logo link so it remains visible and clickable across desktop, tablet, and mobile! */
#layout-menu .popover-header a.sgpm-nav-logo-link,
#layout-menu .popover-header a:not(.cancel) {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 100% !important;
    text-decoration: none !important;
    padding: 0 4px !important;
    box-sizing: border-box !important;
}

#layout-menu .popover-header img.sgpm-nav-logo,
#layout-menu .popover-header img,
#layout-menu #logo {
    display: block !important;
    max-height: 36px !important;
    max-width: 92% !important;
    height: auto !important;
    width: auto !important;
    object-fit: contain !important;
    transition: transform 0.2s ease !important;
}

#layout-menu .popover-header a.sgpm-nav-logo-link:hover img.sgpm-nav-logo {
    transform: scale(1.04) !important;
}

/* Hide cancel button on desktop/tablet */
#layout-menu .popover-header a.button.cancel {
    display: none !important;
}

/* Mobile responsive taskmenu */
html.layout-phone #layout-menu .popover-header a.button.cancel {
    display: block !important;
    width: auto !important;
    color: #ffffff !important;
}
html.layout-phone #layout-menu .popover-header a.sgpm-nav-logo-link {
    width: auto !important;
    flex: 1 !important;
}

#taskmenu {
    background-color: #002b49 !important;
}

#taskmenu a.button {
    color: #e2e8f0 !important;
    transition: all 0.2s ease !important;
}

#taskmenu a.button:hover {
    background-color: rgba(200, 164, 92, 0.15) !important;
    color: #dfbc68 !important;
}

#taskmenu a.button.selected {
    background-color: #001a2e !important;
    color: #c8a45c !important;
    border-left: 3px solid #c8a45c !important;
    font-weight: 600 !important;
}

/* Floating Action Button / Compose Button */
#taskmenu a.button.compose,
a.button.compose {
    background: linear-gradient(135deg, #dfbc68 0%, #c8a45c 100%) !important;
    color: #001a2e !important;
    font-weight: 700 !important;
    border-radius: 8px !important;
    box-shadow: 0 3px 10px rgba(200, 164, 92, 0.35) !important;
    border: none !important;
}

#taskmenu a.button.compose:hover,
a.button.compose:hover {
    background: linear-gradient(135deg, #fae08c 0%, #dfbc68 100%) !important;
    box-shadow: 0 5px 14px rgba(200, 164, 92, 0.45) !important;
    color: #001a2e !important;
}

/* Folders List & Navigation */
.folder-list li.selected > a,
.treelist li.selected > a,
.listing tbody tr.selected td {
    background-color: #e8eef7 !important;
    color: #002b49 !important;
    font-weight: 600 !important;
}

.folder-list li.selected > a,
.treelist li.selected > a {
    border-left: 3px solid #c8a45c !important;
}

.folder-list li:hover > a,
.treelist li:hover > a {
    background-color: #f1f5f9 !important;
    color: #002b49 !important;
}

/* Unread Badges */
.unreadcount,
.badge-primary,
span.unread-count {
    background-color: #002b49 !important;
    color: #ffffff !important;
    font-weight: 600 !important;
    border-radius: 10px !important;
}

/* Message List Table */
#messagelist tr.selected td,
.messagelist tr.selected td {
    background-color: #e8eef7 !important;
    color: #002b49 !important;
    border-color: #cbd5e1 !important;
}

#messagelist tr.focused td,
.messagelist tr.focused td {
    background-color: #f1f5f9 !important;
}

#messagelist tr.unread td {
    font-weight: 600 !important;
}

#messagelist tr.flagged td a,
.flagged {
    color: #c8a45c !important;
}

/* Global Buttons & Form Controls */
.btn-primary,
.button.mainaction {
    background-color: #002b49 !important;
    border-color: #002b49 !important;
    color: #ffffff !important;
}

.btn-primary:hover,
.button.mainaction:hover {
    background-color: #0b1f3a !important;
    border-color: #0b1f3a !important;
}

.header > .toolbar a.button.selected,
.header > .toolbar a.button:active {
    color: #002b49 !important;
    border-bottom-color: #c8a45c !important;
}

/* Global SGPM App Footer */
#sgpm-global-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.35rem 1.25rem;
    background: #001a2e;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.73rem;
    border-top: 1px solid rgba(200, 164, 92, 0.25);
    z-index: 100;
}

#sgpm-global-footer strong {
    color: #ffffff;
}

#sgpm-global-footer a {
    color: #c8a45c;
    text-decoration: none;
}

body.task-login #sgpm-global-footer {
    display: none !important;
}

/* Dark Mode Support */
html.dark-mode #layout-menu {
    background-color: #001524 !important;
    border-right-color: #000c14 !important;
}

html.dark-mode #taskmenu a.button.selected {
    background-color: #0b1f3a !important;
    color: #dfbc68 !important;
    border-left-color: #dfbc68 !important;
}

html.dark-mode .folder-list li.selected > a,
html.dark-mode .treelist li.selected > a,
html.dark-mode .listing tbody tr.selected td,
html.dark-mode #messagelist tr.selected td {
    background-color: #0b2545 !important;
    color: #dfbc68 !important;
}

html.dark-mode #sgpm-global-footer {
    background-color: #000f1a !important;
    border-top-color: rgba(200, 164, 92, 0.2) !important;
}
