/* ========================================================
   HRPMS - Enterprise HR Performance Management System
   Mobile-First Responsive Stylesheet
   ======================================================== */

/* ---- CSS Variables / Design Tokens ---- */
:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #e0e7ff;
    --secondary: #0f172a;
    --accent: #06b6d4;
    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #dc2626;
    --info: #2563eb;

    --bg: #f1f5f9;
    --bg-white: #ffffff;
    --bg-card: #ffffff;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-white: #ffffff;

    --border: #e2e8f0;
    --border-light: #f1f5f9;

    --sidebar-width: 260px;
    --sidebar-bg: #0f172a;
    --sidebar-text: #cbd5e1;
    --sidebar-hover: #1e293b;
    --sidebar-active: #4f46e5;

    --topbar-height: 64px;
    --mobile-header-height: 56px;

    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);

    --transition: 0.2s ease;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; height: auto; }
table { border-collapse: collapse; width: 100%; }

/* ---- App Layout ---- */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ---- Mobile Header ---- */
.mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--mobile-header-height);
    background: var(--sidebar-bg);
    color: var(--text-white);
    padding: 0 1rem;
    z-index: 1001;
}
.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-white);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
}
.mobile-brand { font-weight: 700; font-size: 1.1rem; }
.user-avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-white);
}

/* ---- Sidebar ---- */
.sidebar {
    position: fixed;
    left: -var(--sidebar-width);
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    z-index: 1002;
    transform: translateX(-100%);
    transition: transform var(--transition);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.sidebar.open { transform: translateX(0); }
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1001;
}
.sidebar-overlay.active { display: block; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-white);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-brand i { font-size: 1.5rem; color: var(--primary); }
.sidebar-close {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--sidebar-text);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.25rem;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.user-avatar-lg {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-white);
    flex-shrink: 0;
}
.user-info { min-width: 0; }
.user-name { font-weight: 600; color: var(--text-white); font-size: 0.875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.75rem; color: var(--text-muted); }

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    padding: 0.5rem 0;
    overflow-y: auto;
}
.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    color: var(--sidebar-text);
    font-size: 0.875rem;
    transition: all var(--transition);
    border-left: 3px solid transparent;
}
.nav-link:hover {
    background: var(--sidebar-hover);
    color: var(--text-white);
}
.nav-link.active {
    background: rgba(79, 70, 229, 0.15);
    color: var(--text-white);
    border-left-color: var(--primary);
}
.nav-link i { width: 20px; text-align: center; font-size: 0.875rem; flex-shrink: 0; }

/* Nav Section (Collapsible) */
.nav-section { }
.nav-section-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.625rem 1rem;
    background: none;
    border: none;
    color: var(--sidebar-text);
    font-size: 0.875rem;
    cursor: pointer;
    text-align: left;
    transition: all var(--transition);
    border-left: 3px solid transparent;
}
.nav-section-toggle:hover { background: var(--sidebar-hover); color: var(--text-white); }
.nav-section-toggle i { width: 20px; text-align: center; font-size: 0.875rem; flex-shrink: 0; }
.nav-section-toggle .arrow {
    margin-left: auto;
    font-size: 0.7rem;
    transition: transform var(--transition);
}
.nav-section.open > .nav-section-toggle .arrow { transform: rotate(90deg); }
.nav-section-items {
    display: none;
    padding-left: 0.5rem;
}
.nav-section.open > .nav-section-items { display: block; }
.nav-section-items .nav-link { padding-left: 2.5rem; font-size: 0.8125rem; }

.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.1);
    padding: 0.5rem 0;
}

/* ---- Main Content ---- */
.main-content {
    flex: 1;
    margin-top: var(--mobile-header-height);
    min-width: 0;
}

/* ---- Top Bar ---- */
.topbar {
    display: none; /* Hidden on mobile, shown on desktop */
    align-items: center;
    justify-content: space-between;
    height: var(--topbar-height);
    padding: 0 1.5rem;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar-left { }
.page-title { font-size: 1.25rem; font-weight: 600; color: var(--text-primary); }

.topbar-right { display: flex; align-items: center; gap: 1rem; }
.user-role-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
}
.user-dropdown { position: relative; }
.user-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.375rem;
    border-radius: var(--radius);
    transition: background var(--transition);
}
.user-dropdown-btn:hover { background: var(--bg); }
.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--text-white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}
.user-name-text { font-size: 0.875rem; font-weight: 500; color: var(--text-primary); }
.user-dropdown-btn i.fa-chevron-down { font-size: 0.625rem; color: var(--text-muted); }

.user-dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 0.5rem;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    z-index: 200;
    overflow: hidden;
}
.user-dropdown-menu.open { display: block; }
.user-dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: background var(--transition);
}
.user-dropdown-menu a:hover { background: var(--bg); }
.user-dropdown-menu a i { width: 16px; color: var(--text-muted); }

/* ---- Page Content ---- */
.page-content { padding: 1rem; }

/* ---- Flash Messages ---- */
.flash-container { margin-bottom: 1rem; }
.alert {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    animation: slideDown 0.3s ease;
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.alert-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
    padding: 0 0.25rem;
}
.alert-close:hover { opacity: 1; }

/* ---- Cards ---- */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}
.card-title { font-size: 1rem; font-weight: 600; color: var(--text-primary); }
.card-body { padding: 1.25rem; }
.card-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

/* ---- Stat Cards ---- */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 1rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}
.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}
.stat-icon.blue { background: #eff6ff; color: #2563eb; }
.stat-icon.green { background: #f0fdf4; color: #16a34a; }
.stat-icon.purple { background: #faf5ff; color: #9333ea; }
.stat-icon.orange { background: #fff7ed; color: #ea580c; }
.stat-icon.red { background: #fef2f2; color: #dc2626; }
.stat-icon.teal { background: #f0fdfa; color: #0d9488; }
.stat-info { min-width: 0; }
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.2; color: var(--text-primary); }
.stat-label { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.125rem; }

/* ---- Tables ---- */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
}
.data-table {
    width: 100%;
    font-size: 0.8125rem;
}
.data-table th {
    background: var(--bg);
    padding: 0.625rem 0.75rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    border-bottom: 2px solid var(--border);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}
.data-table td {
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}
.data-table tbody tr:hover { background: #f8fafc; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    line-height: 1.5;
    white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.625rem 1.25rem; font-size: 1rem; }

.btn-primary { background: var(--primary); color: var(--text-white); }
.btn-primary:hover { background: var(--primary-dark); color: var(--text-white); }
.btn-success { background: var(--success); color: var(--text-white); }
.btn-success:hover { background: #15803d; color: var(--text-white); }
.btn-danger { background: var(--danger); color: var(--text-white); }
.btn-danger:hover { background: #b91c1c; color: var(--text-white); }
.btn-warning { background: var(--warning); color: var(--text-primary); }
.btn-warning:hover { background: #d97706; }
.btn-info { background: var(--info); color: var(--text-white); }
.btn-info:hover { background: #1d4ed8; color: var(--text-white); }
.btn-secondary { background: var(--bg); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}
.btn-outline:hover { background: var(--primary); color: var(--text-white); }

.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ---- Forms ---- */
.form-group { margin-bottom: 1rem; }
.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
}
.form-label .required { color: var(--danger); }
.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    color: var(--text-primary);
    background: var(--bg-white);
    transition: border-color var(--transition), box-shadow var(--transition);
    line-height: 1.5;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}
.form-control::placeholder { color: var(--text-muted); }
select.form-control { appearance: auto; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}
.form-check label { font-size: 0.875rem; cursor: pointer; }

.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}
.form-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

.form-text { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; }
.form-error { font-size: 0.75rem; color: var(--danger); margin-top: 0.25rem; }
.form-control.is-invalid { border-color: var(--danger); }

/* ---- Badges / Status ---- */
.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    border-radius: 9999px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: #f1f5f9; color: #475569; }
.badge-primary { background: #e0e7ff; color: #3730a3; }

/* ---- Error Page ---- */
.error-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
    padding: 2rem;
}
.error-icon { font-size: 4rem; color: var(--danger); margin-bottom: 1rem; }
.error-page h2 { font-size: 1.5rem; margin-bottom: 0.5rem; }
.error-page p { color: var(--text-muted); margin-bottom: 1.5rem; }

/* ---- Login Page ---- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 1rem;
}
.login-card {
    background: var(--bg-white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    padding: 2rem;
}
.login-logo {
    text-align: center;
    margin-bottom: 1.5rem;
}
.login-logo i { font-size: 2.5rem; color: var(--primary); }
.login-logo h1 { font-size: 1.5rem; margin-top: 0.5rem; color: var(--text-primary); }
.login-logo p { font-size: 0.875rem; color: var(--text-muted); }

/* ---- Utility ---- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.flex-wrap { flex-wrap: wrap; }
.w-100 { width: 100%; }
.hidden { display: none !important; }

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty-state i { font-size: 3rem; margin-bottom: 1rem; opacity: 0.5; }
.empty-state p { font-size: 0.9375rem; }

/* ========================================================
   RESPONSIVE - Tablet (>= 640px)
   ======================================================== */
@media (min-width: 640px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 1rem; }
    .form-row { grid-template-columns: 1fr 1fr; }
    .page-content { padding: 1.25rem; }
    .stat-value { font-size: 1.75rem; }
}

/* ========================================================
   RESPONSIVE - Desktop (>= 1024px)
   ======================================================== */
@media (min-width: 1024px) {
    /* Show sidebar permanently */
    .mobile-header { display: none; }
    .sidebar-overlay { display: none !important; }
    .sidebar-close { display: none; }

    .sidebar {
        position: fixed;
        left: 0;
        transform: translateX(0);
    }

    .main-content {
        margin-left: var(--sidebar-width);
        margin-top: 0;
    }

    .topbar { display: flex; }

    .stats-grid { grid-template-columns: repeat(4, 1fr); }
    .form-row { grid-template-columns: 1fr 1fr; }
    .form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
    .form-row.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

    .page-content { padding: 1.5rem; }
}

/* ========================================================
   RESPONSIVE - Large Desktop (>= 1280px)
   ======================================================== */
@media (min-width: 1280px) {
    .stats-grid { gap: 1.25rem; }
    .stat-card { padding: 1.25rem; }
}

/* ---- Scrollbar ---- */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }

/* ---- Print ---- */
@media print {
    .sidebar, .mobile-header, .topbar, .sidebar-overlay { display: none !important; }
    .main-content { margin-left: 0 !important; margin-top: 0 !important; }
    .page-content { padding: 0; }
}
