/* ==========================================================================
   2i ERP - Modern Enterprise Theme & Responsive Stylesheet
   ========================================================================== */

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

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-soft: #eff6ff;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --success-soft: #ecfdf5;
    --info-color: #06b6d4;
    --info-soft: #ecfeff;
    --warning-color: #f59e0b;
    --warning-soft: #fffbeb;
    --danger-color: #ef4444;
    --danger-soft: #fef2f2;
    --purple-color: #8b5cf6;
    --purple-soft: #f5f3ff;
    --orange-color: #f97316;
    --orange-soft: #fff7ed;
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-hover: #1e293b;
    --sidebar-active: #2563eb;
    --card-bg: #ffffff;
    --body-bg: #f8fafc;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #f1f5f9;
    --border-subtle: #e2e8f0;
    --header-height: 62px;
    --sidebar-width: 245px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.03);
    --shadow-hover: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.03);
}

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

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--body-bg);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ==========================================================================
   Layout Structure
   ========================================================================== */
.erp-wrapper {
    display: block;
    min-height: 100vh;
    position: relative;
    width: 100%;
    overflow-x: hidden;
}

/* Sidebar */
.erp-sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #fff;
    min-height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.erp-sidebar .sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.erp-sidebar .sidebar-brand .brand-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #fff;
    font-size: 1.15rem;
    font-weight: 700;
}

.sidebar-menu {
    flex-grow: 1;
    padding: 14px 10px;
    overflow-y: auto;
}

.menu-category {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #64748b;
    padding: 12px 10px 4px;
    font-weight: 700;
}

.nav-link-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.84rem;
    font-weight: 500;
    margin-bottom: 2px;
    transition: all 0.2s ease;
    gap: 10px;
}

.nav-link-item:hover {
    color: #fff;
    background: var(--sidebar-hover);
}

.nav-link-item.active {
    background: var(--sidebar-active);
    color: #fff;
    font-weight: 600;
}

.nav-link-item i {
    font-size: 0.95rem;
    width: 18px;
    text-align: center;
}

.sidebar-user {
    padding: 12px 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.2);
    text-decoration: none;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s ease;
}

.sidebar-user:hover {
    background: rgba(0, 0, 0, 0.35);
    color: #fff;
}

.user-avatar-circle {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #334155;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    flex-shrink: 0;
}

/* Main Content Area */
.erp-main {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    max-width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
}

/* Top Navbar */
.erp-header {
    height: var(--header-height);
    background: #ffffff;
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.header-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    border: none;
    background: transparent;
    transition: all 0.2s ease;
    text-decoration: none;
}

.header-icon-btn:hover {
    background: #f1f5f9;
    color: #0f172a;
}

/* Page Content Container */
.erp-content {
    padding: 20px 24px;
    flex-grow: 1;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

.page-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.3px;
    margin: 0;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 0.84rem;
}

.date-badge {
    background: #ffffff;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #334155;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* ==========================================================================
   Compact KPI Metric Cards (Sleek & Proportional)
   ========================================================================== */
.kpi-card {
    background: #ffffff;
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 13px 15px;
    box-shadow: var(--shadow-card);
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
}

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

.kpi-card-top {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 8px;
}

.kpi-icon-box {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.kpi-icon-box.blue { background: #eff6ff; color: #2563eb; }
.kpi-icon-box.green { background: #ecfdf5; color: #10b981; }
.kpi-icon-box.purple { background: #f5f3ff; color: #8b5cf6; }
.kpi-icon-box.orange { background: #fff7ed; color: #f97316; }

.kpi-info {
    flex-grow: 1;
    overflow: hidden;
}

.kpi-title {
    font-size: 0.76rem;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kpi-value {
    font-size: 1.35rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.1;
    margin-bottom: 3px;
    letter-spacing: -0.4px;
}

.kpi-trend {
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    gap: 3px;
    font-weight: 600;
}

.kpi-trend.positive {
    color: #10b981;
}

.kpi-trend .period {
    color: #94a3b8;
    font-weight: 400;
}

.kpi-link {
    font-size: 0.75rem;
    font-weight: 600;
    color: #2563eb;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-top: auto;
    padding-top: 6px;
    border-top: none;
}

.kpi-link:hover {
    color: #1d4ed8;
    text-decoration: none;
}

/* ==========================================================================
   Cards & UI Components
   ========================================================================== */
.card {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--card-bg);
    box-shadow: var(--shadow-card);
    transition: all 0.2s ease;
    overflow: hidden;
}

.card-header {
    background: #ffffff;
    border-bottom: 1px solid var(--border-subtle);
    padding: 12px 16px;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.92rem;
}

.card-body {
    padding: 16px;
}

/* Data Tables (Responsive & Crisp) */
.table-responsive {
    border-radius: var(--radius-md);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.table {
    margin-bottom: 0;
    vertical-align: middle;
    width: 100%;
}

.table thead th {
    background-color: #ffffff;
    color: #64748b;
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.table tbody td {
    padding: 10px 14px;
    font-size: 0.82rem;
    border-bottom: 1px solid #f1f5f9;
    color: #1e293b;
}

.table-hover tbody tr:hover {
    background-color: #f8fafc;
}

/* Badges */
.badge-soft-success {
    background-color: #ecfdf5;
    color: #10b981;
    border: 1px solid #d1fae5;
    font-weight: 600;
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 10px;
    display: inline-block;
}

.badge-soft-primary { background-color: var(--primary-soft); color: var(--primary-color); border: 1px solid #dbeafe; font-size: 0.7rem; padding: 3px 8px; border-radius: 10px; }
.badge-soft-warning { background-color: var(--warning-soft); color: var(--warning-color); border: 1px solid #fef3c7; font-size: 0.7rem; padding: 3px 8px; border-radius: 10px; }
.badge-soft-danger { background-color: var(--danger-soft); color: var(--danger-color); border: 1px solid #fee2e2; font-size: 0.7rem; padding: 3px 8px; border-radius: 10px; }
.badge-soft-secondary { background-color: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; font-size: 0.7rem; padding: 3px 8px; border-radius: 10px; }

/* Filter dropdown badge */
.chart-filter-btn {
    background: #ffffff;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 0.72rem;
    font-weight: 600;
    color: #475569;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

/* Donut Chart Center Container */
.donut-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.donut-center-text {
    position: absolute;
    text-align: center;
    pointer-events: none;
}

.donut-center-text h4 {
    font-size: 1.2rem;
    font-weight: 800;
    margin: 0;
    color: #0f172a;
}

.donut-center-text p {
    font-size: 0.68rem;
    color: #64748b;
    margin: 0;
    font-weight: 600;
}

/* Donut Legend List */
.donut-legend {
    list-style: none;
    padding: 0;
    margin: 0;
}

.donut-legend li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 0.78rem;
    border-bottom: 1px dashed #f1f5f9;
}

.donut-legend li:last-child {
    border-bottom: none;
}

.legend-color-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}

/* Table Footer Link */
.table-footer-link {
    padding: 10px 14px;
    border-top: 1px solid #f1f5f9;
    font-size: 0.78rem;
    font-weight: 600;
    background: #ffffff;
}

.table-footer-link a {
    color: #2563eb;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.table-footer-link a:hover {
    color: #1d4ed8;
}

/* Buttons */
.btn {
    font-weight: 600;
    border-radius: var(--radius-sm);
    padding: 7px 16px;
    font-size: 0.84rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

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

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

.btn-sm {
    padding: 4px 10px;
    font-size: 0.76rem;
}

/* Forms */
.form-label {
    font-weight: 600;
    font-size: 0.8rem;
    color: #334155;
    margin-bottom: 4px;
}

.form-control, .form-select {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    padding: 7px 12px;
    font-size: 0.86rem;
    color: var(--text-main);
    background-color: #fff;
    transition: all 0.2s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
    outline: none;
}

/* Footer */
.erp-footer {
    padding: 16px 24px;
    background: #ffffff;
    border-top: 1px solid var(--border-subtle);
    color: var(--text-muted);
    font-size: 0.8rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 4px;
    margin-top: auto;
    width: 100%;
}

/* ==========================================================================
   Comprehensive Responsive Breakpoints (Mobile, Tablet, Desktop)
   ========================================================================== */

/* Large Tablets & Small Laptops (< 1200px) */
@media (max-width: 1199px) {
    .kpi-value {
        font-size: 1.2rem;
    }
}

/* Tablets (< 992px) */
@media (max-width: 991.98px) {
    .erp-sidebar {
        transform: translateX(-100%);
    }
    .erp-sidebar.show {
        transform: translateX(0);
        box-shadow: 0 0 25px rgba(0, 0, 0, 0.35);
    }
    .erp-main {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(15, 23, 42, 0.6);
        backdrop-filter: blur(2px);
        z-index: 1030;
        display: none;
    }
    .sidebar-overlay.show {
        display: block;
    }
    .erp-header {
        padding: 0 16px;
    }
    .erp-content {
        padding: 16px;
    }
    .page-title {
        font-size: 1.2rem;
    }
}

/* Mobile Phones (< 768px) */
@media (max-width: 767.98px) {
    .erp-header {
        height: 56px;
        padding: 0 12px;
    }
    .erp-content {
        padding: 12px;
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        margin-bottom: 16px;
    }
    .page-header > div:last-child {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    .page-header > div:last-child .btn {
        flex: 1 1 auto;
        justify-content: center;
    }
    .date-badge {
        font-size: 0.72rem;
        padding: 4px 8px;
    }
    .kpi-card {
        padding: 10px 12px;
    }
    .kpi-icon-box {
        width: 36px;
        height: 36px;
        font-size: 0.95rem;
    }
    .kpi-value {
        font-size: 1.15rem;
    }
    .kpi-title {
        font-size: 0.72rem;
    }
    .card-header {
        padding: 10px 12px;
        font-size: 0.86rem;
    }
    .card-body {
        padding: 12px;
    }
    .donut-legend li {
        font-size: 0.72rem;
    }
    .erp-footer {
        flex-direction: column;
        gap: 6px;
        text-align: center;
        padding: 12px;
    }
    .custom-kpi-card {
        max-width: 100% !important;
    }
}

/* Extra Small Phones (< 576px) */
@media (max-width: 575.98px) {
    .kpi-card-top {
        gap: 8px;
    }
    .kpi-icon-box {
        display: none; /* Hide icon on extra small screens for ultra compact presentation */
    }
}

/* Table Responsive & Actions Helpers */
.table-responsive {
    border-radius: var(--radius-md);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    max-width: 100%;
}

.table td .btn-group,
.table td .actions-inline,
.table td.actions-cell,
.table td:last-child {
    white-space: nowrap !important;
}

/* Modern Custom Scrollbar for Responsive Tables */
.table-responsive::-webkit-scrollbar {
    height: 6px;
    width: 6px;
}

.table-responsive::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Custom Workspace Navigation Tabs */
.workspace-tabs {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    gap: 8px;
    border-bottom: 2px solid #e2e8f0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.workspace-tabs .nav-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #64748b;
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.workspace-tabs .nav-link:hover {
    color: #2563eb;
}

.workspace-tabs .nav-link.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
}
