/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

/* Label/tag denoting the user that shared a connection */
.jdbc-share-tag {

    background: #0095ff;
    padding: 0.25em;

    -moz-border-radius:    0.25em;
    -webkit-border-radius: 0.25em;
    -khtml-border-radius:  0.25em;
    border-radius:         0.25em;

    color: white;
    font-size: 0.75em;
    font-weight: bold;

}
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

.login-ui .sso-providers {

    padding: 0.25em 0.5em;
    position: absolute;
    bottom: 0;
    left: 0;

}

.sso-providers ul {
    list-style: none;
}

.sso-providers ul, .sso-providers li {
    display: inline-block;
    margin: 0;
    padding: 0;
}

.sso-providers li::before {
    content: ' / ';
}

.sso-providers li:first-child::before {
    display: none;
}
/* ============================================================
   Kartoza QGIS Cloud — Guacamole Branding  (single source)
   Image URLs relative to /guacamole/:  app/ext/kartoza/images/...
   Brand: Blue #2D7FB8  Gold #E8A020  Dark #3A3A3A
   ============================================================ */

/* ====== GLOBAL BODY (home page background) ================ */

body {
    background:
        linear-gradient(rgba(240, 245, 250, 0.80), rgba(240, 245, 250, 0.80)),
        url('app/ext/kartoza/images/background.jpg') center center / cover fixed !important;
    font-family: 'Segoe UI', Carlito, FreeSans, Helvetica, Arial, sans-serif !important;
}

/* ====== TOP NAVIGATION HEADER ============================== */

.header {
    background: #2D7FB8 !important;
    border-bottom: 3px solid #E8A020 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.20) !important;
}

.header h2 {
    color: #ffffff !important;
    font-size: 0.85em !important;
    letter-spacing: 1.5px !important;
    padding-left: 52px !important;
    position: relative !important;
}

.header h2::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    background: url('app/ext/kartoza/images/logo-144.png') left center / contain no-repeat;
    opacity: 0.95;
}

.header .user-menu,
.header .user-menu * {
    color: rgba(255, 255, 255, 0.92) !important;
}

.header .filter input {
    background: rgba(255, 255, 255, 0.15) !important;
    color: #ffffff !important;
    border-left: 1px solid rgba(255, 255, 255, 0.25) !important;
}

/* ====== HOME PAGE HERO STRIP ============================== */

div.recent-connections::before {
    content: 'QGIS Cloud — Open Source Geospatial Desktop';
    display: block;
    width: calc(100% + 2em);
    text-align: center;
    background: linear-gradient(135deg, #1a5f8a 0%, #2D7FB8 60%, #3a9ad4 100%);
    color: rgba(255, 255, 255, 0.88);
    font-size: 0.78em;
    font-weight: 500;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 8px 0 7px;
    border-bottom: 2px solid #E8A020;
    margin: -1em -1em 1.25em;
}

/* ====== RECENT CONNECTIONS — card grid ==================== */

div.recent-connections {
    padding: 1em !important;
    overflow: hidden !important;
}

div.recent-connections div.connection {
    background: #ffffff !important;
    border-radius: 10px !important;
    border: 1px solid rgba(45, 127, 184, 0.18) !important;
    border-top: 4px solid #2D7FB8 !important;
    box-shadow: 0 4px 18px rgba(45, 127, 184, 0.18), 0 1px 4px rgba(0,0,0,0.06) !important;
    padding: 14px 14px 10px !important;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-top-color 0.18s ease !important;
    cursor: pointer !important;
}

div.recent-connections div.connection:hover {
    transform: translateY(-5px) scale(1.01) !important;
    box-shadow: 0 12px 32px rgba(45, 127, 184, 0.30) !important;
    border-top-color: #E8A020 !important;
}

div.recent-connections div.connection img,
div.recent-connections div.connection canvas {
    border-radius: 6px !important;
    display: block !important;
}

div.recent-connections div.connection .name {
    color: #2D7FB8 !important;
    font-weight: 700 !important;
    font-size: 13px !important;
    margin-top: 9px !important;
    display: block !important;
    text-align: center !important;
}

/* ====== ALL CONNECTIONS — list ============================  */

div.all-connections {
    background: rgba(255, 255, 255, 0.92) !important;
    border-radius: 10px !important;
    border: 1px solid rgba(45, 127, 184, 0.15) !important;
    box-shadow: 0 2px 12px rgba(45, 127, 184, 0.10) !important;
    overflow: hidden !important;
    padding: 0 !important;
}

.all-connections .list-item {
    border-left: 4px solid transparent !important;
    padding: 10px 14px !important;
    transition: background 0.15s, border-left-color 0.15s !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05) !important;
}

.all-connections .list-item:hover {
    background: rgba(45, 127, 184, 0.07) !important;
    border-left-color: #2D7FB8 !important;
}

.all-connections .list-item .caption {
    color: #3A3A3A !important;
    font-size: 14px !important;
    font-weight: 500 !important;
}

/* ====== LOGIN PAGE ======================================== */

/* Full-page map background on the outer container */
div.login-ui {
    background:
        linear-gradient(rgba(0, 0, 0, 0.50), rgba(0, 0, 0, 0.50)),
        url('app/ext/kartoza/images/background.jpg') center center / cover no-repeat !important;
}

/* Cancel inner-box background on the centering wrapper */
div.login-ui .login-dialog-middle {
    background: transparent !important;
}

/* The actual login card */
div.login-ui .login-dialog {
    background: rgba(255, 255, 255, 0.97) !important;
    border-radius: 12px !important;
    border: none !important;
    border-top: 5px solid #2D7FB8 !important;
    box-shadow: 0 10px 48px rgba(0, 0, 0, 0.55) !important;
    padding: 2em 2.2em 1.8em !important;
    max-width: 3.5in !important;
    position: relative !important;
}

/* Kartoza logo — replace the tiny Guacamole icon */
div.login-ui .login-dialog .logo {
    width:  220px !important;
    height:  68px !important;
    background-image: url('app/ext/kartoza/images/logo-144.png') !important;
    background-size: contain !important;
    background-repeat: no-repeat !important;
    background-position: center center !important;
    margin: 0 auto 0.75em !important;
    display: block !important;
}

/* Hide "APACHE GUACAMOLE" title, keep version badge */
div.login-ui .login-dialog .version .app-name {
    display: none !important;
}

div.login-ui .login-dialog .version {
    padding: 0 0 0.5em !important;
}

div.login-ui .login-dialog .version .version-number {
    background: #2D7FB8 !important;
    color: #fff !important;
    font-size: 0.6em !important;
    border-radius: 4px !important;
    padding: 2px 6px !important;
    bottom: auto !important;
    right: auto !important;
    position: static !important;
    display: inline-block !important;
    float: right !important;
    margin-top: -1.5em !important;
}

/* Form inputs */
div.login-ui .login-dialog input[type="text"],
div.login-ui .login-dialog input[type="password"] {
    border: 1px solid #ccd4dc !important;
    border-radius: 6px !important;
    padding: 9px 11px !important;
    background: #FAFBFC !important;
    transition: border-color 0.2s !important;
}

div.login-ui .login-dialog input[type="text"]:focus,
div.login-ui .login-dialog input[type="password"]:focus {
    border-color: #2D7FB8 !important;
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(45, 127, 184, 0.18) !important;
}

/* Login button */
div.login-ui .login-dialog input[type="submit"].login {
    background: #2D7FB8 !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 6px !important;
    padding: 10px 0 !important;
    font-size: 0.9em !important;
    font-weight: 700 !important;
    letter-spacing: 0.5px !important;
    cursor: pointer !important;
    transition: background 0.2s !important;
    width: 100% !important;
}

div.login-ui .login-dialog input[type="submit"].login:hover {
    background: #E8A020 !important;
}

/* Footer tagline */
div.login-ui .login-dialog::after {
    content: 'QGIS Cloud · Powered by Kartoza';
    display: block;
    text-align: center;
    color: #aaa;
    font-size: 0.6em;
    margin-top: 1.2em;
    letter-spacing: 0.8px;
}


/* ====== SSO LOGIN PRIORITY OVERRIDE ======================= */

/* Use Guacamole's existing login siblings: SSO first, admin second. */
div.login-ui.initial {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 18px !important;
    min-height: 100vh !important;
    height: auto !important;
    padding: 36px 18px !important;
    box-sizing: border-box !important;
    overflow: auto !important;
}

div.login-ui.initial .login-error {
    order: 0 !important;
}

div.login-ui.initial .sso-providers {
    order: 1 !important;
    position: static !important;
    transform: none !important;
    z-index: auto !important;
    width: min(430px, calc(100vw - 36px)) !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    padding: 28px 28px 24px !important;
    text-align: center !important;
    background: rgba(255, 255, 255, 0.98) !important;
    border: 1px solid rgba(45, 127, 184, 0.22) !important;
    border-top: 6px solid #2D7FB8 !important;
    border-radius: 10px !important;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.34) !important;
    color: transparent !important;
    font-size: 0 !important;
}

div.login-ui.initial .sso-providers::before {
    content: 'QGIS Cloud';
    display: block;
    color: #223f55;
    font-size: 30px;
    line-height: 1.1;
    font-weight: 800;
    margin-bottom: 18px;
}

div.login-ui.initial .sso-provider-list {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
}

div.login-ui.initial .sso-provider {
    display: block !important;
    margin: 0 !important;
}

div.login-ui.initial .sso-provider-openid a {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    min-height: 50px !important;
    box-sizing: border-box !important;
    background: #2D7FB8 !important;
    color: transparent !important;
    border: none !important;
    border-radius: 7px !important;
    box-shadow: 0 10px 22px rgba(45, 127, 184, 0.30) !important;
    font-size: 0 !important;
    font-weight: 800 !important;
    text-decoration: none !important;
    transition: background 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease !important;
}

div.login-ui.initial .sso-provider-openid a::before {
    content: 'Continue with Kartoza SSO';
    color: #ffffff;
    font-size: 16px;
    line-height: 1.2;
}

div.login-ui.initial .sso-provider-openid a:hover {
    background: #E8A020 !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 14px 28px rgba(232, 160, 32, 0.28) !important;
}

div.login-ui.initial .sso-providers::after {
    content: 'Sign in with your Kartoza account';
    display: block;
    color: #52616f;
    font-size: 13px;
    line-height: 1.4;
    margin-top: 14px;
}

div.login-ui.initial .login-dialog-middle {
    order: 2 !important;
    position: static !important;
    transform: none !important;
    width: min(430px, calc(100vw - 36px)) !important;
    margin: 0 !important;
    background: transparent !important;
}

div.login-ui.initial .login-dialog {
    width: 100% !important;
    max-width: none !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    padding: 1.3em 1.55em 1.25em !important;
    background: rgba(255, 255, 255, 0.94) !important;
    border: 1px solid rgba(58, 58, 58, 0.12) !important;
    border-top: 3px solid rgba(58, 58, 58, 0.55) !important;
    border-radius: 8px !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22) !important;
    opacity: 1 !important;
}

div.login-ui.initial .login-dialog::before {
    content: 'Administrator access';
    display: block;
    text-align: center;
    color: #44515d;
    font-size: 0.78em;
    font-weight: 700;
    margin: -0.1em 0 0.85em;
}

div.login-ui.initial .login-dialog .logo {
    width: 150px !important;
    height: 46px !important;
    margin: 0 auto 0.35em !important;
    opacity: 1 !important;
}

div.login-ui.initial .login-dialog .version {
    padding-bottom: 0.35em !important;
}

div.login-ui.initial .login-dialog .login-fields,
div.login-ui.initial .login-dialog .login-fields *,
div.login-ui.initial .login-dialog .buttons,
div.login-ui.initial .login-dialog .buttons * {
    opacity: 1 !important;
    visibility: visible !important;
}

div.login-ui.initial .login-dialog input[type="text"],
div.login-ui.initial .login-dialog input[type="password"] {
    background: #ffffff !important;
    color: #1f2d38 !important;
    border: 1px solid #b8c3cc !important;
    border-radius: 5px !important;
    padding: 8px 10px !important;
}

div.login-ui.initial .login-dialog input[type="submit"].login {
    background: #3A3A3A !important;
    color: #ffffff !important;
    padding: 9px 0 !important;
    border-radius: 5px !important;
}

div.login-ui.initial .login-dialog input[type="submit"].login:hover {
    background: #2D7FB8 !important;
}

@media (max-height: 760px) {
    div.login-ui.initial {
        justify-content: flex-start !important;
        padding-top: 22px !important;
    }
}

@media (max-width: 520px) {
    div.login-ui.initial {
        padding: 20px 14px !important;
        gap: 14px !important;
    }

    div.login-ui.initial .sso-providers,
    div.login-ui.initial .login-dialog-middle {
        width: min(100%, 430px) !important;
    }

    div.login-ui.initial .sso-providers {
        padding: 24px 20px 20px !important;
    }

    div.login-ui.initial .sso-providers::before {
        font-size: 25px;
    }
}

/* ====== ADMIN FORM AND MENU READABILITY FIXES ============= */

/* Guacamole user dropdown: keep menu text readable on the light menu. */
.menu-dropdown,
.menu-dropdown *,
.user-menu .menu-dropdown,
.user-menu .menu-dropdown *,
.user-menu .menu-dropdown a,
.user-menu .menu-dropdown .caption,
.user-menu .menu-dropdown .text {
    color: #1f2d38 !important;
    opacity: 1 !important;
}

.user-menu .menu-dropdown .icon,
.menu-dropdown .icon {
    filter: none !important;
    opacity: 1 !important;
}

.user-menu .menu-dropdown a:hover,
.menu-dropdown a:hover {
    background: rgba(45, 127, 184, 0.10) !important;
    color: #1f2d38 !important;
}

/* Admin login fields: Guacamole renders labels, but the default theme hides them. */
div.login-ui.initial .login-dialog .field-header {
    display: block !important;
    height: auto !important;
    width: auto !important;
    margin: 0 0 5px !important;
    padding: 0 !important;
    overflow: visible !important;
    clip: auto !important;
    clip-path: none !important;
    position: static !important;
    color: #304456 !important;
    text-align: left !important;
}

div.login-ui.initial .login-dialog .field-header label {
    display: block !important;
    color: #304456 !important;
    font-size: 12px !important;
    line-height: 1.25 !important;
    font-weight: 700 !important;
    margin: 0 !important;
    opacity: 1 !important;
    visibility: visible !important;
}

div.login-ui.initial .login-dialog .labeled-field {
    margin-bottom: 12px !important;
}

div.login-ui.initial .login-dialog .labeled-field-username .field-header label::after {
    content: ' / email';
    font-weight: 600;
    color: #667888;
}

div.login-ui.initial .login-dialog .labeled-field-password .field-header label::after {
    content: '';
}

div.login-ui.initial .login-dialog input[name="username"]::placeholder {
    color: #8a98a5 !important;
}

div.login-ui.initial .login-dialog input[name="password"]::placeholder {
    color: #8a98a5 !important;
}
