/* ============================================
   Ontech ERP - Loan Management System Styles
   White Sidebar Theme with Inter Font
   Version: 2.0
   ============================================ */

:root {
    /* ===== Brand Colors ===== */
    --primary: #002868;
    --primary-light: #1a4a8a;
    --primary-dark: #001a4a;
    --secondary: #10b981;
    --secondary-light: #34d399;
    --secondary-dark: #059669;

    /* ===== Text Colors ===== */
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --text-white: #ffffff;

    /* ===== Background Colors ===== */
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --bg-dark: #1f2937;
    --bg-sidebar: #ffffff;

    /* ===== Border Colors ===== */
    --border-light: #e5e7eb;
    --border-medium: #d1d5db;

    /* ===== Status Colors ===== */
    --status-success: #10b981;
    --status-warning: #f59e0b;
    --status-danger: #ef4444;
    --status-info: #3b82f6;

    /* ===== Shadows ===== */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

    /* ===== Layout ===== */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --header-height: 60px;

    /* ===== Transitions ===== */
    --transition-base: all 0.2s ease;
    --transition-slow: all 0.3s ease;
}

/* ===== Global Reset ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ===== App Container ===== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar (White Theme) ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: var(--text-primary);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    transition: var(--transition-base);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid var(--border-light);
    box-shadow: 1px 0 3px rgba(0, 0, 0, 0.04);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-header {
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border-light);
    min-height: var(--header-height);
}

.sidebar-logo-icon {
    font-size: 1.75rem;
    color: var(--primary);
    flex-shrink: 0;
}

.sidebar-brand {
    font-size: 1.1rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    color: var(--primary);
}

.sidebar.collapsed .sidebar-brand,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .section-chevron {
    display: none;
}

.sidebar-nav {
    flex: 1;
    padding: 0.5rem 0;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.1) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
}

/* ===== Nav Sections ===== */
.nav-section {
    margin-bottom: 0.25rem;
}

.nav-section-title {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    padding: 0.6rem 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--transition-base);
    user-select: none;
}

.nav-section-title:hover {
    color: var(--primary);
}

.section-chevron {
    font-size: 0.6rem;
    transition: transform 0.2s ease;
}

.nav-section.section-collapsed .section-chevron {
    transform: rotate(-90deg);
}

.nav-section.section-collapsed .nav-item {
    display: none;
}

/* ===== Nav Items ===== */
.nav-item {
    padding: 0 0.75rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 6px;
    transition: var(--transition-base);
    font-size: 0.875rem;
    font-weight: 400;
}

.nav-link:hover {
    background: var(--bg-tertiary);
    color: var(--primary);
}

.nav-link.active {
    background: var(--primary);
    color: var(--text-white);
    font-weight: 500;
}

.nav-link i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

/* Font Awesome icon sizing in nav */
.nav-link .fa, .nav-link .fas, .nav-link .far, .nav-link .fab {
    font-size: 0.95rem;
    width: 20px;
    text-align: center;
}

/* ===== Sidebar Footer ===== */
.sidebar-footer {
    border-top: 1px solid var(--border-light);
    padding: 0.75rem;
}

.sidebar-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition-base);
    font-size: 0.875rem;
}

.sidebar-toggle:hover {
    background: var(--bg-tertiary);
    color: var(--primary);
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: var(--transition-base);
}

.sidebar.collapsed ~ .main-content,
.sidebar.collapsed + .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* ===== Top Header ===== */
.top-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    height: var(--header-height);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 0.4rem 1rem;
    min-width: 300px;
}

.header-search i {
    color: var(--text-muted);
}

.header-search input {
    border: none;
    background: none;
    outline: none;
    font-size: 0.875rem;
    color: var(--text-primary);
    width: 100%;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-icon-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-base);
    position: relative;
}

.header-icon-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.notification-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.65rem;
    background: var(--status-danger);
    color: white;
    padding: 1px 5px;
    border-radius: 10px;
}

/* ===== User Dropdown ===== */
.user-dropdown {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 8px;
    transition: var(--transition-base);
}

.user-dropdown:hover {
    background: var(--bg-tertiary);
}

.user-avatar {
    width: 34px;
    height: 34px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

.user-avatar-lg {
    width: 80px;
    height: 80px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
}

.user-info {
    line-height: 1.3;
}

.user-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ===== Page Container ===== */
.page-container {
    flex: 1;
    padding: 1.5rem;
}

/* ===== Page Header ===== */
.page-header {
    margin-bottom: 1.5rem;
}

.page-header-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-header p {
    color: var(--text-secondary);
    margin-bottom: 0;
    font-size: 0.875rem;
}

.page-header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ===== Quick Actions ===== */
.quick-actions {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition-base);
    min-width: 100px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.quick-action-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.quick-action-btn i {
    font-size: 1.5rem;
}

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stats-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: var(--transition-base);
}

.stats-card:hover {
    box-shadow: var(--shadow-md);
}

.stats-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.stats-icon.primary {
    background: rgba(0, 40, 104, 0.1);
    color: var(--primary);
}

.stats-icon.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--status-success);
}

.stats-icon.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--status-warning);
}

.stats-icon.danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--status-danger);
}

.stats-icon.info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--status-info);
}

.stats-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stats-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

.stats-change {
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.stats-change.up {
    color: var(--status-success);
}

.stats-change.down {
    color: var(--status-danger);
}

/* ===== Cards ===== */
.card {
    border: 1px solid var(--border-light);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    background: var(--bg-primary);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-light);
    padding: 1rem 1.25rem;
}

.card-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.card-body {
    padding: 1.25rem;
}

/* ===== Tables ===== */
.table {
    font-size: 0.875rem;
}

.table thead th {
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-light);
    padding: 0.75rem 1rem;
    white-space: nowrap;
}

.table tbody td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--bg-tertiary);
}

.table-hover tbody tr:hover {
    background-color: rgba(0, 40, 104, 0.03);
}

/* ===== Badges ===== */
.badge {
    font-weight: 500;
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
    border-radius: 6px;
}

/* ===== Forms ===== */
.form-control,
.form-select {
    font-size: 0.875rem;
    border-radius: 8px;
    border: 1px solid var(--border-medium);
    padding: 0.5rem 0.75rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 40, 104, 0.1);
}

.form-label {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 0.375rem;
}

.input-group-text {
    font-size: 0.875rem;
    border-radius: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-medium);
}

/* ===== Buttons ===== */
.btn {
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 8px;
    padding: 0.5rem 1rem;
    transition: var(--transition-base);
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

/* ===== Activity List ===== */
.activity-list {
    max-height: 400px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--bg-tertiary);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    width: 32px;
    height: 32px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.875rem;
}

.activity-text {
    font-size: 0.875rem;
    color: var(--text-primary);
}

.activity-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ===== Toast Notifications ===== */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast-custom {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-primary);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--border-medium);
    min-width: 300px;
    max-width: 450px;
    font-size: 0.875rem;
    transition: var(--transition-slow);
}

.toast-success { border-left-color: var(--status-success); }
.toast-danger { border-left-color: var(--status-danger); }
.toast-warning { border-left-color: var(--status-warning); }
.toast-info { border-left-color: var(--status-info); }

/* ===== Footer ===== */
.app-footer {
    padding: 1rem 1.5rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-light);
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* ===== Login Page ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
}

.login-card {
    background: var(--bg-primary);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.login-header h2 {
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

/* ===== Nav Tabs ===== */
.nav-tabs {
    border-bottom: 2px solid var(--border-light);
}

.nav-tabs .nav-link {
    color: var(--text-secondary);
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0.75rem 1rem;
    font-weight: 500;
    margin-bottom: -2px;
}

.nav-tabs .nav-link.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: none;
}

.nav-tabs .nav-link:hover {
    color: var(--primary);
    background: none;
    border-bottom-color: rgba(0, 40, 104, 0.3);
}

/* ===== Pagination ===== */
.pagination .page-link {
    border-radius: 8px;
    margin: 0 2px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
}

.pagination .page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
}

/* ===== Spinner Overlay ===== */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
}

/* ===== Responsive ===== */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.collapsed {
        transform: translateX(0);
        width: var(--sidebar-width);
    }

    .main-content {
        margin-left: 0 !important;
    }

    .header-search {
        min-width: 200px;
    }

    .page-header-content {
        flex-direction: column;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 575.98px) {
    .page-container {
        padding: 1rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .header-search {
        display: none;
    }

    .quick-actions {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 0.5rem;
    }

    .toast-container {
        left: 1rem;
        right: 1rem;
    }

    .toast-custom {
        min-width: auto;
        max-width: none;
    }
}

/* ===== Print Styles ===== */
@media print {
    .sidebar,
    .top-header,
    .app-footer,
    .page-header-actions,
    .quick-actions,
    .toast-container {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
    }

    .card {
        border: 1px solid #ddd;
        box-shadow: none;
    }
}
