/* Dark Mode Variables - Modernize Theme Based */
[data-theme="dark"] {
    --body-bg: #2A3447;
    --card-bg: #2A3447;
    --text-primary: #EAEFF4;
    --text-secondary: #7C8FAC;
    --text-muted: #5A6A85;
    --border-color: #333F55;
    --divider: #333F55;
    --sidebar-bg: #2A3447;
    --sidebar-text: #EAEFF4;
    --sidebar-active-bg: #5D87FF;
    --sidebar-active-text: #ffffff;
    --header-bg: #2A3447;
    --header-shadow: 0px 1px 4px rgba(0,0,0,0.2);
    --input-bg: #2A3447;
}

[data-theme="dark"] .es-header,
[data-theme="dark"] .es-sidebar,
[data-theme="dark"] .es-card {
    background-color: var(--card-bg);
}

[data-theme="dark"] .es-input,
[data-theme="dark"] .es-search-input {
    background-color: #333F55;
    border-color: #465670;
    color: #EAEFF4;
}

[data-theme="dark"] .es-table th {
    background-color: #333F55;
    color: #EAEFF4;
}

[data-theme="dark"] .es-table tr:hover {
    background-color: #333F55;
}

[data-theme="dark"] .es-icon-btn:hover {
    background-color: #333F55;
}

[data-theme="dark"] .es-welcome-banner {
    background: linear-gradient(135deg, #1A2536 0%, #15202B 100%);
}

/* Modal Styles */
.es-modal {
    display: none;
    position: fixed;
    z-index: 1050;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
}

.es-modal-content {
    background-color: var(--card-bg);
    margin: 5% auto;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    width: 90%;
    max-width: 500px;
    position: relative;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { transform: translateY(-30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.es-close {
    color: var(--text-muted);
    float: left; /* RTL left */
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.es-close:hover {
    color: var(--primary);
}

.es-form-group {
    margin-bottom: 20px;
}

.es-form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
}

.es-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 7px;
    background: #fff;
    color: var(--text-primary);
    font-family: 'Heebo', sans-serif;
    font-size: 14px;
    transition: all 0.2s;
}

.es-input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(93,135,255,0.1);
}

/* Original Styles Below */
:root {
  /* Modernize Color Palette */
  --primary: #5D87FF;
  --primary-light: #ECF2FF;
  --primary-dark: #4570EA;
  
  --secondary: #49BEFF;
  --secondary-light: #E8F7FF;
  
  --success: #13DEB9;
  --success-light: #E6FFFA;
  
  --warning: #FFAE1F;
  --warning-light: #FEF5E5;
  
  --danger: #FA896B;
  --danger-light: #FDEDE8;
  
  --body-bg: #F0F5F9; /* Light greyish blue */
  --card-bg: #FFFFFF;
  --sidebar-bg: #FFFFFF;
  --sidebar-text: #2A3547;
  --sidebar-active-bg: #5D87FF;
  --sidebar-active-text: #ffffff;
  
  --text-primary: #2A3547;
  --text-secondary: #5A6A85;
  --text-muted: #7C8FAC;
  
  --border-color: #EAEFF4;
  --divider: #EAEFF4;
  
  /* Brand Override */
  --brand-navy: #1B365D;
  --brand-gold: #C8A951;
  
  /* Shadows */
  --card-shadow: 0px 7px 30px rgba(90, 114, 123, 0.04);
  --header-shadow: 0px 1px 4px rgba(0,0,0,0.05);
}

* { box-sizing: border-box; }

body {
    background-color: var(--body-bg);
    font-family: 'Heebo', sans-serif;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    margin: 0;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Rubik', sans-serif;
    color: var(--text-primary);
    margin-top: 0;
}

a { text-decoration: none; transition: all 0.2s; }

/* === LAYOUT STRUCTURE === */

/* Sidebar (Right) */
.es-sidebar {
    width: 270px;
    background: var(--sidebar-bg);
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    z-index: 100;
    overflow-y: auto;
    transition: width 0.3s, transform 0.3s;
    border-left: 1px solid var(--border-color);
}

.es-sidebar-header {
    height: 70px;
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 12px;
}

.es-logo-symbol {
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: #fff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
}

.es-logo-text {
    font-family: 'Rubik', sans-serif;
    font-weight: 700;
    font-size: 20px;
    color: var(--text-primary);
}

.es-nav-menu {
    padding: 16px;
}

.es-nav-category {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-primary);
    padding: 12px 14px 8px;
    font-weight: 700;
    opacity: 0.7;
}

.es-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: var(--sidebar-text);
    font-size: 14px;
    border-radius: 7px;
    margin-bottom: 4px;
    font-weight: 400;
}

.es-nav-item i {
    font-size: 20px;
}

.es-nav-item:hover {
    background: rgba(93,135,255,0.1);
    color: var(--primary);
}

.es-nav-item.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    box-shadow: 0 4px 10px rgba(93,135,255,0.3);
}

.es-nav-item.active i {
    color: var(--sidebar-active-text);
}

.es-sidebar-footer {
    padding: 20px;
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0,0,0,0.02);
}

/* Header (Top) */
.es-header {
    position: fixed;
    top: 0;
    right: 270px;
    left: 0;
    height: 70px;
    background: #fff;
    /* box-shadow: var(--header-shadow); */
    z-index: 99;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    transition: right 0.3s;
}

.es-header-left, .es-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.es-toggle-sidebar {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 22px;
    color: var(--text-primary);
    padding: 4px;
}

.es-breadcrumb {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.es-search-box {
    position: relative;
    display: none; /* Hidden on mobile by default */
}

@media(min-width: 768px) {
    .es-search-box { display: block; }
}

.es-search-input {
    background: var(--body-bg);
    border: none;
    padding: 8px 36px 8px 16px;
    border-radius: 7px;
    width: 200px;
    font-size: 14px;
    color: var(--text-primary);
}

.es-search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.es-icon-btn {
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 22px;
    color: var(--text-secondary);
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.es-icon-btn:hover {
    background: rgba(93,135,255,0.1);
    color: var(--primary);
}

.es-badge-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid #fff;
}

.es-user-avatar-sm img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

/* Main Content */
.es-main-content {
    margin-right: 270px;
    padding: 94px 24px 24px; /* 70px header + 24px padding */
    min-height: 100vh;
    transition: margin-right 0.3s;
}

/* === COMPONENTS === */

/* Cards */
.es-card {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    padding: 24px;
    margin-bottom: 24px;
    position: relative;
    border: none;
    overflow: hidden;
}

.es-card-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.es-card-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.es-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

/* Welcome Banner */
.es-welcome-banner {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 12px;
    padding: 40px;
    color: #fff;
    position: relative;
    overflow: hidden;
    min-height: 180px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    box-shadow: 0 10px 20px rgba(93,135,255,0.2);
}

.es-welcome-text h2 {
    color: #fff;
    font-size: 28px;
    margin-bottom: 8px;
    font-weight: 700;
}

.es-welcome-text p {
    color: rgba(255,255,255,0.9);
    font-size: 16px;
    margin-bottom: 24px;
}

.es-welcome-date {
    background: rgba(0,0,0,0.1);
    display: inline-block;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 20px;
}

.es-btn-gold {
    background: #fff;
    color: var(--primary);
    padding: 10px 24px;
    border-radius: 7px;
    font-weight: 600;
    display: inline-block;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    border: none;
    cursor: pointer;
    transition: transform 0.2s;
}

.es-btn-gold:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.15);
}

.es-btn-sm {
    padding: 6px 16px;
    font-size: 13px;
    background: var(--primary);
    color: white;
}

.es-btn-sm:hover {
    background: var(--primary-dark);
}

/* KPI Stats */
.es-kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    margin-bottom: 24px;
}

.es-kpi-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 30px 24px;
}

.es-kpi-icon-box {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.es-kpi-icon-box.primary { background: var(--primary-light); color: var(--primary); }
.es-kpi-icon-box.success { background: var(--success-light); color: var(--success); }
.es-kpi-icon-box.warning { background: var(--warning-light); color: var(--warning); }
.es-kpi-icon-box.danger { background: var(--danger-light); color: var(--danger); }

.es-kpi-content h3 {
    font-size: 26px;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
}

.es-kpi-content p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
}

/* Charts Grid */
.es-charts-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

/* Activity & Tasks Grid */
.es-info-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

/* Timeline */
.es-timeline {
    position: relative;
    padding: 0;
    list-style: none;
    margin-top: 10px;
}

.es-timeline-item {
    display: flex;
    gap: 16px;
    padding-bottom: 30px;
    position: relative;
}

.es-timeline-item::before {
    content: '';
    position: absolute;
    right: 16px; /* RTL alignment */
    top: 36px;
    bottom: 0;
    width: 2px;
    background: var(--divider);
}

.es-timeline-item:last-child::before { display: none; }

.es-timeline-avatar img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.es-timeline-content {
    flex: 1;
    padding-top: 4px;
}

.es-timeline-text {
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 4px;
    display: block;
}

.es-timeline-time {
    font-size: 12px;
    color: var(--text-muted);
}

/* Task List */
.es-task-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid var(--divider);
}

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

.es-task-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.es-checkbox {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    cursor: pointer;
}

.es-task-meta {
    text-align: left;
}

.es-badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
}

.es-badge.danger { background: var(--danger-light); color: var(--danger); }
.es-badge.warning { background: var(--warning-light); color: var(--warning); }
.es-badge.success { background: var(--success-light); color: var(--success); }
.es-badge.primary { background: var(--primary-light); color: var(--primary); }

/* Tables */
.es-table-responsive {
    overflow-x: auto;
}

.es-table {
    width: 100%;
    border-collapse: collapse;
}

.es-table th {
    text-align: right;
    padding: 14px 20px;
    background: #F9FBFD;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-color);
}

.es-table td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    color: var(--text-primary);
    vertical-align: middle;
}

.es-table tr:hover {
    background: #F5F7FA;
}

.es-status-pill {
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.es-status-pill.new { background: var(--primary-light); color: var(--primary); }
.es-status-pill.contacted { background: var(--secondary-light); color: var(--secondary); }
.es-status-pill.interested { background: var(--success-light); color: var(--success); }
.es-status-pill.closed { background: #E6FFFA; color: #13DEB9; }

/* Login Page Split Layout */
.es-login-split {
    display: flex;
    min-height: 100vh;
}

.es-login-visual {
    flex: 1;
    background: url('https://images.unsplash.com/photo-1486406146926-c627a92ad1ab?q=80&w=2070&auto=format&fit=crop') no-repeat center center;
    background-size: cover;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    padding: 40px;
    position: relative;
}

.es-login-bg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(27, 54, 93, 0.9) 0%, rgba(93, 135, 255, 0.85) 100%);
    z-index: 1;
}

.es-login-form-area {
    flex: 0.8;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    max-width: 600px;
}

.es-login-box {
    width: 100%;
    max-width: 420px;
    padding: 40px;
}

.es-login-logo {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--brand-navy) 0%, var(--primary) 100%);
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 28px;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(27, 54, 93, 0.3);
}

/* === RESPONSIVE === */

/* Tablet (< 1024px) */
@media (max-width: 1024px) {
    .es-sidebar { width: 80px; }
    .es-sidebar .es-logo-text, 
    .es-sidebar .es-nav-item span,
    .es-sidebar .es-nav-category { display: none; }
    .es-sidebar .es-nav-item { justify-content: center; padding: 12px; }
    .es-sidebar .es-nav-item i { margin: 0; font-size: 24px; }
    .es-sidebar-header { justify-content: center; padding: 0; }
    .es-logo-symbol { margin: 0; }
    
    .es-header { right: 80px; width: calc(100% - 80px); }
    .es-main-content { margin-right: 80px; }
    
    .es-kpi-row { grid-template-columns: 1fr 1fr; }
    .es-charts-row { grid-template-columns: 1fr; }
}

/* Mobile (< 768px) */
@media (max-width: 768px) {
    .es-sidebar { transform: translateX(100%); width: 270px; right: -270px; }
    .es-sidebar.open { transform: translateX(0); right: 0; }
    
    .es-header { right: 0; width: 100%; padding: 0 16px; }
    .es-main-content { margin-right: 0; padding: 80px 16px 80px; }
    
    .es-kpi-row { grid-template-columns: 1fr; gap: 16px; }
    .es-info-row { grid-template-columns: 1fr; }
    
    .es-welcome-banner { flex-direction: column; align-items: start; min-height: auto; }
    .es-welcome-graphic { display: none; }
    
    .es-login-split { flex-direction: column; }
    .es-login-visual { display: none; }
    .es-login-form-area { max-width: 100%; flex: 1; }
    
    /* Bottom Nav */
    .es-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 64px;
        background: var(--card-bg);
        display: flex;
        justify-content: space-around;
        align-items: center;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
        z-index: 1000;
        border-top: 1px solid var(--border-color);
    }
    
    .es-bottom-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        color: var(--text-muted);
        font-size: 11px;
    }
    
    .es-bottom-item.active { color: var(--primary); }
    .es-bottom-item i { font-size: 22px; margin-bottom: 2px; }
    
    .es-toggle-sidebar { display: none; }
}
