/**
 * Modern UI/UX Overrides for Asset Management System
 * strategically transformed for a premium, clean, and modern look.
 */

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --secondary: #64748b;
    --success: #10b981;
    --info: #0ea5e9;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #0f172a;
    --light: #f8fafc;
    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-800: #1f2937;
    
    --radius-sm: 0.375rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    --font-sans: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
    font-family: var(--font-sans);
    background-color: #f1f5f9;
    color: var(--gray-800);
    -webkit-font-smoothing: antialiased;
    letter-spacing: -0.01em;
}

/* Typography Enhancements */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    color: var(--dark);
    letter-spacing: -0.02em;
}

/* Layout Overrides */
.wrapper {
    background-color: transparent !important;
}

.main-header {
    border-bottom: 1px solid var(--gray-200) !important;
    background: rgba(255, 255, 255, 0.8) !important;
    backdrop-filter: blur(8px);
    padding: 0.75rem 1.5rem;
}

.main-sidebar {
    background-color: #0f172a !important; /* Deep matte navy */
    box-shadow: var(--shadow-xl) !important;
    border-right: 1px solid rgba(255, 255, 255, 0.03);
}

.brand-link {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
    padding: 1.25rem 1.5rem !important;
    background: transparent !important;
}

.brand-text {
    font-weight: 800 !important;
    letter-spacing: -0.02em;
    font-size: 1.25rem;
    color: var(--white) !important;
}

.sidebar-dark-primary .nav-sidebar > .nav-item > .nav-link.active,
.sidebar-dark-default .nav-sidebar > .nav-item > .nav-link.active {
    background-color: rgba(59, 130, 246, 0.1) !important; /* Subtle tint instead of solid bright color */
    box-shadow: none !important;
    border-radius: var(--radius-md);
    color: var(--white) !important;
    border-left: 3px solid var(--primary) !important; /* Clean accent bar */
}

.nav-sidebar .nav-link {
    border-radius: var(--radius-md);
    margin: 4px 15px !important; /* Increased margin for better symmetry from edges */
    padding: 0.6rem 0.875rem !important; /* More compact padding */
    transition: all 0.2s ease;
    font-weight: 500;
    font-size: 0.9rem; /* More compact text */
}

.nav-sidebar .nav-icon {
    font-size: 0.95rem !important;
    margin-right: 0.5rem !important;
}

.nav-sidebar .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.03) !important;
    color: var(--white) !important;
}

.nav-treeview {
    background-color: rgba(0, 0, 0, 0.2) !important;
    border-radius: var(--radius-md);
    margin: 4px 15px 8px !important;
    padding: 6px 0;
}

.nav-treeview .nav-link {
    margin: 2px 8px !important;
    padding: 0.5rem 1rem 0.5rem 1.75rem !important; /* Increased indentation */
    font-size: 0.85rem !important;
    color: rgba(255, 255, 255, 0.6) !important;
    position: relative;
}

.nav-treeview .nav-link::before {
    content: '';
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
}

.nav-treeview .nav-link:hover,
.nav-treeview .nav-link.active {
    color: var(--white) !important;
    background-color: rgba(255, 255, 255, 0.05) !important;
}

.nav-treeview .nav-link.active::before {
    background: var(--primary);
    box-shadow: none !important;
}

/* Caret/Angle Icon Improvements */
.nav-sidebar .nav-link i.right {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    transition: transform 0.3s ease;
    font-size: 0.8rem;
    opacity: 0.7;
}

.menu-open > .nav-link i.right {
    transform: translateY(-50%) rotate(-90deg);
}

/* Darker Bluish Sidebar - Active States */
.sidebar-dark-primary .nav-sidebar > .nav-item > .nav-link.active,
.sidebar-dark-default .nav-sidebar > .nav-item > .nav-link.active {
    background: rgba(59, 130, 246, 0.08) !important; 
    box-shadow: none !important;
    border-left: 3px solid #3b82f6 !important;
}

.sidebar-dark-primary .nav-sidebar > .nav-item.menu-open > .nav-link,
.sidebar-dark-default .nav-sidebar > .nav-item.menu-open > .nav-link {
    background: rgba(255, 255, 255, 0.03);
    border-left: 3px solid #1e3a8a;
}

/* Dashboard Specific Styles */
.chart-container {
    background: var(--white);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
    height: 320px; /* Precise height to prevent Chart.js infinite growth */
    position: relative; /* Required for responsive Chart.js */
    transition: all 0.3s ease;
}

.chart-container.chart-lg { height: 400px; }
.chart-container.chart-sm { height: 280px; }

.chart-container:hover {
    box-shadow: var(--shadow-lg);
}

.stat-card {
    position: relative;
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    background: var(--white);
    overflow: hidden;
    height: 100%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
}

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

.stat-card.bg-success-soft { 
    background: #f0fdf4; 
    color: #166534; 
    border-color: rgba(22, 101, 52, 0.1);
}
.stat-card.bg-info-soft { 
    background: #f0f9ff; 
    color: #075985; 
    border-color: rgba(7, 89, 133, 0.1);
}
.stat-card.bg-warning-soft { 
    background: #fffbeb; 
    color: #92400e; 
    border-color: rgba(146, 64, 14, 0.1);
}
.stat-card.bg-danger-soft { 
    background: #fef2f2; 
    color: #991b1b; 
    border-color: rgba(153, 27, 27, 0.1);
}
.stat-card.bg-primary-soft { 
    background: #f5f3ff; 
    color: #4c1d95; 
    border-color: rgba(76, 29, 149, 0.1);
}
.stat-card.bg-indigo-soft { 
    background: #eef2ff; 
    color: #312e81; 
    border-color: rgba(49, 46, 129, 0.1);
}
.stat-card.bg-purple-soft { 
    background: #faf5ff; 
    color: #581c87; 
    border-color: rgba(88, 28, 135, 0.1);
}

.stat-icon-compact {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--shadow-sm);
    font-size: 1.25rem;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.stat-card:hover .stat-icon-compact {
    transform: scale(1.15) rotate(-5deg);
    box-shadow: var(--shadow-md);
    background: #fff;
}

.btn-xs {
    padding: 0.25rem 0.6rem !important;
    font-size: 0.7rem !important;
    border-radius: var(--radius-sm) !important;
}

.stat-card-link {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    display: inline-flex;
    align-items: center;
    transition: all 0.2s ease;
}

.stat-card-link:hover {
    gap: 8px;
}

/* Card Modernization */
.card {
    border: none !important;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin-bottom: 2rem;
    overflow: hidden;
}

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

.card-header {
    background-color: var(--white) !important;
    border-bottom: 1px solid var(--gray-100) !important;
    padding: 1.25rem 1.5rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0;
}

.card-body {
    padding: 1.5rem;
}

/* Button Modernization */
.btn {
    border-radius: var(--radius-md);
    font-weight: 600;
    padding: 0.625rem 1.25rem;
    transition: all 0.2s ease;
    border: none !important;
    box-shadow: var(--shadow-sm);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary { background-color: var(--primary) !important; }
.btn-primary:hover { background-color: var(--primary-hover) !important; }
.btn-success { background-color: var(--success) !important; }
.btn-danger { background-color: var(--danger) !important; }
.btn-info { background-color: var(--info) !important; }
.btn-warning { background-color: var(--warning) !important; }

/* Form Modernization */
.form-control {
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-300);
    padding: 0.75rem 1rem;
    height: auto;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
    outline: none;
}

label {
    font-weight: 600;
    color: var(--secondary);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

/* Table Modernization */
.table {
    border-collapse: separate;
    border-spacing: 0 0.5rem;
}

.table thead th {
    background-color: var(--gray-50);
    border-bottom: 2px solid var(--gray-100) !important;
    color: var(--secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 1rem;
    font-weight: 700;
}

.table tbody tr:nth-child(even) {
    background-color: rgba(79, 70, 229, 0.02); /* Very subtle primary tint for even rows */
}

.table tbody tr:hover {
    background-color: rgba(79, 70, 229, 0.05) !important;
}

.table td {
    padding: 1rem;
    vertical-align: middle;
    border-top: 1px solid var(--gray-100) !important;
}

.table-actions {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    flex-wrap: nowrap;
}

.table-actions .btn {
    padding: 0.35rem 0.6rem !important;
    font-size: 0.8rem !important;
    border-radius: var(--radius-sm);
    line-height: 1;
}

.table-actions .btn i {
    font-size: 0.85rem;
}

/* DataTables Modernization */
.dataTables_wrapper .top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.dt-buttons {
    margin-bottom: 0 !important;
}

.dt-button {
    background: var(--white) !important;
    border: 1px solid var(--gray-200) !important;
    color: var(--secondary) !important;
    border-radius: var(--radius-md) !important;
    padding: 0.5rem 1rem !important;
    font-size: 0.875rem !important;
    font-weight: 600 !important;
    transition: all 0.2s ease !important;
    box-shadow: var(--shadow-sm) !important;
}

.dt-button:hover {
    background: var(--gray-50) !important;
    border-color: var(--gray-300) !important;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md) !important;
}

.dataTables_filter input {
    margin-left: 0.5rem !important;
}

.dataTables_info {
    font-size: 0.875rem;
    color: var(--secondary);
    font-weight: 500;
}

.dataTables_paginate .pagination .page-item .page-link {
    border-radius: var(--radius-sm);
    margin: 0 2px;
    border: none;
    color: var(--secondary);
    font-weight: 600;
}

.dataTables_paginate .pagination .page-item.active .page-link {
    background-color: var(--primary) !important;
    color: var(--white) !important;
}

/* Modal Enhancements */
.modal-content {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
}

.modal-header {
    border-bottom: 1px solid var(--gray-100);
    padding: 1.5rem;
}

.modal-footer {
    border-top: 1px solid var(--gray-100);
    padding: 1.25rem 1.5rem;
}

/* Badge Refinements */
.badge-success { background-color: rgba(16, 185, 129, 0.1) !important; color: var(--success) !important; }
.badge-danger { background-color: rgba(239, 68, 68, 0.1) !important; color: var(--danger) !important; }
.badge-warning { background-color: rgba(245, 158, 11, 0.1) !important; color: var(--warning) !important; }
.badge-info { background-color: rgba(14, 165, 233, 0.1) !important; color: var(--info) !important; }
.badge-secondary, .badge-default { background-color: var(--gray-100) !important; color: var(--secondary) !important; }

/* Auth Pages Modernization */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top right, #4f46e5 0%, #0f172a 100%);
    padding: 2rem;
}

.auth-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 400px;
    overflow: hidden;
    animation: fadeInScale 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.auth-card-body {
    padding: 2rem 1.5rem;
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.auth-logo {
    text-align: center;
    margin-bottom: 1.25rem;
}

.auth-logo img {
    height: 60px;
    width: auto;
    margin-bottom: 1rem;
}

.auth-logo h2 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--dark);
    margin: 0;
}

.auth-description {
    text-align: center;
    color: var(--secondary);
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
}

.auth-card .form-control {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    padding: 0.75rem 1rem;
}

.auth-card .form-control:focus {
    background: var(--white);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.auth-footer-links {
    text-align: center;
    margin-top: 2rem;
    font-size: 0.875rem;
    color: var(--secondary);
}

.auth-footer-links a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
    margin: 0 0.5rem;
}

.auth-footer-links a:hover {
    text-decoration: underline;
}

.auth-card.auth-card-lg {
    max-width: 900px;
}

.auth-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    color: var(--white);
    flex-direction: column;
}

.auth-loading-spinner {
    width: 60px;
    height: 60px;
    border: 6px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: auth-spin 1s linear infinite;
    margin-bottom: 1.5rem;
}

@keyframes auth-spin {
    to { transform: rotate(360deg); }
}

.custom-file-upload {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-md);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--gray-50);
}

.custom-file-upload:hover {
    border-color: var(--primary);
    background: var(--white);
}

.photo-preview-box {
    width: 150px;
    height: 150px;
    margin: 0 auto 1.5rem;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 3px solid var(--white);
    box-shadow: var(--shadow-md);
    display: none;
}

.photo-preview-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Navbar User Dropdown Enhancements */
.user-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.25rem 0.5rem !important;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 50px;
    border: 1px solid var(--gray-200);
}

.user-dropdown-toggle:hover {
    background: rgba(0, 0, 0, 0.05);
}

.user-avatar-circle {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

.user-name-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-800);
}

.dropdown-user-menu {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: 0.5rem;
    margin-top: 0.75rem;
    min-width: 220px;
}

.dropdown-user-item {
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--secondary);
    font-weight: 500;
    transition: all 0.2s ease;
}

.dropdown-user-item:hover {
    background: var(--gray-50);
    color: var(--primary);
}

.dropdown-user-item i {
    font-size: 1rem;
    opacity: 0.7;
}

/* 404 Page Modernization */
.error-page-container {
    min-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem;
}

.error-code-bg {
    font-size: 10rem;
    font-weight: 900;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    position: absolute;
    z-index: 0;
    opacity: 0.5;
}

.error-content-box {
    position: relative;
    z-index: 1;
}

.error-content-box h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.error-content-box p {
    color: var(--secondary);
    font-size: 1.1rem;
    margin-bottom: 2.5rem;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

/* Select2 Modernization & Consistency */
.select2-container--default .select2-selection--single {
    height: 38px !important;
    min-height: 38px !important;
    padding: 0.375rem 0.75rem !important;
    border: 1px solid #ced4da !important;
    border-radius: 4px !important;
    background-color: #fff !important;
    display: flex !important;
    align-items: center !important;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: normal !important;
    padding-left: 0 !important;
    color: #495057 !important;
    margin-top: -2px;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 36px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    right: 10px !important;
}

.select2-container {
    width: 100% !important;
}

.select2-container--default.select2-container--focus .select2-selection--single {
    border-color: #80bdff !important;
    outline: 0 !important;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25) !important;
}

.select2-container--default .select2-selection--multiple {
    min-height: 38px !important;
    border: 1px solid #ced4da !important;
    border-radius: 4px !important;
    padding-bottom: 2px !important;
}

.select2-dropdown {
    border: 1px solid #ced4da !important;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
    border-radius: 4px !important;
    z-index: 9999 !important;
}

/* Small Select2 variation */
.form-control-sm + .select2-container--default .select2-selection--single {
    height: 31px !important;
    min-height: 31px !important;
    padding: 0.25rem 0.5rem !important;
    font-size: 0.875rem !important;
}

/* Action Menu Button (Vertical Dots) Enhancement */
.action-menu-btn {
    width: 38px !important;
    height: 38px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
    color: var(--secondary) !important;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    outline: none !important;
    cursor: pointer;
}

.action-menu-btn:hover {
    background-color: rgba(79, 70, 229, 0.1) !important; /* Subtle primary tint */
    color: var(--primary) !important;
    transform: rotate(90deg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08) !important;
}

.action-menu-btn:focus, .action-menu-btn:active {
    background-color: rgba(79, 70, 229, 0.15) !important;
    box-shadow: none !important;
}

.action-menu-btn i {
    font-size: 1rem !important;
}

/* Ensure the dropdown toggle doesn't have default bootstrap link behavior */
.dropdown > .action-menu-btn::after {
    display: none !important;
}
