/* Enterprise ERP Core Styles */
:root {
    --primary-color: #4F46E5; /* Indigo 600 */
    --primary-hover: #4338CA;
    --bg-dark: #0F172A; /* Slate 900 */
    --bg-glass: rgba(30, 41, 59, 0.7);
    --border-glass: rgba(255, 255, 255, 0.1);
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    --input-bg: rgba(15, 23, 42, 0.6);
    --focus-ring: rgba(79, 70, 229, 0.5);
}

/* Global Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #10B981;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    gap: 8px;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999;
}
.toast.show {
    transform: translateY(0);
    opacity: 1;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-image: 
        radial-gradient(at 0% 0%, hsla(253,16%,7%,1) 0, transparent 50%), 
        radial-gradient(at 50% 0%, hsla(225,39%,30%,0.2) 0, transparent 50%), 
        radial-gradient(at 100% 0%, hsla(339,49%,30%,0.2) 0, transparent 50%);
    background-attachment: fixed;
}

/* Glassmorphism Container */
.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
    animation: fadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.glass-card {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: 24px;
    padding: 40px 30px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.logo-container {
    text-align: center;
    margin-bottom: 30px;
}

.logo-icon {
    font-size: 3rem;
    margin-bottom: 10px;
    animation: float 3s ease-in-out infinite;
}

.logo-container h2 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    margin-bottom: 5px;
}

.logo-container p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Form Styles */
.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-muted);
}

.input-group input, .input-group select, .input-group textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--input-bg);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    color: white;
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.input-group input:focus, .input-group select:focus, .input-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    font-size: 0.875rem;
}

.remember-me {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    cursor: pointer;
}

.forgot-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s;
}

.forgot-link:hover {
    color: #818cf8;
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.4);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.5);
}

.btn-primary:active {
    transform: translateY(0);
}

.form-footer {
    margin-top: 30px;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Animations */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .glass-card {
        padding: 30px 20px;
        border-radius: 20px;
        border: none;
        background: transparent;
        box-shadow: none;
    }
    
    body {
        background-color: #0F172A; /* Solid for mobile app feel */
        background-image: none;
        align-items: flex-start;
        padding-top: 5vh;
    }
}
    
.sidebar-overlay, .mobile-bottom-nav {
    display: none;
}

/* Dashboard Layout */
.dashboard-body {
    display: flex;
    padding: 0;
    align-items: stretch;
    justify-content: flex-start;
}

.sidebar {
    width: 260px;
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    border-right: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-logo {
    padding: 0 24px 30px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo h2 {
    font-size: 1.2rem;
    font-weight: 700;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 16px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text-muted);
    border-radius: 12px;
    transition: all 0.2s;
    font-weight: 500;
}

.nav-item:hover, .nav-item.active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.nav-item.active {
    background: rgba(79, 70, 229, 0.15);
    color: var(--primary-color);
    border: 1px solid rgba(79, 70, 229, 0.3);
}

.sidebar-footer {
    padding: 24px 16px 0;
    border-top: 1px solid var(--border-glass);
}

.text-danger:hover {
    color: #EF4444;
    background: rgba(239, 68, 68, 0.1);
}

.main-content {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-header {
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-glass);
    position: sticky;
    top: 0;
    z-index: 50;
}

.search-bar input {
    background: var(--input-bg);
    border: 1px solid var(--border-glass);
    padding: 10px 16px;
    border-radius: 20px;
    color: white;
    width: 300px;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 24px;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.2s;
}

.icon-btn:hover {
    color: white;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

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

.user-info {
    display: flex;
    flex-direction: column;
    white-space: nowrap;
}

.user-info strong {
    font-size: 0.875rem;
}

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

.content-wrapper {
    padding: 40px;
    flex: 1;
}

.page-header {
    margin-bottom: 30px;
}

.page-header h1 {
    font-size: 1.8rem;
    margin-bottom: 8px;
}

.page-header p {
    color: var(--text-muted);
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.kpi-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    padding: 24px;
}

.kpi-header {
    display: flex;
    justify-content: space-between;
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 16px;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.kpi-trend {
    font-size: 0.875rem;
}

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

.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

.panel {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    padding: 24px;
}

.panel h3 {
    margin-bottom: 20px;
    font-size: 1.1rem;
}

.empty-state {
    text-align: center;
    padding: 40px 0;
    color: var(--text-muted);
}

.health-status {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.status-indicator.active {
    background: #10B981;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

/* Dashboard Mobile View */
@media (max-width: 768px) {
    .dashboard-body {
        flex-direction: column;
    }
    
    .sidebar-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s, visibility 0.3s;
    }
    
    .sidebar-open .sidebar-overlay {
        opacity: 1;
        visibility: visible;
    }
    
    .mobile-bottom-nav {
        display: flex;
        width: 100%;
        position: fixed;
        bottom: 0;
        left: 0;
        flex-direction: row;
        justify-content: flex-start;
        padding: 12px 16px;
        background: rgba(15, 23, 42, 0.95);
        border-top: 1px solid var(--border-glass);
        z-index: 900;
        overflow-x: auto;
        gap: 8px;
        -ms-overflow-style: none;
        scrollbar-width: none;
        backdrop-filter: blur(16px);
    }
    
    .mobile-bottom-nav::-webkit-scrollbar {
        display: none;
    }
    
    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 8px 12px;
        border-radius: 12px;
        color: var(--text-muted);
        text-decoration: none;
        transition: all 0.2s;
        min-width: 64px;
        gap: 4px;
    }
    
    .mobile-nav-item .nav-text {
        display: block;
        font-size: 0.65rem;
        white-space: nowrap;
        text-align: center;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 64px;
    }
    
    .mobile-nav-item .nav-icon {
        width: 20px;
        height: 20px;
    }
    
    .mobile-nav-item.active {
        background: rgba(79, 70, 229, 0.15);
        color: var(--primary-color);
        border: 1px solid rgba(79, 70, 229, 0.3);
    }
    
    .sidebar {
        width: 260px;
        height: 100vh;
        position: fixed;
        top: 0;
        left: 0;
        bottom: auto;
        flex-direction: column;
        padding: 24px 0;
        border-right: 1px solid var(--border-glass);
        border-top: none;
        z-index: 1000;
        background: rgba(15, 23, 42, 0.98);
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
    }
    
    .sidebar-open .sidebar {
        transform: translateX(0);
    }
    
    .mobile-menu-btn {
        display: block !important;
        margin-left: 12px;
    }
    
    .sidebar-nav {
        flex-direction: column;
        justify-content: flex-start;
        padding: 0 16px;
        overflow-y: auto;
        gap: 8px;
    }
    
    .nav-item {
        padding: 12px 16px;
        border-radius: 12px;
    }
    
    .main-content {
        margin-left: 0;
        padding-bottom: 80px;
    }
    }
    
    .top-header {
        padding: 0 20px;
    }
    
    .search-bar input {
        width: 200px;
    }
    
    .content-wrapper {
        padding: 20px;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* --- Advanced UI Components --- */
/* Tables */
.data-table-container {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    overflow: hidden;
    margin-top: 24px;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th, .data-table td {
    padding: 16px 24px;
    text-align: left;
    border-bottom: 1px solid var(--border-glass);
}
.data-table th {
    background: rgba(15, 23, 42, 0.4);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.data-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}
.data-table td {
    font-size: 0.875rem;
}

/* Badges */
.badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.badge-success { background: rgba(16, 185, 129, 0.2); color: #10B981; }
.badge-warning { background: rgba(245, 158, 11, 0.2); color: #F59E0B; }
.badge-danger { background: rgba(239, 68, 68, 0.2); color: #EF4444; }
.badge-primary { background: rgba(79, 70, 229, 0.2); color: #818CF8; }

/* Buttons */
.btn {
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}
.btn-primary {
    background: var(--primary-color);
    color: white;
}
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}
.btn-secondary:hover { background: rgba(255, 255, 255, 0.2); }
.btn-outline {
    background: transparent;
    border: 1px solid var(--border-glass);
    color: white;
}
.btn-outline:hover { background: rgba(255, 255, 255, 0.05); }

/* Flex utilities */
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-start { display: flex; justify-content: flex-start; align-items: center; gap: 12px; }

/* Grid utilities */
.grid { display: grid; }

/* Page Actions Header */
.page-actions { display: flex; gap: 12px; }

/* Grid Layouts for Modules */
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
    margin-top: 24px;
}
.project-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
}
.project-card:hover { 
    transform: translateY(-5px); 
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.5);
}
.project-image {
    width: 100%;
    height: 160px;
    background-color: rgba(0,0,0,0.2);
    background-size: cover;
    background-position: center;
    position: relative;
}
.project-image .badge {
    position: absolute;
    top: 12px;
    right: 12px;
    backdrop-filter: blur(4px);
}
.project-details { padding: 20px; }
.project-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 8px; }
.project-meta { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 16px; }
.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 8px;
}
.progress-fill {
    height: 100%;
    background: var(--primary-color);
}

/* Kanban Board for CRM */
.kanban-board {
    display: flex;
    gap: 24px;
    overflow-x: auto;
    padding-bottom: 24px;
    margin-top: 24px;
    scroll-snap-type: x mandatory; /* Mobile friendly snap scrolling */
    min-height: calc(100vh - 200px);
}
.kanban-board::-webkit-scrollbar {
    height: 8px;
}
.kanban-board::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}
.kanban-column {
    min-width: 320px;
    max-width: 320px;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 12px;
    padding: 16px;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
}
.kanban-header {
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.kanban-column-content {
    flex-grow: 1;
    min-height: 100px;
}
.kanban-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    cursor: grab;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.kanban-card:active {
    cursor: grabbing;
}
.kanban-card:hover {
    border-color: rgba(255,255,255,0.2);
    transform: translateY(-2px);
}
.kanban-card h4 { margin-bottom: 6px; font-size: 1rem; color: #fff; }
.kanban-card p { font-size: 0.85rem; color: #94A3B8; margin-bottom: 16px; line-height: 1.4;}
.kanban-card-footer { display: flex; justify-content: space-between; align-items: center; font-size: 0.75rem; border-top: 1px solid rgba(255,255,255,0.05); padding-top: 12px; }

/* SortableJS drag classes */
.sortable-ghost {
    opacity: 0.4;
    background: rgba(255,255,255,0.05);
    border: 2px dashed var(--primary-color);
}
.sortable-drag {
    cursor: grabbing !important;
}

/* Ledger Table */
.text-positive { color: #10B981; font-weight: 600; }
.text-negative { color: #EF4444; font-weight: 600; }

/* Rules Visual Hierarchy */
.tree-node {
    padding: 16px;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.tree-node.level-1 { border-left: 4px solid #4F46E5; }
.tree-node.level-2 { margin-left: 24px; border-left: 4px solid #818CF8; }
.tree-node.level-3 { margin-left: 48px; border-left: 4px solid #C7D2FE; }
.tree-node.level-4 { margin-left: 72px; border-left: 4px solid #E0E7FF; }

/* Charts Container */
.chart-container {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    padding: 24px;
    margin-top: 24px;
    position: relative;
    width: 100%;
}
.chart-wrapper {
    position: relative;
    height: 300px;
    width: 100%;
}

/* --- Slide-Over Panel --- */
.slide-over-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.slide-over-overlay.open {
    display: block;
    opacity: 1;
}
.slide-over-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    height: 100%;
    background: var(--bg-dark);
    border-left: 1px solid var(--border-glass);
    box-shadow: -5px 0 25px rgba(0,0,0,0.5);
    z-index: 1001;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}
.slide-over-panel.open {
    transform: translateX(0);
}
.slide-over-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255,255,255,0.02);
}
.slide-over-body {
    padding: 24px;
    flex-grow: 1;
    overflow-y: auto;
}
.slide-over-footer {
    padding: 24px;
    border-top: 1px solid var(--border-glass);
    background: rgba(255,255,255,0.02);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* --- Mobile Specific Overrides --- */
@media (max-width: 768px) {
    .slide-over-panel {
        width: 100%;
        right: 0;
    }
    .top-header {
        padding: 12px 16px;
        height: auto;
        flex-direction: column-reverse;
        gap: 12px;
        align-items: stretch;
    }
    .header-actions {
        justify-content: space-between;
        width: 100%;
    }
    .search-bar {
        width: 100%;
    }
    .search-bar input {
        width: 100%;
    }
    .content-wrapper {
        padding: 24px 16px;
    }
    .panel {
        padding: 16px !important;
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    .page-actions {
        width: 100%;
        justify-content: space-between;
    }
    .data-table-container {
        overflow-x: auto;
    }
    .kpi-grid {
        grid-template-columns: 1fr;
    }
    .sidebar-nav {
        overflow-x: auto;
        justify-content: flex-start;
        gap: 16px;
        padding: 0 16px;
    }
    .sidebar-nav::-webkit-scrollbar {
        display: none;
    }
}

/* Stat Cards */
.stat-card {
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.7) 0%, rgba(15, 23, 42, 0.9) 100%);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease;
}
.stat-card:hover {
    transform: translateY(-5px);
    border-color: rgba(255, 255, 255, 0.1);
}
.stat-card::after {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 150px; height: 150px;
    background: radial-gradient(circle, var(--primary-color) 0%, transparent 70%);
    opacity: 0.05;
    border-radius: 50%;
    transform: translate(30%, -30%);
}
.stat-icon {
    background: rgba(212, 175, 55, 0.1);
    color: var(--primary-color);
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 16px;
}
.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    margin: 8px 0;
}
.stat-trend.positive { color: #10B981; }
.stat-trend.negative { color: #EF4444; }
