/**
 * Admin Dashboard CSS
 * Premium FinTech Design for Mahaveer Micro Finance
 * No external dependencies required - Pure CSS
 */

/* Import Google Fonts - Inter for a modern, clean look */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* Global Variables - Premium FinTech Palette */
:root {
    /* Primary Colors - Deep Trustworthy Blues */
    --primary-color: #0f172a;
    /* Slate 900 */
    --primary-light: #334155;
    /* Slate 700 */
    --accent-color: #3b82f6;
    /* Blue 500 */

    /* Secondary & Status Colors */
    --success-color: #10b981;
    /* Emerald 500 */
    --warning-color: #f59e0b;
    /* Amber 500 */
    --danger-color: #ef4444;
    /* Red 500 */
    --info-color: #0ea5e9;
    /* Sky 500 */

    /* Neutral / Surface Colors */
    --body-bg: #f1f5f9;
    /* Slate 100 */
    --card-bg: #ffffff;
    --text-main: #1e293b;
    /* Slate 800 */
    --text-muted: #64748b;
    /* Slate 500 */
    --border-color: #e2e8f0;
    /* Slate 200 */

    /* Effects */
    --border-radius: 0.75rem;
    /* 12px */
    --radius-sm: 0.375rem;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base Styles */
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--body-bg);
    color: var(--text-main);
    line-height: 1.6;
    padding-top: 60px;
    /* Navbar height */
}

a {
    text-decoration: none;
    color: var(--accent-color);
    transition: var(--transition);
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5em;
}

/* Layout & Main Content */
main {
    min-height: calc(100vh - 60px);
    padding: 2rem 1.5rem;
    transition: margin-left 0.3s ease;
    width: 100%;
}

@media (min-width: 992px) {
    main {
        margin-left: 250px;
        width: calc(100% - 250px);
    }
}

@media (max-width: 991.98px) {
    main {
        margin-left: 0;
        padding: 1rem;
        width: 100%;
    }
}

/* Card Styling - Glass-like & Floating */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    height: 100%;
    overflow: hidden;
    will-change: transform;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    padding: 1.25rem 1.5rem;
    color: var(--primary-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-body {
    padding: 1.5rem;
}

/* Premium Statistics Cards */
.stat-card {
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 150px;
    height: 150px;
    background: currentColor;
    border-radius: 50%;
    opacity: 0.05;
    z-index: -1;
}

.stat-label {
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0.25rem 0;
}

/* Statistics Icons & Borders specific overrides */
.border-left-primary {
    border-left: 4px solid var(--accent-color) !important;
    color: var(--accent-color);
}

.border-left-success {
    border-left: 4px solid var(--success-color) !important;
    color: var(--success-color);
}

.border-left-info {
    border-left: 4px solid var(--info-color) !important;
    color: var(--info-color);
}

.border-left-warning {
    border-left: 4px solid var(--warning-color) !important;
    color: var(--warning-color);
}

.border-left-danger {
    border-left: 4px solid var(--danger-color) !important;
    color: var(--danger-color);
}


/* Buttons */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 500;
    padding: 0.625rem 1.25rem;
    transition: var(--transition);
    border: none;
    box-shadow: var(--shadow-sm);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-outline-primary {
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    box-shadow: none;
}

.btn-outline-primary:hover {
    background: var(--primary-color);
    color: white;
}

/* Forms - Modern Inputs */
.form-control,
.form-select {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    background-color: #f8fafc;
    transition: var(--transition);
}

.form-control:focus,
.form-select:focus {
    background-color: #fff;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-label {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

/* Tables - Clean & Spacious */
.table-responsive {
    border-radius: var(--border-radius);
    overflow: hidden;
}

.table {
    width: 100%;
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0;
}

.table th {
    background-color: #f8fafc;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.table td {
    padding: 1rem 1.5rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    background-color: white;
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr:hover td {
    background-color: #f8fafc;
}

/* Badges - Subtle Pills */
.badge {
    padding: 0.35em 0.8em;
    border-radius: 9999px;
    font-weight: 600;
    letter-spacing: 0.025em;
    text-transform: capitalize;
}

.bg-success {
    background-color: rgba(16, 185, 129, 0.1) !important;
    color: var(--success-color);
}

.bg-warning {
    background-color: rgba(245, 158, 11, 0.1) !important;
    color: var(--warning-color);
}

.bg-danger {
    background-color: rgba(239, 68, 68, 0.1) !important;
    color: var(--danger-color);
}

.bg-info {
    background-color: rgba(14, 165, 233, 0.1) !important;
    color: var(--info-color);
}

.bg-primary {
    background-color: rgba(59, 130, 246, 0.1) !important;
    color: var(--accent-color);
}

.bg-secondary {
    background-color: #f1f5f9 !important;
    color: var(--text-muted);
}

/* Sidebar - Modern Fixed/Offcanvas */
.sidebar {
    box-shadow: var(--shadow-sm);
    background-color: white;
    z-index: 1000;
}

.sidebar .nav-link {
    color: var(--text-muted);
    font-weight: 500;
    padding: 0.875rem 1.5rem;
    border-radius: 0;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
}

.sidebar .nav-link:hover {
    color: var(--primary-color);
    background-color: #f8fafc;
}

.sidebar .nav-link.active {
    color: var(--accent-color);
    background-color: rgba(59, 130, 246, 0.05);
    border-left-color: var(--accent-color);
}

.sidebar .nav-link i {
    width: 20px;
    text-align: center;
    margin-right: 0.5rem;
}

.sidebar-heading {
    padding: 1.5rem 1.5rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Navbar - Clean Header */
.navbar {
    background-color: white;
    box-shadow: var(--shadow-sm);
    padding: 0.75rem 1.5rem;
}

.navbar-brand {
    font-weight: 700;
    color: var(--primary-color) !important;
    font-size: 1.25rem;
}

/* Utilities */
.shadow {
    box-shadow: var(--shadow-lg) !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

/* Loading Spinner */
.loading-overlay {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(2px);
}

/* Responsive Adjustments */
@media (max-width: 991.98px) {
    main {
        margin-left: 0;
        padding: 1rem;
    }
}

/* Login Button Fix */
.btn-login {
    background-color: var(--accent-color) !important;
    color: white !important;
    font-weight: 600;
    padding: 0.75rem;
    letter-spacing: 0.5px;
    border: none;
    transition: all 0.3s ease;
}

.btn-login:hover {
    background-color: #2563eb !important;
    /* Darker blue */
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-login:active {
    transform: translateY(0);
}

/* File Upload Wrapper - Complete Styling */
.file-upload-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
    margin-bottom: 1rem;
}

.file-upload-wrapper input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.file-upload-label {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    background-color: #f8fafc;
    color: var(--text-muted);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.file-upload-label:hover {
    border-color: var(--accent-color);
    background-color: rgba(59, 130, 246, 0.05);
    color: var(--accent-color);
}

.file-upload-label i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    display: block;
}

/* Search Input - Complete Styling */
.search-input {
    position: relative;
    width: 100%;
    max-width: 400px;
}

.search-input input {
    padding-left: 2.5rem;
    border-radius: 9999px;
    border: 1px solid var(--border-color);
    background-color: #f8fafc;
    transition: var(--transition);
}

.search-input input:focus {
    background-color: white;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-input i {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    z-index: 2;
}

/* Table Responsive Enhancements */
.table-responsive {
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

@media (max-width: 768px) {
    .table-responsive {
        font-size: 0.875rem;
    }
    
    .table th,
    .table td {
        padding: 0.75rem 0.5rem;
        word-break: break-word;
        max-width: 150px;
    }
    
    .table th {
        font-size: 0.7rem;
    }
}

/* Mobile-First Responsive Grid */
.row {
    margin-left: -0.75rem;
    margin-right: -0.75rem;
}

.col,
[class*="col-"] {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

@media (max-width: 576px) {
    .row {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
    }
    
    .col,
    [class*="col-"] {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
}

/* Sidebar Responsive Fixes */
@media (max-width: 991.98px) {
    .offcanvas-lg {
        position: fixed;
        top: 60px;
        left: -100%;
        width: 250px;
        height: calc(100vh - 60px);
        background-color: white;
        box-shadow: var(--shadow-lg);
        transition: left 0.3s ease;
        z-index: 1050;
    }
    
    .offcanvas-lg.show {
        left: 0;
    }
    
    .offcanvas-backdrop {
        position: fixed;
        top: 60px;
        left: 0;
        width: 100vw;
        height: calc(100vh - 60px);
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1040;
    }
}

/* Form Responsive Enhancements */
@media (max-width: 768px) {
    .form-control,
    .form-select {
        padding: 0.625rem 0.875rem;
        font-size: 0.9rem;
    }
    
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
    
    .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
}

/* Statistics Cards Mobile */
@media (max-width: 768px) {
    .stat-value {
        font-size: 1.5rem;
    }
    
    .stat-label {
        font-size: 0.7rem;
    }
    
    .card-body {
        padding: 1rem;
    }
}

/* Navbar Mobile Adjustments */
@media (max-width: 991.98px) {
    .navbar {
        padding: 0.5rem 1rem;
    }
    
    .navbar-toggler {
        border: none;
        padding: 0.25rem 0.5rem;
    }
    
    .navbar-toggler:focus {
        box-shadow: none;
    }
}

/* Modal Responsive */
@media (max-width: 576px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }
}

/* Pagination Mobile */
@media (max-width: 576px) {
    .pagination {
        font-size: 0.875rem;
    }
    
    .page-link {
        padding: 0.375rem 0.5rem;
    }
}

/* Alert Responsive */
.alert {
    border-radius: var(--border-radius);
    border: none;
    box-shadow: var(--shadow-sm);
}

@media (max-width: 576px) {
    .alert {
        font-size: 0.875rem;
        padding: 0.75rem 1rem;
    }
}

/* Loading States */
.btn.loading {
    position: relative;
    color: transparent !important;
}

.btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Select2 Responsive Overrides */
.select2-container {
    width: 100% !important;
}

.select2-container .select2-selection--single {
    height: calc(2.25rem + 2px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: #f8fafc;
}

.select2-container .select2-selection--single .select2-selection__rendered {
    padding-left: 1rem;
    padding-top: 0.5rem;
    color: var(--text-main);
}

.select2-container--default .select2-selection--single:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Print Styles */
@media print {
    .sidebar,
    .navbar,
    .btn,
    .pagination {
        display: none !important;
    }
    
    main {
        margin-left: 0 !important;
        padding: 0 !important;
    }
    
    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
}

/* Dark Mode Support (Optional) */
@media (prefers-color-scheme: dark) {
    :root {
        --body-bg: #0f172a;
        --card-bg: #1e293b;
        --text-main: #f1f5f9;
        --text-muted: #94a3b8;
        --border-color: #334155;
    }
}

/* Accessibility Improvements */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus Indicators */
.btn:focus,
.form-control:focus,
.form-select:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .card {
        border: 2px solid var(--text-main);
    }
    
    .btn {
        border: 2px solid currentColor;
    }
}