/* ==========================================================================
   CUSTOM.CSS - BDox Power Pages Styles
   ==========================================================================

   Structure:
   1. CSS Variables
   2. Base Element Styles (standard HTML tags)
   3. Layout (containers, wrappers)
   4. Components (reusable UI)
   5. Page-Specific Styles
   6. Media Queries
   ========================================================================== */


/* ==========================================================================
   1. CSS VARIABLES
   ========================================================================== */

:root {
    /* Colors */
    --primary-green: #147162;
    --primary-green-light: #1a8a78;
    --primary-green-dark: #0f5a4d;
    --text-dark: #363636;
    --text-gray: #666666;
    --bg-light: rgb(250, 250, 250);
    --bg-white: rgb(255, 255, 255);
    --border-light: #e0e0e0;
    --border-input: #d0d0d0;

    /* Typography */
    --font-family: Roboto, sans-serif;
    --font-size-base: 16px;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.85rem;
    --font-size-md: 1rem;
    --font-size-lg: 1.1rem;
    --font-size-xl: 1.75rem;

    /* Shadows */
    --shadow-sm: rgba(0, 0, 0, 0.12) 0px 0px 0px, rgba(0, 0, 0, 0.14) 0px 2px 4px;
    --shadow-md: rgba(0, 0, 0, 0.12) 0px 0px 2px, rgba(0, 0, 0, 0.14) 0px 8px 16px;
}


/* ==========================================================================
   2. BASE ELEMENT STYLES (standard HTML tags)
   ========================================================================== */

a,
.a {
    font-size: var(--font-size-base) !important;
}

a:not(.btn):hover {
    text-decoration: none !important;
}

html {
    height: 100%;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-family: var(--font-family);
}

button,
input,
optgroup,
select,
textarea {
    font-family: var(--font-family);
}


/* ==========================================================================
   3. LAYOUT (containers, wrappers, structure)
   ========================================================================== */

.container {
    margin: 0;
}

.container #navbar .fa {
    line-height: inherit;
    width: 20px;
}

.wrapper-body-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-light);
    padding-bottom: 30px !important;
    min-height: calc(100vh - 200px);
}

.wrapper-body {
    box-shadow: var(--shadow-md);
    position: relative;
    background-color: var(--bg-light);
    overflow: hidden;
    padding: 0px;
    min-height: calc(100vh - 180px);
    display: flex;
    flex-direction: column;
}

.page-copy {
    background-color: var(--bg-white);
    box-shadow: var(--shadow-sm);
    margin: 16px;
    border-radius: 4px;
    overflow-y: auto;
    overflow-x: auto;
    flex: 1;
}

#content-container #content {
    background-color: var(--bg-white);
    box-shadow: var(--shadow-sm);
    margin: 16px;
    border-radius: 4px;
    padding: 16px;
}


/* ==========================================================================
   4. COMPONENTS (reusable UI elements)
   ========================================================================== */

/* --- Header & Navigation --- */
.navbar-brand.navbar-header img {
    height: 45px !important;
}

.navbar-dark .navbar-nav > li > a,
.navbar-dark .navbar-nav > li.dropdown > a {
    color: #fff !important;
}

/* --- Footer --- */
footer .footer-bottom {
    background-color: var(--primary-green) !important;
    color: #fff !important;
}

.footer-bottom {
    padding: 40px 0px;
    min-height: 100px;
}

.footer-bottom.d-print-none p {
    font-size: var(--font-size-base) !important;
}

/* --- Forms --- */
.crmEntityFormView,
.entitylist,
.modal-content,
.popover-content,
.crmEntityFormView label {
    color: var(--text-dark) !important;
}

.modal-form .modal-body iframe {
    height: 755px;
}

/* --- Section Titles --- */
.section-title h3 {
    padding-left: 20px;
}

/* --- PVA Chatbot (hidden) --- */
.pva-floating-style.pva-container {
    display: none !important;
}

/* --- Conversation Window --- */
.conversation-modal {
    display: flex;
    flex-direction: column;
    height: 600px;
    max-height: 80vh;
    background: var(--bg-white);
    border-radius: 8px;
    overflow: hidden;
}

.conversation-header {
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--primary-green-light) 100%);
    color: #fff;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.conversation-header .conversation-title h5 {
    color: #fff;
    font-size: var(--font-size-lg);
    font-weight: 600;
}

.conversation-header .text-muted {
    color: rgba(255, 255, 255, 0.8) !important;
    font-size: 0.8rem;
}

.conversation-header .btn-close {
    filter: brightness(0) invert(1);
    opacity: 0.8;
}

.conversation-header .btn-close:hover {
    opacity: 1;
}

.conversation-body {
    flex: 1;
    overflow-y: auto;
    background: #f8f9fa;
    padding: 16px;
}

.conversation-footer {
    padding: 16px;
    background: var(--bg-white);
    border-top: 1px solid var(--border-light);
}

/* --- Messages --- */
.messages-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 100%;
}

.message-item {
    display: flex;
    animation: messageSlide 0.3s ease-out;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-sent {
    justify-content: flex-end;
}

.message-sent .message-bubble {
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--primary-green-light) 100%);
    color: #fff;
    border-radius: 16px 16px 4px 16px;
    max-width: 70%;
}

.message-sent .message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.message-sent .message-time {
    color: rgba(255, 255, 255, 0.8) !important;
}

.message-received {
    justify-content: flex-start;
}

.message-received .message-bubble {
    background: var(--bg-white);
    color: var(--text-dark);
    border-radius: 16px 16px 16px 4px;
    max-width: 70%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.message-received .message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.message-received .message-author {
    color: var(--primary-green);
}

.message-bubble {
    padding: 12px 16px;
    word-wrap: break-word;
    word-break: break-word;
}

.message-header {
    margin-bottom: 6px;
    font-size: var(--font-size-sm);
}

.message-author {
    font-weight: 600;
}

.message-time {
    font-size: var(--font-size-xs);
}

.message-content {
    line-height: 1.5;
    white-space: pre-wrap;
}

.no-messages {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.message-form {
    display: flex;
    gap: 8px;
}

.message-input {
    resize: none;
    overflow-y: hidden;
    min-height: 42px;
    max-height: 120px;
    border-radius: 20px;
    padding: 10px 16px;
    border: 1px solid var(--border-input);
    transition: border-color 0.2s;
}

.message-input:focus {
    border-color: var(--primary-green);
    box-shadow: 0 0 0 0.2rem rgba(20, 113, 98, 0.15);
}

.send-button {
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--primary-green-light) 100%);
    border: none;
    border-radius: 20px;
    padding: 10px 20px;
    min-width: 60px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.send-button:hover {
    background: linear-gradient(135deg, var(--primary-green-dark) 0%, var(--primary-green) 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(20, 113, 98, 0.3);
}

.send-button:active {
    transform: translateY(0);
}

.messages-container::-webkit-scrollbar {
    width: 8px;
}

.messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

.modal-dialog.conversation-modal-dialog {
    max-width: 700px;
}

.modal-dialog.conversation-modal-dialog .modal-content {
    height: 85vh;
    border: none;
    border-radius: 12px;
    overflow: hidden;
}

.modal-dialog.conversation-modal-dialog .modal-body {
    padding: 0;
    display: flex;
    flex-direction: column;
}


/* --- Loading Screen --- */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loading-screen {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(200, 200, 200, 0.85);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

#loading-screen .loading-spinner {
    border: 8px solid var(--border-light);
    border-top: 8px solid var(--primary-green);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

#loading-screen .loading-text {
    color: var(--text-gray);
    font-family: var(--font-family);
    font-size: var(--font-size-lg);
    font-weight: bold;
    margin-top: 20px;
}


/* ==========================================================================
   5. PAGE-SPECIFIC STYLES
   ========================================================================== */

/* --- Sign-in Page --- */
.signinpage {
    padding: 0 !important;
}

.signinpage #content {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 0;
}

.signinpage .page-content {
    width: 100%;
    margin: 0 auto;
}

.signinpage .page-copy {
    margin: 0 0 2rem 0;
    text-align: center;
    min-height: 0;
}

.signinpage .row {
    margin: 0;
    justify-content: center;
}

.signinpage .col-md-6 {
    padding: 0;
}

.signinpage form {
    text-align: center;
}

.signinpage .login-heading-section {
    text-align: center;
    margin-bottom: 1rem;
    margin-top: 1rem;
    font-size: var(--font-size-xl);
    font-weight: 500;
    color: var(--primary-green);
}

.signinpage .login-description {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-gray);
    margin-bottom: 4rem;
    padding: 0 1rem;
    line-height: 1.5;
}

.signinpage .btn-primary {
    width: 200px;
    padding: 12px 24px;
    font-size: var(--font-size-md);
}

.signinpage #loginValidationSummary {
    margin: 0 auto 1rem;
}


/* ==========================================================================
   6. MEDIA QUERIES
   ========================================================================== */

@media (min-width: 576px) {
    .container,
    .container-sm {
        max-width: 100%;
    }
}

@media (min-width: 1400px) {
    .row.sectionBlockLayout > .container,
    .row.sectionBlockLayout > .container-lg,
    .row.sectionBlockLayout > .container-md,
    .row.sectionBlockLayout > .container-sm,
    .row.sectionBlockLayout > .container-xl,
    .row.sectionBlockLayout > .container-xxl {
        max-width: -webkit-fill-available !important;
    }

    .container,
    .container-lg,
    .container-md,
    .container-sm,
    .container-xl,
    .container-xxl {
        max-width: -webkit-fill-available !important;
    }
}

@media (max-width: 768px) {
    .conversation-modal {
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    .message-sent .message-bubble,
    .message-received .message-bubble {
        max-width: 85%;
    }

    .send-button span {
        display: none;
    }

    .send-button {
        min-width: 48px;
        padding: 10px 16px;
    }
}

/* Large screens - ensure content fills viewport */
@media (min-height: 900px) {
    .wrapper-body-right {
        min-height: calc(100vh - 120px);
    }
}

@media (min-height: 1080px) {
    .wrapper-body-right {
        min-height: calc(100vh - 100px);
    }
}
