/* ============================================================
   ERP SaaS - Main Stylesheet
   ============================================================ */

:root {
    --sidebar-width: 260px;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active: #1d4ed8;
    --sidebar-text: #94a3b8;
    --sidebar-text-bright: #f1f5f9;
    --sidebar-label: #475569;
    --topbar-height: 60px;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --body-bg: #f1f5f9;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text-muted: #64748b;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

body {
    font-family: var(--font);
    background: var(--body-bg);
    color: #1e293b;
    margin: 0;
    padding: 0;
    font-size: 14px;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.app-wrapper {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.3s ease;
    z-index: 100;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: #334155; border-radius: 2px; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 16px;
    border-bottom: 1px solid #1e293b;
    text-decoration: none;
    flex-shrink: 0;
}

.sidebar-brand-icon {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    flex-shrink: 0;
}

.sidebar-brand-text {
    color: var(--sidebar-text-bright);
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.3px;
}

.sidebar-company {
    padding: 12px 16px;
    background: #1e293b;
    border-bottom: 1px solid #334155;
    flex-shrink: 0;
}

.sidebar-company small {
    display: block;
    color: var(--sidebar-label);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 2px;
}

.sidebar-company-name {
    color: var(--sidebar-text-bright);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav {
    flex: 1;
    padding: 8px 0;
    overflow-y: auto;
}

.nav-section { padding: 16px 16px 4px; }

.nav-section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--sidebar-label);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.15s ease;
    font-size: 13.5px;
    position: relative;
}

.sidebar-link:hover { color: var(--sidebar-text-bright); background: var(--sidebar-hover); }

.sidebar-link.active {
    color: white;
    background: var(--sidebar-active);
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: #93c5fd;
    border-radius: 0 2px 2px 0;
}

.sidebar-link i { width: 18px; text-align: center; flex-shrink: 0; font-size: 14px; }

.sidebar-sub { list-style: none; padding: 0; margin: 0; display: none; }
.sidebar-sub.show { display: block; }
.sidebar-sub .sidebar-link { padding-left: 44px; font-size: 13px; }

.sidebar-toggle-btn { cursor: pointer; justify-content: space-between; }
.sidebar-toggle-btn .arrow { font-size: 10px; transition: transform 0.2s; margin-left: auto; }
.sidebar-toggle-btn.open .arrow { transform: rotate(90deg); }

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid #1e293b;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.sidebar-footer-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

.sidebar-footer-info { flex: 1; min-width: 0; }
.sidebar-footer-name { color: var(--sidebar-text-bright); font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer-role { color: var(--sidebar-label); font-size: 11px; }

.sidebar-footer-logout { color: var(--sidebar-text); text-decoration: none; padding: 6px; border-radius: 6px; }
.sidebar-footer-logout:hover { color: var(--danger); background: rgba(239,68,68,0.1); }

/* ============================================================
   MAIN CONTENT / TOPBAR / PAGE
   ============================================================ */
.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

.topbar {
    height: var(--topbar-height);
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.topbar-toggle { background: none; border: none; color: #64748b; cursor: pointer; padding: 6px; border-radius: 6px; font-size: 18px; line-height: 1; }
.topbar-toggle:hover { background: var(--body-bg); color: #1e293b; }

.topbar-breadcrumb { flex: 1; font-size: 13px; }
.topbar-breadcrumb .breadcrumb { margin: 0; background: none; padding: 0; }
.topbar-breadcrumb .breadcrumb-item { color: var(--text-muted); }
.topbar-breadcrumb .breadcrumb-item + .breadcrumb-item::before { color: var(--text-muted); }
.topbar-breadcrumb .breadcrumb-item.active { color: #1e293b; font-weight: 600; }
.topbar-breadcrumb a { color: var(--primary); text-decoration: none; }

.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-date { color: var(--text-muted); font-size: 12.5px; }

.page-content { flex: 1; overflow-y: auto; padding: 24px; }

/* ============================================================
   CARDS
   ============================================================ */
.card { border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }

.card-header {
    background: white;
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
    border-radius: 10px 10px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-header h5 { margin: 0; font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.stat-icon {
    width: 52px; height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-icon.bg-primary-soft { background: #eff6ff; color: var(--primary); }
.stat-icon.bg-success-soft { background: #ecfdf5; color: var(--success); }
.stat-icon.bg-warning-soft { background: #fffbeb; color: var(--warning); }
.stat-icon.bg-danger-soft  { background: #fef2f2; color: var(--danger); }
.stat-icon.bg-info-soft    { background: #ecfeff; color: var(--info); }

.stat-info { flex: 1; min-width: 0; }
.stat-value { font-size: 24px; font-weight: 700; color: #1e293b; line-height: 1; }
.stat-label { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }

/* ============================================================
   TABLES
   ============================================================ */
.table { font-size: 13.5px; margin: 0; }

.table th {
    background: #f8fafc;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td { padding: 12px 16px; vertical-align: middle; border-bottom: 1px solid #f1f5f9; }
.table tbody tr:hover { background: #f8fafc; }
.table tbody tr:last-child td { border-bottom: none; }

/* ============================================================
   BADGES
   ============================================================ */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-active   { background: #ecfdf5; color: #059669; }
.badge-inactive { background: #f1f5f9; color: #64748b; }
.badge-pending  { background: #fffbeb; color: #d97706; }
.badge-approved { background: #ecfdf5; color: #059669; }
.badge-rejected { background: #fef2f2; color: #dc2626; }
.badge-draft    { background: #f1f5f9; color: #64748b; }
.badge-present  { background: #ecfdf5; color: #059669; }
.badge-absent   { background: #fef2f2; color: #dc2626; }
.badge-late     { background: #fffbeb; color: #d97706; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn { border-radius: 7px; font-size: 13.5px; font-weight: 500; padding: 7px 14px; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-icon { width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 7px; }

/* ============================================================
   FORMS
   ============================================================ */
.form-control, .form-select {
    border-radius: 7px;
    border-color: var(--border);
    font-size: 13.5px;
    padding: 8px 12px;
}

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

.form-label { font-size: 13px; font-weight: 500; color: #374151; margin-bottom: 5px; }

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

.page-title { font-size: 20px; font-weight: 700; color: #1e293b; margin: 0; }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin: 2px 0 0; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state i { font-size: 48px; margin-bottom: 12px; opacity: 0.4; display: block; }
.empty-state h6 { font-size: 15px; color: #374151; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f172a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 420px;
    padding: 40px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.3);
}

.login-logo {
    width: 56px; height: 56px;
    background: var(--primary);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    color: white;
    margin: 0 auto 20px;
}

.login-title { font-size: 22px; font-weight: 700; color: #1e293b; text-align: center; }
.login-subtitle { font-size: 13px; color: var(--text-muted); text-align: center; margin-bottom: 28px; }

/* ============================================================
   AVATAR
   ============================================================ */
.avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

/* ============================================================
   SIDEBAR COLLAPSED
   ============================================================ */
.sidebar.collapsed { width: 60px; }
.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .sidebar-company,
.sidebar.collapsed .sidebar-link span,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .sidebar-footer-info,
.sidebar.collapsed .arrow { display: none; }

@media (max-width: 768px) {
    .sidebar { position: fixed; left: -260px; height: 100vh; }
    .sidebar.mobile-open { left: 0; box-shadow: 0 0 30px rgba(0,0,0,0.4); }
    .page-content { padding: 16px; }
}

a, button { transition: all 0.15s ease; }
