@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

:root {
    /* Classic Professional SaaS Palette */
    --primary: #0067ff;
    --primary-hover: #0056d6;
    --secondary: #374151;
    --accent: #0067ff;
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --glass-bg: #ffffff;
    --glass-border: #e2e8f0;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --error: #ef4444;
    --success: #10b981;
    --radius: 8px;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    color: var(--text-main);
    background-color: var(--bg-page);
    line-height: 1.5;
    min-height: 100vh;
    letter-spacing: -0.01em;
}

/* App Background */
.app-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-page);
    z-index: -1;
}

/* Clean Panel Design */
.glass-panel {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
}

/* Layout Structure */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background-color: var(--secondary);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;
    transition: all 0.3s ease;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-nav {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-item:hover {
    color: white;
    background-color: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    color: white;
    background-color: rgba(0, 0, 0, 0.30);
    border-left: 3px solid var(--primary);
    border-radius: 4px;
    padding-left: 1.3rem;
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

.nav-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}

.nav-group-header:hover {
    color: white;
}

.nav-group-header i.arrow {
    transition: transform 0.3s ease;
    font-size: 0.8rem;
}

.nav-group.active .nav-group-header i.arrow {
    transform: rotate(180deg);
}

.nav-group-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background: rgba(0, 0, 0, 0.1);
}

.nav-group.active .nav-group-content {
    max-height: 1000px;
}

.main-layout {
    flex-grow: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
}

/* Header/Titles */
h1,
h2,
h3 {
    font-weight: 700;
    letter-spacing: -0.025em;
    margin-bottom: 1.5rem;
    color: var(--secondary);
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

input[type="text"],
input[type="password"],
input[type="email"],
select,
textarea,
.form-control {
    width: 100% !important;
    display: block;
    padding: 0.875rem 1.25rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    color: var(--text-main);
    font-size: 1rem;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

input:focus,
select:focus,
textarea:focus,
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 103, 255, 0.1);
    background: #ffffff;
}

/* Login Styles */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background-color: #f8fafc;
    width: 100%;
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 3.5rem;
    background: white;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    border: 1px solid #e2e8f0;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    font-weight: 700;
    font-size: 0.95rem;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    text-decoration: none;
    box-sizing: border-box;
}

.btn-primary {
    background-color: var(--accent);
    color: white;
    border-color: var(--accent);
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.2);
}

.btn-primary:hover {
    background-color: #2563eb;
    border-color: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.3);
}

.btn-secondary {
    background-color: white;
    border-color: #d1d5db;
    color: #374151;
}

.btn-secondary:hover {
    background-color: #f9fafb;
    border-color: #9ca3af;
}

.btn-accent {
    background-color: var(--accent);
    color: white;
}

.btn-accent:hover {
    filter: brightness(0.9);
}

/* Tables */
.table-container {
    background: white;
    border-radius: var(--radius);
    padding: 0;
    border: 1px solid #e5e7eb;
    margin-top: 1rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.modern-table {
    width: 100%;
    border-collapse: collapse;
    color: var(--text-main);
}

.modern-table th {
    padding: 1rem;
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 2px solid #edf2f7;
    background: #f7fafc;
}

.modern-table td {
    padding: 1rem;
    font-size: 0.875rem;
    border-bottom: 1px solid #edf2f7;
}

.modern-table tr:hover {
    background: #f9fafb;
}

/* Status Badges */
.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    background: #ebf8ff;
    color: var(--primary);
    border: 1px solid #bee3f8;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1050;
    padding: 1rem;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: #ffffff;
    border-radius: var(--radius);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    padding: 2.5rem;
    max-width: 500px;
    width: 90%;
}

.modal-header h2 {
    color: var(--primary);
}

/* SSO Buttons */
.sso-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 1.5rem 0;
    color: var(--text-muted);
}

.sso-divider::before,
.sso-divider::after {
    border-bottom: 1px solid #e2e8f0;
}

.btn-google {
    background: white;
    border: 1px solid #e2e8f0;
    color: #4a5568;
}

.btn-microsoft {
    background: #2f2f2f;
    color: white;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* =====================================================
   MOBILE SIDEBAR OVERLAY
   ===================================================== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    display: block;
}

/* =====================================================
   RESPONSIVE — TABLET (max-width: 1024px)
   ===================================================== */
@media (max-width: 1024px) {
    .main-layout {
        margin-left: 240px;
    }

    .sidebar {
        width: 240px;
    }
}

/* =====================================================
   RESPONSIVE — MOBILE (max-width: 768px)
   ===================================================== */
@media (max-width: 768px) {

    /* Sidebar hidden off-canvas */
    .sidebar {
        transform: translateX(-100%);
        width: 280px !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    /* Prevent collapsed state from conflicting on mobile */
    .sidebar.collapsed {
        width: 280px !important;
        transform: translateX(-100%);
    }

    .sidebar.collapsed.mobile-open {
        transform: translateX(0);
    }

    /* Restore all labels when open on mobile */
    .sidebar.collapsed .brand-name,
    .sidebar.collapsed .nav-item span,
    .sidebar.collapsed .nav-group-header span,
    .sidebar.collapsed .nav-group-header .arrow {
        display: inline !important;
        opacity: 1 !important;
    }

    .sidebar.collapsed .nav-item {
        justify-content: flex-start !important;
        padding: 11px 16px !important;
    }

    .sidebar.collapsed .nav-item i {
        margin-right: 12px !important;
        font-size: 1.1rem !important;
    }

    .sidebar.collapsed .nav-group-header {
        justify-content: space-between !important;
        padding: 12px 16px !important;
    }

    /* Main layout fills full width */
    .main-layout {
        margin-left: 0 !important;
    }

    /* Top header */
    .top-header {
        padding: 0 16px !important;
        height: 60px !important;
    }

    /* Main content padding */
    main {
        padding: 16px !important;
        min-height: calc(100vh - 120px) !important;
    }

    /* Footer */
    footer {
        padding: 16px !important;
        font-size: 0.75rem !important;
    }

    /* Login */
    .login-wrapper {
        padding: 1rem;
        align-items: flex-start;
        padding-top: 2rem;
    }

    .login-card {
        padding: 2rem 1.5rem;
        border-radius: 16px;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    }

    /* Glass panels */
    .glass-panel {
        padding: 1.25rem;
        border-radius: 12px;
    }

    /* Buttons */
    .btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.9rem;
    }

    /* Headings */
    h1 { font-size: 1.4rem !important; margin-bottom: 1rem; }
    h2 { font-size: 1.15rem !important; margin-bottom: 0.75rem; }
    h3 { font-size: 1rem !important; margin-bottom: 0.5rem; }

    /* Tables: horizontal scroll */
    .table-container,
    .custom-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 12px;
    }

    /* Wrap bare tables in a scroll wrapper */
    table.debtor-table,
    table.modern-table,
    table.custom-table {
        min-width: 640px;
        display: table;
    }

    /* Make bare table parents scrollable */
    table.debtor-table {
        min-width: 700px;
    }

    .modern-table th,
    .modern-table td,
    .custom-table th,
    .custom-table td {
        padding: 0.65rem 0.75rem !important;
        font-size: 0.8rem !important;
        white-space: nowrap;
    }

    /* Modal */
    .modal-content {
        padding: 1.5rem;
        border-radius: 16px;
        max-width: 100%;
        margin: 0;
        width: 95%;
    }

    /* KPI & Portal grids */
    .kpi-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .portal-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* Form inputs — prevent iOS zoom (font-size must be >= 16px) */
    input[type="text"],
    input[type="password"],
    input[type="email"],
    select,
    textarea,
    .form-control {
        padding: 0.75rem 1rem;
        font-size: 16px !important;
        border-radius: 8px;
    }

    /* Hide username text in header on mobile */
    .user-name {
        display: none;
    }

    /* KPI Cards */
    .kpi-card,
    .premium-card {
        padding: 1.25rem !important;
        border-radius: 0.875rem !important;
    }

    .kpi-value {
        font-size: 1.25rem !important;
    }

    /* Section titles */
    .portal-section-title {
        font-size: 1.05rem !important;
        margin-bottom: 0.875rem !important;
    }

    /* Welcome text */
    .welcome-text {
        font-size: 1.35rem !important;
    }

    /* Status badges: compact */
    .status-badge {
        padding: 0.2rem 0.5rem;
        font-size: 0.68rem;
    }

    /* Action buttons */
    .action-button {
        margin-bottom: 0.75rem;
    }

    /* Responsive utilities */
    .hide-mobile { display: none !important; }
    .show-mobile { display: block !important; }
}

/* =====================================================
   RESPONSIVE — VERY SMALL PHONES (max-width: 375px)
   ===================================================== */
@media (max-width: 375px) {
    .login-card {
        padding: 1.5rem 1.25rem;
    }

    main {
        padding: 12px !important;
    }

    .btn {
        padding: 0.7rem 1rem;
        font-size: 0.875rem;
    }

    .kpi-value {
        font-size: 1.1rem !important;
    }

    .modal-content {
        padding: 1.25rem;
    }
}
