/* =========================================
   LFMS - Responsive & Modern Styles
   Professional Legal Management System
   ========================================= */

/* =========================================
   ROOT VARIABLES - Modern Color Scheme
   ========================================= */
:root {
    --primary-color: #4a6fa5;
    --primary-dark: #3a5a8a;
    --primary-light: #6b8fc7;
    --secondary-color: #5a6c7d;
    --accent-color: #7c9cbf;
    
    --success-color: #48bb78;
    --info-color: #4299e1;
    --warning-color: #ed8936;
    --danger-color: #f56565;
    
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-dark: #2d3748;
    --bg-darker: #1a202c;
    
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --text-light: #a0aec0;
    --text-white: #ffffff;
    
    --border-color: #e2e8f0;
    --border-radius: 8px;
    --box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --box-shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
    
    --sidebar-width: 260px;
    --header-height: 60px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =========================================
   GLOBAL IMPROVEMENTS
   ========================================= */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
}

/* =========================================
   ENHANCED SIDEBAR - Responsive
   ========================================= */
.sidebar {
    position: fixed;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--bg-darker) 0%, var(--bg-dark) 100%);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    transition: var(--transition);
    z-index: 1000;
}

.sidebar .nav-item a {
    padding: 12px 20px;
    margin: 4px 12px;
    border-radius: var(--border-radius);
    transition: var(--transition);
    color: rgba(255, 255, 255, 0.8);
}

.sidebar .nav-item a:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-white);
    transform: translateX(4px);
}

.sidebar .nav-item.active > a {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--text-white);
    box-shadow: 0 4px 8px rgba(74, 111, 165, 0.3);
}

/* =========================================
   MAIN PANEL & CONTENT
   ========================================= */
.main-panel {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    transition: var(--transition);
    background-color: var(--bg-primary);
}

.page-inner {
    padding: 20px;
    margin-top: var(--header-height);
}

/* =========================================
   HEADER IMPROVEMENTS
   ========================================= */
.main-header {
    background-color: var(--bg-secondary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    height: var(--header-height);
}

.navbar-header {
    background-color: transparent !important;
}

.topbar-nav .nav-link {
    color: var(--text-secondary);
    transition: var(--transition);
}

.topbar-nav .nav-link:hover {
    color: var(--primary-color);
}

/* =========================================
   CARDS - Modern Design
   ========================================= */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    transition: var(--transition);
    background-color: var(--bg-secondary);
    margin-bottom: 24px;
}

.card:hover {
    box-shadow: var(--box-shadow-lg);
    transform: translateY(-2px);
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 20px 24px;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.card-body {
    padding: 24px;
}

/* =========================================
   BUTTONS - Modern Style
   ========================================= */
.btn {
    border-radius: var(--border-radius);
    padding: 10px 20px;
    font-weight: 500;
    transition: var(--transition);
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--text-white);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
    box-shadow: 0 4px 12px rgba(74, 111, 165, 0.4);
    transform: translateY(-2px);
}

.btn-round {
    border-radius: 25px;
}

/* =========================================
   FORMS - Enhanced Style
   ========================================= */
.form-control,
.form-select {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 10px 16px;
    transition: var(--transition);
    font-size: 14px;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.1);
    outline: none;
}

.form-label {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* =========================================
   TABLES - Modern Responsive Design
   ========================================= */
.table-responsive {
    border-radius: var(--border-radius);
    box-shadow: none;
    position: relative;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Enhanced scroll indicators */
.table-responsive::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(to right,
        var(--primary-color) 0%,
        transparent 20%,
        transparent 80%,
        var(--primary-color) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.table-responsive.has-scroll::before {
    opacity: 0.6;
}

/* Modern table styling */
.table {
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0;
    background-color: var(--bg-secondary);
}

.table thead th {
    background: linear-gradient(135deg, var(--bg-primary) 0%, rgba(74, 111, 165, 0.05) 100%);
    color: var(--text-primary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-color);
    padding: 16px 12px;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.table tbody tr {
    transition: all 0.2s ease;
    border-bottom: 1px solid var(--border-color);
}

.table tbody tr:hover {
    background: linear-gradient(135deg,
        rgba(74, 111, 165, 0.08) 0%,
        rgba(74, 111, 165, 0.04) 100%);
    transform: translateX(2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.table tbody tr:last-child {
    border-bottom: none;
}

.table td {
    padding: 16px 12px;
    vertical-align: middle;
    color: var(--text-secondary);
    border: none;
}

/* Action buttons optimization */
.table .btn {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 6px;
    margin: 0 2px;
    transition: all 0.2s ease;
}

.table .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Status badges and priority indicators */
.table .badge {
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 500;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Data priority classes for responsive behavior */
.table th[data-priority],
.table td[data-priority] {
    display: table-cell;
}

.table th[data-priority="1"],
.table td[data-priority="1"] {
    /* Always visible - high priority - default table-cell display */
    display: table-cell;
}

.table th[data-priority="2"],
.table td[data-priority="2"] {
    /* Medium priority - visible by default, hidden on smaller screens via media queries */
    display: table-cell;
}

.table th[data-priority="3"],
.table td[data-priority="3"] {
    /* Low priority - hidden on tablets and mobile via media queries */
    display: table-cell;
}

/* =========================================
   MODALS - Modern Design
   ========================================= */
.modal-content {
    border: none;
    border-radius: 12px;
    box-shadow: var(--box-shadow-lg);
}

.modal-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border-radius: 12px 12px 0 0;
    padding: 20px 24px;
}

.modal-title {
    font-weight: 600;
    font-size: 18px;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    background-color: var(--bg-primary);
}

/* =========================================
   BADGES & STATUS
   ========================================= */
.badge {
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 12px;
}

/* =========================================
   BREADCRUMBS
   ========================================= */
.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding: 0;
    margin: 0;
    list-style: none;
}

.breadcrumbs li {
    display: flex;
    align-items: center;
    color: var(--text-secondary);
    font-size: 13px;
}

.breadcrumbs a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
}

.breadcrumbs a:hover {
    color: var(--primary-color);
}

/* =========================================
   PAGE HEADER
   ========================================= */
.page-header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.page-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 8px 0;
}

/* =========================================
   TABLET RESPONSIVENESS (768px - 1024px)
   ========================================= */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 240px;
    }
    
    .page-inner {
        padding: 16px;
    }
    
    .card-body {
        padding: 20px;
    }
    
    .page-title {
        font-size: 22px;
    }
}

@media (max-width: 991px) {
    .sidebar {
        margin-left: calc(var(--sidebar-width) * -1);
        transition: margin-left 0.3s ease-in-out;
    }
    
    .nav_open .sidebar {
        margin-left: 0;
    }
    
    .main-panel {
        margin-left: 0;
        width: 100%;
    }
    
    .topbar-nav .nav-item .profile-username {
        display: none;
    }
    
    /* Enhanced Table Actions for Mobile - compact design */
    .table td .btn-group {
        display: flex;
        flex-direction: row;
        gap: 2px;
        justify-content: center;
    }

    .table td .btn {
        width: auto;
        font-size: 11px;
        padding: 6px 8px;
        margin: 0;
        min-width: 32px;
        height: 32px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Modern Mobile Table Layout */
    .table-responsive.mobile-cards {
        overflow-x: visible;
    }

    .table-responsive.mobile-cards .table {
        display: none;
    }

    .table-responsive.mobile-cards .mobile-cards-container {
        display: block;
    }

    /* Card-based table layout for mobile */
    .mobile-cards-container {
        display: none;
    }

    .mobile-card {
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: var(--border-radius);
        margin-bottom: 12px;
        padding: 16px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        transition: all 0.3s ease;
    }

    .mobile-card:hover {
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
        transform: translateY(-2px);
    }

    .mobile-card-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 12px;
        padding-bottom: 12px;
        border-bottom: 1px solid var(--border-color);
    }

    .mobile-card-title {
        font-weight: 600;
        color: var(--text-primary);
        font-size: 16px;
        margin: 0;
    }

    .mobile-card-subtitle {
        color: var(--text-secondary);
        font-size: 14px;
        margin: 4px 0 0 0;
    }

    .mobile-card-content {
        display: grid;
        gap: 8px;
    }

    .mobile-card-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 4px 0;
    }

    .mobile-card-label {
        font-weight: 500;
        color: var(--text-secondary);
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        flex-shrink: 0;
    }

    .mobile-card-value {
        color: var(--text-primary);
        font-size: 14px;
        text-align: right;
        flex-grow: 1;
    }

    .mobile-card-actions {
        display: flex;
        gap: 8px;
        margin-top: 12px;
        padding-top: 12px;
        border-top: 1px solid var(--border-color);
    }

    .mobile-card-actions .btn {
        flex: 1;
        padding: 6px 8px;
        font-size: 12px;
        min-height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Progressive column hiding for tablets */
    .table th[data-priority="3"],
    .table td[data-priority="3"] {
        display: none;
    }

    /* Enhanced scroll indicators for tablets */
    @media (max-width: 991px) {
        .table-responsive::after {
            content: '⟷ Scroll horizontally';
            position: absolute;
            bottom: -24px;
            right: 0;
            font-size: 11px;
            color: var(--text-secondary);
            background: var(--bg-secondary);
            padding: 2px 8px;
            border-radius: 4px;
            opacity: 0;
            transition: opacity 0.3s ease;
        }

        .table-responsive.has-scroll::after {
            opacity: 0.8;
        }
    }
}

/* =========================================
   MOBILE RESPONSIVENESS (< 768px)
   ========================================= */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 100%;
        --header-height: 56px;
    }
    
    body {
        font-size: 13px;
    }
    
    /* Mobile sidebar toggle using nav_open class */
    .sidebar {
        width: 100%;
        margin-left: -100%;
        z-index: 9999;
        transition: margin-left 0.3s ease-in-out;
    }
    
    .nav_open .sidebar {
        margin-left: 0;
    }
    
    /* Overlay when sidebar is open on mobile */
    .nav_open .sidebar::before {
        content: '';
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: -1;
    }
    
    /* Main panel full width */
    .main-panel {
        margin-left: 0;
        width: 100%;
    }
    
    /* Page layout */
    .page-inner {
        padding: 12px;
        margin-top: var(--header-height);
    }
    
    .page-header {
        margin-bottom: 16px;
        padding-bottom: 12px;
    }
    
    .page-title {
        font-size: 20px;
    }
    
    /* Breadcrumbs on mobile */
    .breadcrumbs {
        font-size: 12px;
    }
    
    /* Cards on mobile */
    .card {
        margin-bottom: 16px;
    }
    
    .card-header {
        padding: 16px;
    }
    
    .card-body {
        padding: 16px;
    }
    
    .card-title {
        font-size: 16px;
    }
    
    /* Card header button stacking */
    .card-header .d-flex {
        flex-direction: column;
        gap: 8px;
        align-items: stretch !important;
    }
    
    /* General mobile button adjustments - more targeted */
    .card-header .btn,
    .modal-footer .btn,
    .page-header .btn {
        width: 100%;
        padding: 10px 16px;
        font-size: 14px;
        margin-bottom: 8px;
    }

    .card-header .btn:last-child,
    .modal-footer .btn:last-child,
    .page-header .btn:last-child {
        margin-bottom: 0;
    }
    
    /* Table responsiveness - Progressive Enhancement */
    .table-responsive {
        margin: -16px;
        padding: 16px;
        border-radius: 0;
    }

    .table {
        font-size: 13px;
        min-width: 600px; /* Ensure minimum width for readability */
    }

    .table thead th,
    .table td {
        padding: 12px 8px;
        white-space: nowrap;
    }

    .table thead th {
        font-size: 11px;
        position: sticky;
        top: 0;
        background: var(--bg-primary) !important;
        z-index: 10;
    }

    /* Priority-based column hiding */
    .table th[data-priority="1"],
    .table td[data-priority="1"],
    .table th[data-priority="2"],
    .table td[data-priority="2"] {
        display: table-cell;
    }

    .table th[data-priority="3"],
    .table td[data-priority="3"],
    .table th[data-priority="4"],
    .table td[data-priority="4"],
    .table th[data-priority="5"],
    .table td[data-priority="5"] {
        display: none;
    }

    /* Enhanced action buttons for mobile - more compact */
    .table .btn {
        padding: 4px 6px;
        font-size: 10px;
        min-width: 28px;
        height: 28px;
        margin: 1px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Mobile Card Layout - Alternative to table */
    .mobile-table-cards {
        display: block !important;
    }

    .mobile-table-cards .table {
        display: none !important;
    }

    .mobile-table-cards .mobile-cards-container {
        display: block !important;
    }
    
    /* Forms on mobile */
    .form-control,
    .form-select {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px 14px;
    }
    
    .form-label {
        font-size: 13px;
    }
    
    /* Modal adjustments */
    .modal-dialog {
        margin: 8px;
    }
    
    .modal-content {
        border-radius: 8px;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 16px;
    }
    
    .modal-title {
        font-size: 16px;
    }
    
    /* Topbar adjustments for mobile header */
    .topbar-nav .nav-item {
        margin: 0 2px;
    }
    
    .topbar-nav .nav-link {
        padding: 10px;
        border-radius: 8px;
    }
    
    .topbar-nav .nav-link i {
        font-size: 18px;
    }
    
    /* Enhanced header responsiveness */
    .main-header {
        height: 56px;
        box-shadow: 0 1px 8px rgba(0, 0, 0, 0.06);
    }
    
    .logo-header {
        padding: 8px 12px;
    }
    
    .navbar-brand img {
        height: 24px;
    }
    
    /* Profile dropdown mobile optimization */
    .topbar-user .profile-username {
        display: none;
    }
    
    .topbar-user .avatar-sm {
        width: 36px;
        height: 36px;
    }
    
    /* Dropdown menus */
    .dropdown-menu {
        font-size: 13px;
    }
    
    /* Row spacing */
    .row [class*='col-'] {
        margin-bottom: 12px;
    }
}

/* =========================================
   SMALL MOBILE (< 576px)
   ========================================= */
@media (max-width: 576px) {
    .page-title {
        font-size: 18px;
    }
    
    .card-header .btn {
        font-size: 13px;
        padding: 10px;
    }
    
    .table {
        font-size: 11px;
    }
    
    /* Hide description columns on small screens */
    .table th:nth-child(3),
    .table td:nth-child(3) {
        display: none;
    }
    
    .modal-title {
        font-size: 15px;
    }
    
    /* Compact spacing */
    .mb-3 {
        margin-bottom: 12px !important;
    }
}

/* =========================================
   LANDSCAPE ORIENTATION ADJUSTMENTS
   ========================================= */
@media (max-width: 768px) and (orientation: landscape) {
    .page-inner {
        margin-top: 52px;
    }
    
    .sidebar {
        height: 100vh;
        overflow-y: auto;
    }
}

/* =========================================
   UTILITY CLASSES
   ========================================= */
.text-muted {
    color: var(--text-secondary) !important;
}

.text-primary {
    color: var(--primary-color) !important;
}

.bg-light-primary {
    background-color: rgba(74, 111, 165, 0.1) !important;
}

.border-radius {
    border-radius: var(--border-radius) !important;
}

.shadow-sm {
    box-shadow: var(--box-shadow) !important;
}

.shadow-lg {
    box-shadow: var(--box-shadow-lg) !important;
}

/* =========================================
   PRINT STYLES
   ========================================= */
@media print {
    .sidebar,
    .main-header,
    .btn,
    .breadcrumbs {
        display: none !important;
    }
    
    .main-panel {
        margin-left: 0;
        width: 100%;
    }
    
    .page-inner {
        margin-top: 0;
        padding: 0;
    }
    
    .card {
        box-shadow: none;
        page-break-inside: avoid;
    }
}

/* =========================================
   LOADING & ANIMATIONS
   ========================================= */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

/* =========================================
   SCROLLBAR STYLING
   ========================================= */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* =========================================
   ACCESSIBILITY IMPROVEMENTS
   ========================================= */
.btn:focus,
.form-control:focus,
.form-select:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

a:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
