/**
 * Custom Logo Styles for BP One Group
 * Ensures proper display without distortion
 */

:root {
    --custom-logo-ratio: 1.62;
}

/* Login page logo - larger display */
.page-anonymous .glpi-logo {
    width: 250px !important;
    height: 154px !important;
    background-size: contain !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
}

/* Header logo - navigation bar */
.page .glpi-logo {
    width: 120px !important;
    height: 74px !important;
    background-size: contain !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
}

/* Reduced logo for collapsed menu */
.navbar .glpi-logo,
.sidebar-collapsed .glpi-logo {
    width: 50px !important;
    height: 31px !important;
    background-size: contain !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .page-anonymous .glpi-logo {
        width: 160px !important;
        height: 99px !important;
    }
    
    .page .glpi-logo {
        width: 80px !important;
        height: 49px !important;
    }
}

/* ============================================
   Login Page Responsive Layout
   Scoped to .login-form to avoid affecting
   other anonymous pages (2FA, OAuth, etc.)
   ============================================ */

/* Notebooks and small desktop screens (height <= 750px) */
@media (max-height: 750px) {
    .login-form .card-header {
        margin-bottom: 0.75rem !important;
    }

    .login-form .card-header h2 {
        font-size: 1.1rem !important;
    }

    .login-form .mb-3 {
        margin-bottom: 0.5rem !important;
    }

    .login-form .mb-4 {
        margin-bottom: 0.75rem !important;
    }

    .login-form .mb-2 {
        margin-bottom: 0.25rem !important;
    }

    .login-form .my-3 {
        margin-top: 0.5rem !important;
        margin-bottom: 0.5rem !important;
    }

    .login-form .form-footer {
        margin-top: 0.5rem !important;
    }
}

/* Very small height screens (height <= 600px) */
@media (max-height: 600px) {
    .login-form .form-control {
        padding: 0.3rem 0.5rem !important;
        font-size: 0.85rem !important;
    }

    .login-form .btn {
        padding: 0.4rem 0.75rem !important;
        font-size: 0.85rem !important;
    }
}

/* Smartphones narrow width (width <= 576px) */
@media (max-width: 576px) {
    .login-form .col-md-5 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }
}

/* Login page ancestor containers — scoped via :has(.login-form)
   so only the page containing the login form is affected */
@media (max-height: 750px) {
    .page-anonymous:has(.login-form) > .flex-fill {
        padding-top: 0.5rem !important;
        margin-top: 0 !important;
    }

    .page-anonymous:has(.login-form) .container-tight {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }

    .page-anonymous:has(.login-form) .glpi-logo {
        width: 160px !important;
        height: 99px !important;
        margin-bottom: 0.5rem !important;
    }

    .page-anonymous:has(.login-form) .card-body {
        padding: 0.75rem !important;
    }

    .page-anonymous:has(.login-form) .text-center.text-muted.mt-3 {
        margin-top: 0.5rem !important;
        font-size: 0.75rem;
    }
}

@media (max-height: 600px) {
    .page-anonymous:has(.login-form) > .flex-fill {
        padding-top: 0 !important;
        margin-top: 0 !important;
    }

    .page-anonymous:has(.login-form) .container-tight {
        padding-top: 0.25rem !important;
        padding-bottom: 0.25rem !important;
    }

    .page-anonymous:has(.login-form) .glpi-logo {
        width: 120px !important;
        height: 74px !important;
        margin-bottom: 0.25rem !important;
    }

    .page-anonymous:has(.login-form) .card-body {
        padding: 0.5rem !important;
    }
}

@media (max-width: 576px) {
    .page-anonymous:has(.login-form) .container-tight {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }
}

/* Combined: very short AND narrow (landscape phones) */
@media (max-height: 600px) and (max-width: 576px) {
    .page-anonymous:has(.login-form) .glpi-logo {
        width: 100px !important;
        height: 62px !important;
        margin-bottom: 0.25rem !important;
    }
}

/* Dark theme support */
[data-glpi-theme-dark="1"] .page-anonymous .glpi-logo,
.dark-mode .page-anonymous .glpi-logo {
    filter: brightness(1.1);
}

/* ============================================
   Microsoft SSO Button (Login Page)
   ============================================ */

.btn-microsoft-sso {
    background-color: #ffffff;
    color: #5e5e5e;
    border: 1px solid #8c8c8c;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, border-color 0.2s;
}

.btn-microsoft-sso:disabled {
    background-color: #f5f5f5;
    color: #a0a0a0;
    border-color: #d0d0d0;
    cursor: not-allowed;
    opacity: 0.8;
}

.btn-microsoft-sso:not(:disabled):hover {
    background-color: #f0f0f0;
    border-color: #5e5e5e;
    color: #333333;
}

/* ============================================
   BP One Group Customizations
   ============================================ */

/* Hide "Add User" button on Users page
   Users are imported from Sankhya ERP only */
body[data-itemtype="User"] .navbar-nav a.btn-primary[href*="user.form.php"],
body[data-itemtype="User"] .nav-item a.btn-primary[title*="Add"],
body.glpi_users .nav-item a.btn-primary,
a.btn-primary[href="/front/user.form.php"] {
    display: none !important;
}
