/* ============================================================
   WEBLAZE ERP — Master Stylesheet
   ============================================================ */

:root {
    --sidebar-width:      240px;
    --topbar-height:      60px;
    --sidebar-bg:         #0f172a;
    --sidebar-hover:      #1e293b;
    --sidebar-active:     #3b82f6;
    --sidebar-text:       #94a3b8;
    --sidebar-text-hover: #f1f5f9;
    --topbar-bg:          #0f172a;
    --topbar-border:      #1e293b;
    --content-bg:         #f1f5f9;
    --card-bg:            #ffffff;
    --card-shadow:        0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --card-radius:        12px;
    --primary:            #3b82f6;
    --success:            #22c55e;
    --warning:            #f59e0b;
    --danger:             #ef4444;
    --info:               #06b6d4;
    --text-primary:       #0f172a;
    --text-secondary:     #64748b;
    --border-color:       #e2e8f0;
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--content-bg);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
}

/* ── Topbar ──────────────────────────────────────────────── */
.erp-topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-height);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--topbar-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 1000;
}

.erp-topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.erp-topbar-brand {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: 0.3px;
}

.erp-topbar-brand i { color: var(--primary); font-size: 1.2rem; }

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--sidebar-text);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s, color 0.2s;
    display: flex;
    align-items: center;
}
.sidebar-toggle:hover { background: var(--sidebar-hover); color: #fff; }

.erp-topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.erp-user-badge {
    display: flex;
    align-items: center;
    gap: 10px;
}

.erp-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.erp-user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.erp-user-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: #f1f5f9;
}

.erp-user-role {
    font-size: 0.72rem;
    color: var(--sidebar-text);
    text-transform: capitalize;
}

.erp-logout-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--sidebar-text);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 1rem;
    transition: background 0.2s, color 0.2s;
    flex-shrink: 0;
}
.erp-logout-btn:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

/* ── Flash Message ───────────────────────────────────────── */
.erp-flash {
    position: fixed;
    top: calc(var(--topbar-height) + 10px);
    right: 20px;
    left: 20px;
    z-index: 1100;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: slideIn 0.3s ease;
    max-width: 380px;
    margin-left: auto;
}
.erp-flash-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.erp-flash-danger  { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.erp-flash-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.erp-flash-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.erp-flash-close {
    background: none; border: none; cursor: pointer;
    margin-left: auto; font-size: 1.1rem; opacity: 0.6; padding: 0 0 0 8px;
}
.erp-flash-close:hover { opacity: 1; }

@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ── Layout ──────────────────────────────────────────────── */
.erp-layout {
    display: flex;
    padding-top: var(--topbar-height);
    min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.erp-sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    height: calc(100vh - var(--topbar-height));
    overflow: hidden;
    z-index: 999;
    transition: width 0.25s ease;
    display: flex;
    flex-direction: column;
    scrollbar-width: thin;
    scrollbar-color: #1e293b transparent;
}

.erp-sidebar:hover { overflow-y: auto; }

/* Desktop: collapsed via JS */
.erp-sidebar.collapsed {
    width: 0;
    overflow: hidden;
}

/* Mobile: hidden by default, shown when .open added */
.erp-sidebar.open {
    width: var(--sidebar-width);
    overflow-y: auto;
}

.erp-sidebar-brand {
    padding: 20px 16px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.5px;
    white-space: nowrap;
    border-bottom: 1px solid #1e293b;
    flex-shrink: 0;
}
.erp-sidebar-brand i { color: var(--primary); font-size: 1.1rem; }

.erp-sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
}

.erp-nav-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: #334155;
    padding: 8px 8px 4px;
    text-transform: uppercase;
    white-space: nowrap;
}

.erp-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 1px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.erp-nav-link i { font-size: 1rem; min-width: 18px; }
.erp-nav-link:hover { background: var(--sidebar-hover); color: var(--sidebar-text-hover); }
.erp-nav-link.active { background: var(--primary); color: #fff; }
.erp-nav-logout { color: #f87171 !important; }
.erp-nav-logout:hover { background: rgba(239,68,68,0.15) !important; color: #ef4444 !important; }

.erp-sidebar-footer {
    padding: 12px 16px;
    font-size: 0.72rem;
    color: #334155;
    border-top: 1px solid #1e293b;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ── Main Content ────────────────────────────────────────── */
.erp-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: calc(100vh - var(--topbar-height));
    transition: margin-left 0.25s ease;
    min-width: 0;
    max-width: 100%;
}

.erp-main.expanded { margin-left: 0; }

.erp-content {
    padding: 28px;
}

/* ── Page Header ─────────────────────────────────────────── */
.page-header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}
.page-header h4 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.page-header p { color: var(--text-secondary); margin: 0; font-size: 0.875rem; }

/* ── Cards ───────────────────────────────────────────────── */
.erp-card {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    padding: 20px;
    border: 1px solid var(--border-color);
}

/* ── Stat Cards ──────────────────────────────────────────── */
.stat-card {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    padding: 20px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.stat-icon {
    width: 46px; height: 46px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}
.stat-value { font-size: 1.6rem; font-weight: 800; line-height: 1.2; }
.stat-label { font-size: 0.78rem; color: var(--text-secondary); margin-top: 2px; }

/* ── Tables ──────────────────────────────────────────────── */
.erp-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; }
.erp-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; min-width: 500px; }
.erp-table th {
    background: #f8fafc;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    white-space: nowrap;
}
.erp-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text-primary);
    vertical-align: middle;
}
.erp-table tr:hover td { background: #f8fafc; }
.erp-table tr:last-child td { border-bottom: none; }

/* ── Badges ──────────────────────────────────────────────── */
.erp-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.erp-badge-success { background: #f0fdf4; color: #166534; }
.erp-badge-danger  { background: #fef2f2; color: #991b1b; }
.erp-badge-warning { background: #fffbeb; color: #92400e; }
.erp-badge-primary { background: #eff6ff; color: #1e40af; }
.erp-badge-info    { background: #ecfeff; color: #155e75; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn-erp-primary {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s, transform 0.1s;
    text-decoration: none;
}
.btn-erp-primary:hover { background: #2563eb; color: #fff; transform: translateY(-1px); }

/* ── Forms ───────────────────────────────────────────────── */
.form-control, .form-select {
    max-width: 100%;
}

/* ── 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: #fff;
    border-radius: 16px;
    padding: 40px 36px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.4);
}
.login-logo {
    width: 56px; height: 56px;
    background: var(--primary);
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem; color: #fff;
    margin: 0 auto 16px;
}
.login-title { font-size: 1.3rem; font-weight: 800; color: var(--text-primary); text-align: center; }
.login-subtitle { color: var(--text-secondary); font-size: 0.85rem; text-align: center; margin-bottom: 24px; }

/* ── Sidebar Overlay ─────────────────────────────────────── */
.erp-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 998;
}
.erp-sidebar-overlay.active { display: block; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {

    /* Sidebar hidden by default on mobile */
    .erp-sidebar {
        width: 0;
        overflow: hidden;
    }

    /* Main takes full width on mobile */
    .erp-main {
        margin-left: 0;
    }

    .erp-content {
        padding: 16px;
    }

    .erp-user-info { display: none; }
    .erp-topbar-brand span { display: none; }

    /* Cards stack on mobile */
    .stat-card { padding: 14px; }
    .stat-value { font-size: 1.3rem; }

    /* Tables scroll horizontally */
    .erp-table { min-width: 480px; }

    /* Fix Bootstrap row overflow */
    .row { margin-left: 0; margin-right: 0; }
    .row > * { padding-left: 8px; padding-right: 8px; }

    /* Page header wrap */
    .page-header { flex-direction: column; align-items: flex-start; gap: 8px; }

    /* Login card padding */
    .login-card { padding: 24px 20px; }

    /* Buttons full width on mobile forms */
    .btn-erp-primary.w-mobile { width: 100%; justify-content: center; }
}

@media (max-width: 480px) {
    .erp-content { padding: 12px; }
    .erp-card { padding: 14px; }
    .stat-value { font-size: 1.2rem; }
    .page-header h4 { font-size: 1.1rem; }
}

/* ── Attendance Calendar ─────────────────────────────────── */
.att-calendar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}
.att-day-header {
    text-align: center;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-secondary);
    padding: 6px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.att-day-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: default;
    transition: transform 0.1s;
}
.att-day-cell:hover { transform: scale(1.1); }
.att-empty    { background: transparent; }
.att-none     { background: #f1f5f9; color: #94a3b8; }
.att-present  { background: #dcfce7; color: #166534; font-weight: 700; }
.att-absent   { background: #fee2e2; color: #991b1b; font-weight: 700; }
.att-late     { background: #fef9c3; color: #854d0e; font-weight: 700; }
.att-holiday  { background: #e0f2fe; color: #075985; font-weight: 700; }
.att-today    { outline: 2px solid var(--primary); outline-offset: 1px; }

.att-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    display: inline-block;
}
.att-dot.att-present { background: #22c55e; }
.att-dot.att-absent  { background: #ef4444; }
.att-dot.att-late    { background: #eab308; }
.att-dot.att-none    { background: #e2e8f0; }