﻿/* Shared admin modal + table styles (aligned with /admin/tenants) */

.modal-dialog-custom {
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    width: 960px;
    height: 780px;
    max-width: 98vw;
    max-height: 94vh;
    display: flex;
    flex-direction: column;
    z-index: 1050;
}

.modal-dialog-custom.child-modal {
    width: 850px;
    height: 720px;
    top: 75px;
    z-index: 1070;
}

.modal-dialog-custom.leaf-modal {
    width: 640px;
    min-height: 520px;
    top: 90px;
    z-index: 1090;
}

.modal-backdrop.level-1 { z-index: 1040; }
.modal-backdrop.level-2 { z-index: 1060; }
.modal-backdrop.level-3 { z-index: 1080; }

.modal-content-custom {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    border-radius: 10px;
    background: var(--app-card);
    color: var(--app-text);
    border: 1px solid var(--app-border);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
}

.ui-modal .modal-shell {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.ui-modal .modal-body-scroll {
    flex: 1 1 auto;
    overflow: auto;
}

.draggable-header {
    cursor: move;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.02), rgba(0, 0, 0, 0));
    user-select: none;
    flex-shrink: 0;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--app-border);
}

.draggable-header:active {
    cursor: grabbing;
}

.resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 18px;
    height: 18px;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 55%, rgba(0, 0, 0, 0.25) 55%);
    border-bottom-right-radius: 6px;
    opacity: 0.7;
}

.resize-grip {
    position: absolute;
    right: 10px;
    bottom: 10px;
    width: 18px;
    height: 18px;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 55%, rgba(0, 0, 0, 0.25) 55%);
    border-radius: 4px;
    opacity: 0.8;
    pointer-events: auto;
    z-index: 5;
}

.export-wizard-dialog {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 900px;
    height: 650px;
    max-width: 95vw;
    max-height: 90vh;
    pointer-events: auto;
}

.export-wizard-dialog .modal-content {
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.export-wizard-dialog .modal-header,
.export-wizard-dialog .modal-footer {
    flex-shrink: 0;
}

.export-wizard-dialog .modal-body {
    flex: 1 1 auto;
    overflow: auto;
}

.modal-tabs {
    display: flex;
    gap: 6px;
    padding: 0.5rem 1rem 0.35rem;
    border-bottom: 1px solid var(--app-border);
    background: var(--app-card);
}

.tab-button {
    border-radius: 0;
    border-bottom: none;
}

.tab-button.active {
    background-color: #0d6efd;
    color: #fff;
    border-color: #0d6efd;
}

/* Fixed tables + selection */
.fixed-layout-table {
    table-layout: fixed;
    width: 100%;
}

.fixed-layout-table th,
.fixed-layout-table td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
    position: relative;
}

.row-selected {
    background-color: rgba(13, 110, 253, 0.15) !important;
    border-left: 4px solid #0d6efd !important;
}

:root[data-bs-theme="dark"] .row-selected,
.app-root.dark .row-selected {
    background-color: rgba(13, 110, 253, 0.25) !important;
}

/* KPI blocks used across admin pages */
.kpi-container {
    display: flex;
    gap: 10px;
    padding: 14px;
    background: var(--app-surface);
    border-bottom: 1px solid var(--app-border);
}

.kpi-card {
    background: var(--app-card);
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    border-left: 4px solid #0d6efd;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 150px;
}

.kpi-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--app-muted);
    text-transform: uppercase;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--app-text);
    line-height: 1.2;
}

.kpi-icon {
    font-size: 2rem;
    opacity: 0.8;
}

.kpi-card.purple { border-left-color: #6f42c1; }
.kpi-card.purple .kpi-icon { color: #6f42c1; }
.kpi-card.success { border-left-color: #198754; }
.kpi-card.success .kpi-icon { color: #198754; }
.kpi-card.info { border-left-color: #0dcaf0; }
.kpi-card.info .kpi-icon { color: #0dcaf0; }

/* Dark mode surfaces */
.app-root.dark .modal-content-custom,
[data-bs-theme="dark"] .modal-content {
    background: #11171f;
    color: #e5e7eb;
    border-color: #1f2a38;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.app-root.dark .draggable-header,
[data-bs-theme="dark"] .modal-header {
    background: #1a2432;
    border-color: #1f2a38;
    color: #e5e7eb;
}

.app-root.dark .modal-footer,
[data-bs-theme="dark"] .modal-footer {
    background: #0f141b;
    border-color: #1f2a38;
}

.app-root.dark .resize-handle {
    background: linear-gradient(135deg, transparent 55%, #334155 55%);
}

[data-bs-theme="dark"] .resize-grip,
.app-root.dark .resize-grip {
    background: linear-gradient(135deg, transparent 55%, #334155 55%);
}

body .modal-backdrop.show {
    background: rgba(0, 0, 0, 0.55);
}

/* Lookup modal (tenant/company/address selectors etc.) */
.lookup-modal-dialog {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 800px;
    max-width: 95vw;
    height: 600px;
    max-height: 85vh;
    z-index: 1150;
    background: var(--app-card);
    color: var(--app-text);
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--app-border);
}

.lookup-grid-wrap {
    overflow: auto;
    flex: 1;
    padding: 0;
}

.lookup-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1140;
}

.lookup-row {
    cursor: pointer;
    border-bottom: 1px solid var(--app-border);
}

.lookup-row:hover {
    background-color: rgba(13, 110, 253, 0.08);
}

/* Confirmation modals (delete/purge) */
.confirm-modal-content {
    border: 0;
    box-shadow: 0 0 25px rgba(220, 53, 69, 0.45);
    overflow: hidden;
    background-color: var(--app-card);
    color: var(--app-text);
}

.confirm-header {
    background: linear-gradient(135deg, #dc3545 0%, #b02a37 100%);
    color: #fff;
}

.confirm-item-box {
    background-color: #fff5f5;
    border: 2px dashed #dc3545;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    text-align: center;
    color: #b02a37;
    word-break: break-all;
}

:root[data-bs-theme="dark"] .confirm-modal-content,
.app-root.dark .confirm-modal-content {
    background-color: #2b3035;
    color: #dee2e6;
    box-shadow: 0 0 25px rgba(220, 53, 69, 0.3);
}

:root[data-bs-theme="dark"] .confirm-item-box,
.app-root.dark .confirm-item-box {
    background-color: #2c0b0e;
    border-color: #dc3545;
    color: #ea868f;
}

.confirm-danger-content {
    background-color: #fff5f5;
    border: 2px solid #dc3545;
}

.confirm-danger-header {
    background-color: #dc3545;
    color: #fff;
}

:root[data-bs-theme="dark"] .confirm-danger-content,
.app-root.dark .confirm-danger-content {
    background-color: #2c0b0e;
    border-color: #dc3545;
    color: #ea868f;
}

tbody:focus {
    outline: 2px solid #86b7fe;
    outline-offset: -2px;
}

/* Page-specific modal sizing overrides (preserve existing layouts) */
#licenseModalDialog.modal-dialog-custom {
    width: 85vw;
    height: 85vh;
    top: 50px;
    z-index: 1055;
}

#appModalDialog.modal-dialog-custom {
    width: 85vw;
    height: 85vh;
    top: 50px;
    z-index: 1055;
}

#moduleModalDialog.modal-dialog-custom.child-modal {
    width: 70vw;
    height: 70vh;
    top: 80px;
    z-index: 1075;
}

#inchargeModalDialog.modal-dialog-custom {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 900px;
    max-width: 96vw;
    height: 680px;
    max-height: 92vh;
    z-index: 1050;
    border-radius: 8px;
    overflow: hidden;
}

#inchargeModalDialog .resize-handle {
    cursor: nwse-resize;
    opacity: 0.8;
    background: linear-gradient(135deg, transparent 55%, rgba(0, 0, 0, 0.25) 55%);
}
