/* Big Screen Layout Fixes for Borrowing & Lending Dashboard */

/* Fix for cards on large screens */
@media (min-width: 1200px) {
    .analytics-card {
        max-width: 100%;
        word-wrap: break-word;
        overflow: hidden;
    }
    
    .analytics-card .card-body {
        padding: 1rem !important;
        min-height: 180px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }
    
    .analytics-card h3 {
        font-size: 1.4rem;
        line-height: 1.2;
        margin-bottom: 0.5rem;
        word-break: break-word;
    }
    
    .analytics-card h6 {
        font-size: 0.875rem;
        margin-bottom: 0.5rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .analytics-card p {
        font-size: 0.8rem;
        margin-bottom: 0.75rem;
        line-height: 1.3;
    }
    
    .analytics-card .icon-container {
        margin-bottom: 0.75rem;
        font-size: 1.2rem;
    }
    
    .analytics-card .badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }
    
    /* Enhanced person cards with better sizing */
    .person-card {
        min-height: 180px !important;
        max-height: 220px !important;
        border-radius: 12px;
        transition: all 0.3s ease;
        cursor: pointer;
    }
    
    .person-card:hover {
        transform: translateY(-5px);
        box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    }
    
    .person-card-inner {
        padding: 1.25rem !important;
        height: 100%;
        display: flex;
        flex-direction: column;
        text-align: center;
    }
    
    .person-avatar-large {
        width: 50px !important;
        height: 50px !important;
        font-size: 1.5rem !important;
        margin: 0 auto 1rem auto !important;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: bold;
        color: white;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    }
    
    .person-info {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }
    
    .person-name-card {
        font-size: 1.1rem !important;
        margin-bottom: 0.75rem !important;
        line-height: 1.3;
        font-weight: 600;
    }
    
    .person-stats {
        margin-bottom: 0.5rem !important;
        flex: 1;
    }
    
    .stat-row {
        margin-bottom: 0.4rem !important;
        font-size: 0.85rem !important;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .stat-label {
        font-weight: 500;
        color: #6c757d;
    }
    
    .stat-value {
        font-weight: 600;
    }
    
    .person-card-footer {
        margin-top: auto;
        font-size: 0.75rem !important;
        color: #6c757d;
        border-top: 1px solid #e9ecef;
        padding-top: 0.5rem;
    }

    /* Specific fixes for Net Position and Active Records cards */
    .col-xl-3 .analytics-card {
        height: 100%;
        min-height: 200px;
    }
    
    .col-xl-3 .card-body {
        display: flex;
        flex-direction: column;
        height: 100%;
    }
    
    .col-xl-3 .mt-auto {
        margin-top: auto !important;
    }
}

/* Extra large screens (1400px+) */
@media (min-width: 1400px) {
    .analytics-card .card-body {
        padding: 1.25rem !important;
    }
    
    .analytics-card h3 {
        font-size: 1.6rem;
    }
    
    .analytics-card h6 {
        font-size: 0.9rem;
    }
    
    .analytics-card p {
        font-size: 0.85rem;
    }
}

/* Prevent text overflow on all screen sizes */
.analytics-card * {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.analytics-card .metric-counter {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Fix for progress bars on large screens */
@media (min-width: 1200px) {
    .progress {
        height: 6px !important;
        margin-bottom: 0.5rem;
    }
    
    .progress-bar {
        font-size: 0.7rem;
    }
}

/* Modern Metric Card Design */
.modern-metric-card {
    transition: all 0.3s ease;
    border-radius: 12px;
    min-height: 200px;
}

.modern-metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1) !important;
}

.metric-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.metric-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 1.8rem;
    line-height: 1.2;
    margin-bottom: 0.5rem;
}

.metric-subtitle {
    font-size: 0.8rem;
    margin-bottom: 1rem;
}

.metric-footer {
    border-top: 1px solid #f8f9fa;
    padding-top: 0.75rem;
}

/* Responsive adjustments */
@media (max-width: 575.98px) {
    .metric-icon {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }
    
    .metric-value {
        font-size: 1.5rem;
    }
    
    .metric-title {
        font-size: 0.8rem;
    }
    
    .modern-metric-card {
        min-height: 180px;
    }
}

@media (min-width: 576px) and (max-width: 767.98px) {
    .metric-icon {
        width: 38px;
        height: 38px;
    }
    
    .metric-value {
        font-size: 1.6rem;
    }
    
    .modern-metric-card {
        min-height: 190px;
    }
}

@media (min-width: 768px) and (max-width: 991.98px) {
    .metric-value {
        font-size: 1.7rem;
    }
    
    .modern-metric-card {
        min-height: 195px;
    }
}

@media (min-width: 992px) and (max-width: 1199.98px) {
    .metric-value {
        font-size: 1.75rem;
    }
    
    .modern-metric-card {
        min-height: 200px;
    }
}

@media (min-width: 1200px) {
    .metric-value {
        font-size: 1.6rem;
    }
    
    .metric-title {
        font-size: 0.85rem;
    }
    
    .metric-subtitle {
        font-size: 0.75rem;
    }
    
    .modern-metric-card {
        min-height: 200px;
    }
    
    .modern-metric-card .card-body {
        padding: 1.25rem !important;
    }
}

@media (min-width: 1400px) {
    .metric-value {
        font-size: 1.8rem;
    }
    
    .metric-title {
        font-size: 0.9rem;
    }
    
    .metric-subtitle {
        font-size: 0.8rem;
    }
    
    .modern-metric-card {
        min-height: 210px;
    }
}

/* Modern Table Container - Remove Scrollbars */
.modern-table-container {
    overflow: hidden;
    border-radius: 0 0 8px 8px;
}

.modern-records-table {
    font-size: 0.875rem;
    table-layout: fixed;
    width: 100%;
}

.modern-records-table thead th {
    background-color: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #495057;
    height: 45px;
    vertical-align: middle;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modern-records-table tbody tr {
    height: 60px;
    transition: all 0.2s ease;
    border-bottom: 1px solid #f1f3f4;
}

.modern-records-table tbody tr:hover {
    background-color: #f8f9fa;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.modern-records-table tbody td {
    vertical-align: middle;
    padding: 0.75rem 0.5rem;
    border-bottom: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modern-records-table .avatar-circle {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.modern-records-table .person-info {
    min-width: 0;
    flex: 1;
}

.modern-records-table .person-name {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0;
    font-size: 0.9rem;
}

.modern-records-table .person-contact {
    color: #6c757d;
    font-size: 0.75rem;
    margin: 0;
}

.modern-records-table .type-badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.modern-records-table .amount-value {
    font-weight: 600;
    font-size: 0.9rem;
}

.modern-records-table .status-badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-weight: 500;
}

.modern-records-table .btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 6px;
}

/* Responsive Table Adjustments */
@media (max-width: 575.98px) {
    .modern-records-table {
        font-size: 0.8rem;
    }
    
    .modern-records-table tbody tr {
        height: 55px;
    }
    
    .modern-records-table .avatar-circle {
        width: 30px;
        height: 30px;
        font-size: 0.8rem;
    }
    
    .modern-records-table .person-name {
        font-size: 0.85rem;
    }
    
    .modern-records-table .person-contact {
        font-size: 0.7rem;
    }
}

@media (min-width: 576px) and (max-width: 767.98px) {
    .modern-records-table tbody tr {
        height: 58px;
    }
}

@media (min-width: 768px) and (max-width: 991.98px) {
    .modern-records-table tbody tr {
        height: 60px;
    }
}

@media (min-width: 992px) {
    .modern-records-table tbody tr {
        height: 62px;
    }
    
    .modern-records-table .person-name {
        font-size: 0.95rem;
    }
}

/* FIXED: Allow proper table scrolling instead of forcing visible */
.table-responsive:not(.ai-table-responsive-wrapper) {
    overflow: visible !important;
}

/* Ensure AI tables maintain proper scrolling */
.ai-table-responsive-wrapper.table-responsive {
    overflow-x: auto !important;
    overflow-y: visible !important;
}

.card-body:not(:has(.ai-table-responsive-wrapper)) {
    overflow: hidden;
}

/* Allow card bodies with AI tables to show scrollbars */
.card-body:has(.ai-table-responsive-wrapper) {
    overflow: visible;
}

/* Fix dropdown positioning in table */
.modern-table-container {
    position: relative;
    overflow: visible !important;
}

.modern-records-table {
    overflow: visible !important;
}

.modern-records-table .dropdown {
    position: relative;
}

.modern-records-table .dropdown-menu {
    position: absolute !important;
    z-index: 1050 !important;
    right: 0 !important;
    left: auto !important;
    top: 100% !important;
    margin-top: 0.125rem !important;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 6px;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
    min-width: 160px;
    transform: translateX(0) !important;
    /* DISABLED: will-change causing scroll pause effect */
    /* will-change: auto !important; */
}

.modern-records-table tbody tr {
    overflow: visible !important;
}

.modern-records-table td:last-child {
    overflow: visible !important;
}

.modern-records-table tbody tr {
    position: relative;
}

.modern-records-table .dropdown-toggle {
    border: none;
    background: transparent;
    box-shadow: none;
}

/* Distribution Dialog Styles */
.distribution-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1060;
    display: flex;
    align-items: center;
    justify-content: center;
}

.distribution-dialog-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.distribution-dialog-content {
    position: relative;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    animation: dialogSlideIn 0.3s ease-out;
}

@keyframes dialogSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.distribution-dialog-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    justify-content: between;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.distribution-dialog-header h5 {
    color: #495057;
    font-weight: 600;
    margin: 0;
    flex: 1;
}

.distribution-dialog-body {
    padding: 1.5rem;
    max-height: 60vh;
    overflow-y: auto;
}

.distribution-dialog-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    background: #f8f9fa;
}

/* Responsive dialog */
@media (max-width: 576px) {
    .distribution-dialog-content {
        width: 95%;
        margin: 1rem;
    }
    
    .distribution-dialog-header,
    .distribution-dialog-body,
    .distribution-dialog-footer {
        padding: 1rem;
    }
}