/* Universal topbar search */
.topbar-menu {
    flex-wrap: nowrap;
}
.topbar-menu > .d-flex:last-child {
    flex: 1;
    justify-content: flex-end;
}
.topbar-search-universal {
    flex: 1 1 auto;
    min-width: 320px;
    max-width: 640px;
    margin: 0 1rem 0 0;
    padding: 0.45rem 1rem;
    border-radius: 50rem;
    background: var(--ct-gray-100, #f6f7fb);
    border: 1px solid var(--ct-gray-300, #e7e9eb);
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.topbar-search-universal:hover,
.topbar-search-universal:focus-within {
    border-color: var(--ct-primary, #188ae2);
    box-shadow: 0 0 0 2px rgba(24, 138, 226, 0.12);
}
.topbar-search-universal span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#searchModal .modal-dialog {
    max-width: 720px;
}
#searchModal .form-control {
    font-size: 1.05rem;
    padding: 0.65rem 0.5rem;
}

/* Country Choices.js alignment */
.choices-country-wrap {
    width: 100%;
    position: relative;
}
.choices-country-wrap .choices {
    width: 100% !important;
    max-width: 100%;
    margin-bottom: 0;
}
.choices-country-wrap + .invalid-feedback {
    display: block;
}
.choices-country-wrap .choices__inner {
    min-height: 38px;
    padding: 6px 10px;
    border-radius: 0.375rem;
    border: 1px solid var(--ct-input-border-color, #ced4da);
    background: var(--ct-input-bg, #fff);
}
.choices-country-wrap .choices__list--dropdown,
.choices-country-wrap .choices__list[aria-expanded] {
    z-index: 1060;
    border-radius: 0.375rem;
    margin-top: 4px;
    max-height: 280px;
}
.choices-country-wrap .choices__list--dropdown .choices__item,
.choices-country-wrap .choices__list[aria-expanded] .choices__item {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.choices-country-wrap .choices__input {
    background: transparent !important;
    margin-bottom: 0;
    padding: 4px 0;
}
.country-option-flag {
    width: 22px;
    height: 16px;
    object-fit: cover;
    border-radius: 2px;
    flex-shrink: 0;
}

/* CRM dropzone */
.crm-dropzone {
    border: 2px dashed var(--ct-gray-400, #ced4da);
    border-radius: 0.5rem;
    background: var(--ct-gray-100, #f6f7fb);
    min-height: 140px;
    padding: 1.25rem;
    text-align: center;
    transition: border-color 0.2s, background 0.2s;
}
.crm-dropzone.dz-drag-hover,
.crm-dropzone.drag-over {
    border-color: var(--ct-primary, #188ae2);
    background: rgba(24, 138, 226, 0.06);
}
.crm-dropzone .dz-message {
    margin: 1.5em 0;
    color: var(--ct-gray-600, #8a969c);
}
.crm-dropzone .dz-preview {
    margin: 8px;
}

/* Photo crop */
.crm-photo-upload-card .photo-preview-wrap {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--ct-gray-300);
    margin: 0 auto 1rem;
    background: var(--ct-gray-100);
}
.crm-photo-upload-card .photo-preview-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
#photoCropModal .crm-photo-crop-container {
    width: 100%;
    max-height: min(72vh, 560px);
    min-height: 320px;
    overflow: hidden;
    background: #2a2a2a;
}
#photoCropModal .crm-photo-crop-container img {
    display: block;
    max-width: 100%;
}
#photoCropModal .cropper-container {
    max-height: min(72vh, 560px) !important;
}
/* Settings: favicon + logo row under robots toggle */
.crm-settings-branding-row .crm-favicon-upload,
.crm-settings-branding-row .crm-logo-upload {
    min-height: 100%;
}
.crm-settings-branding-row .crm-dropzone {
    min-height: 120px;
}

/* Favicon upload (settings) */
.crm-favicon-preview-wrap {
    width: 72px;
    height: 72px;
    border-radius: 0.5rem;
    overflow: hidden;
    border: 2px solid var(--ct-gray-300);
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    image-rendering: pixelated;
}
.crm-favicon-preview-img {
    width: 64px;
    height: 64px;
    object-fit: contain;
}
.crm-favicon-dropzone {
    min-height: 110px;
    padding: 0.75rem;
}
#faviconCropModal .crm-photo-crop-container {
    width: 100%;
    max-height: min(72vh, 480px);
    min-height: 280px;
    overflow: hidden;
    background: #2a2a2a;
}
#faviconCropModal .crm-photo-crop-container img {
    display: block;
    max-width: 100%;
}

/* Logo upload (settings) */
.crm-logo-preview-wrap {
    max-width: 100%;
    padding: 0.5rem;
    border-radius: 0.5rem;
    border: 2px solid var(--ct-gray-300);
    background: #fff;
}
.crm-logo-preview-img {
    max-width: 100%;
    max-height: 56px;
    width: auto;
    height: auto;
    object-fit: contain;
}
.crm-logo-dropzone {
    min-height: 100px;
    padding: 0.75rem;
}
#logoCropModal .crm-photo-crop-container {
    width: 100%;
    max-height: min(72vh, 480px);
    min-height: 280px;
    overflow: hidden;
    background: #2a2a2a;
}
#logoCropModal .crm-photo-crop-container img {
    display: block;
    max-width: 100%;
}

#photoCropModal .cropper-view-box,
#photoCropModal .cropper-face {
    border-radius: 0;
}
#crmDocumentPdfViewer canvas {
    max-width: 100%;
    height: auto !important;
}

/* Dynamic phones */
.phone-row .btn-remove-phone {
    min-height: calc(1.5em + 0.75rem + 2px);
}

/* Page toolbar — Edit / Delete alignment */
.crm-page-toolbar {
    margin-bottom: 1rem;
}
.crm-page-actions .btn,
.crm-page-actions form {
    margin: 0;
}
.crm-page-actions form.d-inline {
    display: inline-flex !important;
    align-items: center;
}

/* Dashboard KPI cards — uniform height */
.dashboard-stat-cards .dashboard-kpi-card,
.dashboard-stat-cards > .col > .card {
    min-height: 148px;
}
.dashboard-stat-cards .dashboard-kpi-card .card-header {
    padding-top: 0.85rem;
    padding-bottom: 0.5rem;
}
.dashboard-stat-cards .dashboard-kpi-card .card-body {
    padding-top: 0.25rem;
    padding-bottom: 0.85rem;
}
.dashboard-stat-cards .dashboard-kpi-card h3 {
    font-size: 1.65rem;
    line-height: 1.2;
}
.dashboard-stat-cards .dashboard-kpi-card .header-title {
    font-size: 0.95rem;
}

/* Invoice (Adminto-style) */
.crm-invoice-card {
    border: none;
    box-shadow: var(--ct-box-shadow, 0 0.75rem 1.5rem rgba(18, 38, 63, 0.03));
}
.crm-invoice-table thead th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    font-weight: 600;
}
.crm-invoice-summary td {
    padding: 0.35rem 0;
}

/* Student profile — remarks & issues */
.journey-profile-notes {
    text-align: left;
}
.journey-profile-notes .journey-remarks-list,
.journey-profile-notes .journey-issues-list {
    max-height: 220px;
    overflow-y: auto;
}
.student-profile-panel .card-body {
    text-align: left;
}

/* Breadcrumb */
.crm-breadcrumb {
    --bs-breadcrumb-divider: '›';
    font-size: 0.8125rem;
    margin-bottom: 0;
}

.country-flag-emoji {
    font-size: 1.15rem;
    line-height: 1;
    vertical-align: -0.1em;
}
.country-flag-display {
    justify-content: center;
}

/* Student documents manager */
#student-documents-card .document-upload-slot {
    background: var(--ct-gray-50, #fafbfc);
}
#student-documents-card .document-slot-row .doc-field-label {
    margin-bottom: 0.35rem;
    min-height: 1.25rem;
}
#student-documents-card .document-slot-row .form-control {
    min-height: calc(1.5em + 0.75rem + 2px);
}
#student-documents-card .doc-slot-actions-col {
    display: flex;
    flex-direction: column;
}
#student-documents-card .doc-slot-actions {
    display: flex;
    gap: 0.375rem;
    align-items: stretch;
    flex: 1 1 auto;
    min-height: calc(1.5em + 0.75rem + 2px);
}
#student-documents-card .doc-slot-actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: calc(1.5em + 0.75rem + 2px);
    padding-left: 0.65rem;
    padding-right: 0.65rem;
}
#student-documents-card .doc-slot-actions .btn-upload-doc {
    flex: 1 1 auto;
}
#student-documents-card .doc-slot-actions .btn-remove-slot {
    flex: 0 0 auto;
    width: calc(1.5em + 0.75rem + 2px);
    min-width: calc(1.5em + 0.75rem + 2px);
    padding-left: 0;
    padding-right: 0;
}
#student-documents-card .file-selected-name {
    display: block;
    min-height: 1.125rem;
    line-height: 1.125rem;
    font-size: 0.75rem;
    margin-top: 0.25rem;
    word-break: break-all;
}
#student-documents-card #documents-list .list-group-item {
    border-left: 0;
    border-right: 0;
}
#student-documents-card #documents-list .list-group-item > div:first-child {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    min-width: 0;
    flex: 1;
}
#student-documents-card #documents-list .btn-view-doc {
    padding: 0.15rem 0.4rem;
    line-height: 1;
}
#student-documents-card #documents-list .doc-view-link {
    word-break: break-word;
}

/* Auth login — theme gradient background */
.crm-auth-page {
    margin: 0;
}
.crm-auth-gradient {
    background: linear-gradient(
        145deg,
        #1475c0 0%,
        var(--ct-primary, #188ae2) 28%,
        var(--ct-secondary, #5b69bc) 58%,
        #2a3544 100%
    );
    background-attachment: fixed;
}
.crm-auth-alerts .alert {
    border-radius: 0.5rem;
    border: none;
    margin-bottom: 0.75rem;
}
.crm-auth-alerts .alert:last-child {
    margin-bottom: 0;
}
.crm-auth-card {
    border-radius: 0.75rem;
}
.crm-auth-footer {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.8125rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}
.crm-auth-card .alert-danger {
    border-radius: 0.5rem;
    font-size: 0.875rem;
}
.crm-auth-card .input-group .btn-outline-secondary {
    border-color: var(--ct-input-border-color, #ced4da);
}

/* Login — standard reCAPTCHA, centered, no clipping */
.crm-login-recaptcha {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 4.875rem;
    padding: 0.25rem 0;
}
.crm-login-recaptcha.is-invalid #login-recaptcha-mount > div {
    outline: 2px solid var(--ct-danger, #dc3545);
    outline-offset: 2px;
    border-radius: 0.25rem;
}
#login-recaptcha-mount {
    display: flex;
    justify-content: center;
    width: 100%;
    max-width: 304px;
    margin: 0 auto;
}
#login-recaptcha-wrap.d-none {
    display: none !important;
}

/* Settings — SEO robots toggle (switch stays inside card) */
.crm-meta-robots-toggle .form-check-input {
    float: none;
    margin-left: 0;
    width: 2.5em;
    height: 1.25em;
    cursor: pointer;
}
.crm-footer-solution-row .crm-footer-version {
    font-weight: 600;
    letter-spacing: 0.02em;
    opacity: 0.85;
}

.crm-meta-robots-toggle .form-check.form-switch {
    padding-left: 0;
    min-height: auto;
}

/* Scroll targets sit below fixed topbar */
#crm-page-alerts {
    scroll-margin-top: 5.5rem;
}

.crm-2fa-qr-box .crm-2fa-qr-server svg {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Logos: wide mark in expanded sidebar, square icon when collapsed */
.sidenav-menu .logo,
.app-topbar .logo {
    overflow: hidden;
}
.crm-logo-img--lg {
    height: var(--ct-logo-lg-height, 22px);
    max-width: min(220px, calc(var(--ct-sidenav-width, 245px) - 44px));
    width: auto;
    object-fit: contain;
    vertical-align: middle;
}
.crm-logo-img--sm {
    height: var(--ct-logo-sm-height, 28px);
    max-width: calc(var(--ct-sidenav-width-sm, 80px) - 24px);
    width: auto;
    object-fit: contain;
    vertical-align: middle;
}
html[data-sidenav-size="condensed"]:not([data-layout="topnav"]) .sidenav-menu .logo,
html[data-sidenav-size="sm"]:not([data-layout="topnav"]) .sidenav-menu .logo,
html[data-sidenav-size="sm-hover"]:not([data-layout="topnav"]) .sidenav-menu:not(:hover) .logo {
    padding-left: 12px;
    padding-right: 12px;
    text-align: center;
}
html[data-sidenav-size="condensed"]:not([data-layout="topnav"]) .sidenav-menu .logo .crm-logo-img--sm,
html[data-sidenav-size="sm"]:not([data-layout="topnav"]) .sidenav-menu .logo .crm-logo-img--sm,
html[data-sidenav-size="sm-hover"]:not([data-layout="topnav"]) .sidenav-menu:not(:hover) .logo .crm-logo-img--sm {
    display: block;
    margin-left: auto;
    margin-right: auto;
    max-width: 52px;
    max-height: 28px;
}
html[data-sidenav-size="condensed"]:not([data-layout="topnav"]) .sidenav-menu .logo span.logo-lg,
html[data-sidenav-size="sm"]:not([data-layout="topnav"]) .sidenav-menu .logo span.logo-lg,
html[data-sidenav-size="sm-hover"]:not([data-layout="topnav"]) .sidenav-menu:not(:hover) .logo span.logo-lg {
    display: none !important;
}
html[data-sidenav-size="condensed"]:not([data-layout="topnav"]) .sidenav-menu .logo span.logo-sm,
html[data-sidenav-size="sm"]:not([data-layout="topnav"]) .sidenav-menu .logo span.logo-sm,
html[data-sidenav-size="sm-hover"]:not([data-layout="topnav"]) .sidenav-menu:not(:hover) .logo span.logo-sm {
    display: block !important;
}
