/* * SOFDAX ENTERPRISE DESIGN SYSTEM v5.0
 * Supports: Dark Mode, Print Layouts, Analytics, Data Grids
 */

:root {
    /* Color Palette - Light Mode */
    --primary: #4338ca; --primary-hover: #3730a3; --primary-light: #e0e7ff;
    --bg-body: #f8fafc; --bg-card: #ffffff; --bg-sidebar: #0f172a;
    --text-main: #1e293b; --text-muted: #64748b; --text-inv: #ffffff;
    --border: #e2e8f0; --border-focus: #4f46e5;
    
    /* Semantic Colors */
    --success: #10b981; --success-bg: #dcfce7; --success-text: #14532d;
    --warning: #f59e0b; --warning-bg: #fef9c3; --warning-text: #713f12;
    --danger: #ef4444; --danger-bg: #fee2e2; --danger-text: #7f1d1d;
    --info: #3b82f6; --info-bg: #dbeafe; --info-text: #1e3a8a;

    /* Metrics */
    --sidebar-w: 260px; --header-h: 64px;
    --radius-sm: 4px; --radius-md: 8px; --radius-lg: 12px;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --font-main: 'Inter', system-ui, sans-serif;
}

/* Dark Mode Variables */
[data-theme="dark"] {
    --bg-body: #0f172a; --bg-card: #1e293b; --bg-sidebar: #020617;
    --text-main: #f1f5f9; --text-muted: #94a3b8;
    --border: #334155;
    --primary-light: #1e1b4b;
    --success-bg: #064e3b; --success-text: #6ee7b7;
    --warning-bg: #451a03; --warning-text: #fcd34d;
    --danger-bg: #450a0a; --danger-text: #fca5a5;
    --info-bg: #172554; --info-text: #93c5fd;
}

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: var(--font-main); background: var(--bg-body); color: var(--text-main);
    line-height: 1.5; font-size: 0.95rem; transition: background 0.3s, color 0.3s;
}

/* Layout */
.app-container { display: flex; min-height: 100vh; }
.main-content { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; transition: margin 0.3s; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-w); background: var(--bg-sidebar); color: var(--text-inv);
    position: fixed; height: 100vh; left: 0; top: 0; z-index: 50; display: flex; flex-direction: column;
    border-right: 1px solid var(--border);
}
.brand-area { height: var(--header-h); display: flex; align-items: center; padding: 0 1.5rem; border-bottom: 1px solid rgba(255,255,255,0.1); font-weight: 800; letter-spacing: 1px; color: #818cf8; }
.nav-menu { padding: 1.5rem 1rem; flex: 1; list-style: none; overflow-y: auto; }
.nav-item { margin-bottom: 0.5rem; }
.nav-link {
    display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem;
    color: #94a3b8; border-radius: var(--radius-md); text-decoration: none; transition: 0.2s;
    font-weight: 500; cursor: pointer;
}
.nav-link:hover, .nav-link.active { background: var(--primary); color: #fff; }
.nav-link svg { width: 20px; height: 20px; }

/* Top Header */
.topbar {
    height: var(--header-h); background: var(--bg-card); border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center; padding: 0 2rem;
    position: sticky; top: 0; z-index: 40; transition: background 0.3s;
}

/* Content Body */
.page-content { padding: 2rem; max-width: 1600px; margin: 0 auto; width: 100%; }

/* Cards */
.card {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow); padding: 1.5rem; margin-bottom: 1.5rem; transition: background 0.3s, border 0.3s;
}
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border); padding-bottom: 1rem; }
.card h3 { font-size: 1.1rem; font-weight: 600; color: var(--text-main); }

/* Grid System */
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.5rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 1.5rem; }

/* Stat Cards */
.stat-box { background: var(--bg-card); border: 1px solid var(--border); padding: 1.5rem; border-radius: var(--radius-lg); position: relative; overflow: hidden; }
.stat-box h4 { font-size: 0.8rem; text-transform: uppercase; color: var(--text-muted); margin-bottom: 0.5rem; }
.stat-box .val { font-size: 2rem; font-weight: 800; color: var(--text-main); }
.stat-box .trend { font-size: 0.85rem; margin-top: 0.5rem; display: flex; align-items: center; gap: 4px; }
.trend.up { color: var(--success); } .trend.down { color: var(--danger); }

/* Forms & Inputs */
.form-control {
    width: 100%; padding: 0.65rem 1rem; border: 1px solid var(--border); background: var(--bg-body);
    color: var(--text-main); border-radius: var(--radius-md); font-size: 0.9rem; transition: 0.2s;
}
.form-control:focus { outline: none; border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15); }
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    padding: 0.65rem 1.25rem; font-size: 0.9rem; font-weight: 600; border-radius: var(--radius-md);
    border: 1px solid transparent; cursor: pointer; transition: 0.2s; text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text-main); }
.btn-outline:hover { background: var(--bg-body); }
.btn-danger { background: var(--danger-bg); color: var(--danger-text); }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }

/* Data Tables */
.datatable-wrapper { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--bg-card); }
.toolbar { padding: 1rem; background: var(--bg-body); border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 1rem; background: var(--bg-body); border-bottom: 1px solid var(--border); font-size: 0.8rem; text-transform: uppercase; color: var(--text-muted); cursor: pointer; user-select: none; }
th:hover { color: var(--primary); }
td { padding: 1rem; border-bottom: 1px solid var(--border); color: var(--text-main); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--primary-light); }

/* Badges */
.badge { padding: 2px 8px; border-radius: 99px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; display: inline-block; }
.b-active { background: var(--success-bg); color: var(--success-text); }
.b-warn { background: var(--warning-bg); color: var(--warning-text); }
.b-err { background: var(--danger-bg); color: var(--danger-text); }
.b-info { background: var(--info-bg); color: var(--info-text); }

/* Charts (CSS Only Implementation) */
.bar-chart { display: flex; align-items: flex-end; gap: 10px; height: 200px; padding-top: 20px; }
.bar-col { flex: 1; background: var(--primary-light); border-radius: 4px 4px 0 0; position: relative; transition: height 0.5s; }
.bar-col:hover { background: var(--primary); }
.bar-val { position: absolute; top: -20px; left: 50%; transform: translateX(-50%); font-size: 0.75rem; color: var(--text-muted); }
.bar-label { position: absolute; bottom: -25px; left: 50%; transform: translateX(-50%); font-size: 0.75rem; color: var(--text-muted); }

/* Calendar */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border); margin-top: 1rem; }
.cal-day { background: var(--bg-card); min-height: 100px; padding: 0.5rem; position: relative; }
.cal-header { background: var(--bg-body); padding: 0.5rem; text-align: center; font-weight: 700; font-size: 0.8rem; }
.cal-event { font-size: 0.7rem; padding: 2px 4px; background: var(--warning-bg); color: var(--warning-text); border-radius: 2px; margin-top: 2px; cursor: pointer; }

/* Modals */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(2px); z-index: 100; display: none; place-items: center; opacity: 0; transition: 0.2s; }
.modal-backdrop.active { opacity: 1; display: grid; }
.modal { background: var(--bg-card); padding: 2rem; border-radius: var(--radius-lg); width: 100%; max-width: 550px; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1); transform: translateY(20px); transition: 0.2s; }
.modal-backdrop.active .modal { transform: translateY(0); }

/* Switch Toggle */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background-color: var(--border); border-radius: 22px; transition: .4s; }
.slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px; background-color: white; border-radius: 50%; transition: .4s; }
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(18px); }

/* Utilities */
.hidden { display: none !important; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 0.5rem; }
.text-right { text-align: right; }
.mt-4 { margin-top: 1rem; }

/* Toast */
#toast { position: fixed; bottom: 2rem; right: 2rem; background: var(--bg-sidebar); color: #fff; padding: 1rem 1.5rem; border-radius: var(--radius-md); z-index: 200; transform: translateY(100%); opacity: 0; transition: 0.3s; }
#toast.visible { transform: translateY(0); opacity: 1; }

@media (max-width: 1024px) {
    .main-content { margin-left: 0; }
    .sidebar { transform: translateX(-100%); transition: 0.3s; }
    .sidebar.open { transform: translateX(0); }
    .grid-4, .grid-2 { grid-template-columns: 1fr; }
}