/* =========================================================================
   REFINED SAAS HRMS DESIGN SYSTEM
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary-color: #4361ee;
    --primary-hover: #3f37c9;
    --secondary-color: #3f37c9;
    --accent-color: #4cc9f0;
    
    --bg-color: #f6f8fc;
    --card-bg: #ffffff;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-active: #4361ee;
    
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    
    --sidebar-width: 260px;
    --header-height: 70px;
    --border-radius: 16px;
    --border-radius-sm: 10px;
    
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.03), 0 8px 10px -6px rgba(0, 0, 0, 0.03);
    --shadow-md: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.02);
    --shadow-lg: 0 25px 50px -12px rgba(67, 97, 238, 0.08);
}

body.dark-theme {
    --bg-color: #0b0f19;
    --card-bg: #151c2c;
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;
    --border-color: #242f47;
    --sidebar-bg: #070a13;
    --sidebar-text: #64748b;
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 20px 25px -5px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: var(--transition);
    overflow-x: hidden;
    font-size: 0.95rem;
}

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

.main-content {
    flex: 1;
    min-width: 0; /* Prevents flexbox child stretching past viewport */
    margin-left: var(--sidebar-width);
    padding: 30px;
    padding-top: calc(var(--header-height) + 30px);
    transition: var(--transition);
    min-height: 100vh;
    padding-bottom: 90px;
}

/* Custom Header */
.app-header {
    position: fixed;
    top: 0;
    right: 0;
    left: var(--sidebar-width);
    height: var(--header-height);
    background: rgba(var(--card-bg) === '#ffffff' ? '255, 255, 255' : '21, 28, 44', 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    z-index: 100;
    transition: var(--transition);
}

body:not(.dark-theme) .app-header {
    background: rgba(255, 255, 255, 0.85);
}
body.dark-theme .app-header {
    background: rgba(21, 28, 44, 0.85);
}

.header-title h4 {
    font-weight: 700;
    font-size: 1.35rem;
    letter-spacing: -0.5px;
    margin: 0;
}

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

/* Premium Sidebar */
.app-sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 110;
    display: flex;
    flex-direction: column;
    color: var(--sidebar-text);
    transition: var(--transition);
    border-right: 1px solid var(--border-color);
    padding-bottom: 15px;
}

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.sidebar-brand img {
    height: 32px;
    width: auto;
}

.sidebar-brand h3 {
    font-size: 1.15rem;
    font-weight: 800;
    color: #fff;
    margin: 0;
    letter-spacing: 0.5px;
}

.sidebar-menu {
    list-style: none;
    padding: 20px 14px;
    flex: 1;
    overflow-y: auto;
}

.sidebar-menu::-webkit-scrollbar {
    width: 4px;
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.sidebar-menu li {
    margin-bottom: 4px;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: var(--border-radius-sm);
    gap: 14px;
    font-size: 0.92rem;
    font-weight: 500;
    transition: var(--transition);
}

.sidebar-menu a i {
    font-size: 1.15rem;
    width: 20px;
    text-align: center;
    opacity: 0.8;
}

.sidebar-menu a:hover {
    background: rgba(255, 255, 255, 0.03);
    color: #fff;
}

.sidebar-menu li.active a {
    background: var(--sidebar-active);
    color: #fff;
    box-shadow: 0 8px 20px -6px rgba(67, 97, 238, 0.4);
    font-weight: 600;
}

.sidebar-footer {
    padding: 16px;
    margin: 0 14px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--border-radius);
    border: 1px solid rgba(255, 255, 255, 0.03);
}

/* Premium Cards */
.card-premium {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    padding: 24px;
    box-shadow: var(--shadow);
    transition: var(--transition);
    position: relative;
}

.card-premium:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Form Styles */
.form-group-custom {
    margin-bottom: 18px;
}

.form-group-custom label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-muted);
}

.form-control-custom {
    width: 100%;
    padding: 11px 16px;
    border-radius: var(--border-radius-sm);
    border: 1.5px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 0.95rem;
    transition: var(--transition);
    outline: none;
}

.form-control-custom:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.12);
}

.form-select {
    border-radius: var(--border-radius-sm) !important;
    border: 1.5px solid var(--border-color) !important;
    padding: 11px 16px !important;
    font-size: 0.95rem !important;
    background-color: var(--card-bg) !important;
    color: var(--text-color) !important;
}

.form-select:focus {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.12) !important;
}

.btn-custom {
    padding: 11px 22px;
    border-radius: var(--border-radius-sm);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

.btn-primary-custom {
    background: var(--primary-color);
    color: #fff;
}

.btn-primary-custom:hover {
    background: var(--primary-hover);
    box-shadow: 0 8px 20px -6px rgba(67, 97, 238, 0.35);
}

.btn-secondary-custom {
    background: var(--border-color);
    color: var(--text-color);
}

.btn-secondary-custom:hover {
    background: rgba(100, 116, 139, 0.15);
}

/* Custom Table Styles */
.responsive-table-wrapper {
    overflow-x: auto;
    width: 100%;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
}

.table-custom {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
}

.table-custom th {
    background-color: rgba(67, 97, 238, 0.03);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.8px;
    padding: 14px 18px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table-custom td {
    padding: 16px 18px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.88rem;
    color: var(--text-color);
}

.table-custom tr:last-child td {
    border-bottom: none;
}

.table-custom tr:hover {
    background-color: rgba(67, 97, 238, 0.015);
}

/* SaaS Badge Tags */
.badge-custom {
    padding: 6px 12px;
    font-size: 0.75rem;
    border-radius: 50px;
    font-weight: 600;
    display: inline-block;
}

.badge-present, .badge-approved { background: rgba(16, 185, 129, 0.12); color: var(--success-color); }
.badge-absent, .badge-rejected { background: rgba(239, 68, 68, 0.12); color: var(--error-color); }
.badge-late, .badge-pending { background: rgba(245, 158, 11, 0.12); color: var(--warning-color); }
.badge-halfday, .badge-cancelled { background: rgba(100, 116, 139, 0.12); color: var(--text-muted); }

/* Interactive Attendance Calendar */
.attendance-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    margin-top: 15px;
}

.calendar-header-day {
    text-align: center;
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    padding: 8px 0;
}

.calendar-day-cell {
    aspect-ratio: 1.1;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    padding: 6px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: var(--transition);
    position: relative;
    cursor: default;
}

.calendar-day-cell:hover {
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.calendar-day-num {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
}

.calendar-day-cell.current-month .calendar-day-num {
    color: var(--text-color);
}

.calendar-day-cell.other-month {
    opacity: 0.35;
    background: rgba(0, 0, 0, 0.02);
}

.calendar-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin: 0 auto;
}

/* Calendar status mappings */
.calendar-day-cell.present { border-color: rgba(16, 185, 129, 0.35); background: rgba(16, 185, 129, 0.03); }
.calendar-day-cell.present .calendar-day-num { color: var(--success-color); }

.calendar-day-cell.late { border-color: rgba(245, 158, 11, 0.35); background: rgba(245, 158, 11, 0.03); }
.calendar-day-cell.late .calendar-day-num { color: var(--warning-color); }

.calendar-day-cell.absent { border-color: rgba(239, 68, 68, 0.35); background: rgba(239, 68, 68, 0.03); }
.calendar-day-cell.absent .calendar-day-num { color: var(--error-color); }

.calendar-day-cell.leave { border-color: rgba(59, 130, 246, 0.35); background: rgba(59, 130, 246, 0.03); }
.calendar-day-cell.leave .calendar-day-num { color: var(--info-color); }

.calendar-day-cell.weekly-off { border-color: var(--border-color); background: rgba(100, 116, 139, 0.04); }
.calendar-day-cell.weekly-off .calendar-day-num { color: var(--text-muted); }

.calendar-day-cell.holiday { border-color: rgba(139, 92, 246, 0.35); background: rgba(139, 92, 246, 0.04); }
.calendar-day-cell.holiday .calendar-day-num { color: #8b5cf6; }

/* Native Toasts */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 380px;
}

.navix-toast {
    background: var(--card-bg);
    color: var(--text-color);
    border-left: 4px solid var(--primary-color);
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 14px;
    transform: translateX(120%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.navix-toast.show {
    transform: translateX(0);
}

/* Mobile Layout Polish */
.mobile-nav-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 72px;
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    z-index: 99;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.06);
    justify-content: space-around;
    align-items: center;
    padding: 0 16px;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    transition: var(--transition);
    gap: 5px;
}

.mobile-nav-item i {
    font-size: 1.3rem;
    transition: var(--transition);
}

.mobile-nav-item.active {
    color: var(--primary-color);
}

/* Floating Action Button (FAB) */
.fab-punch {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 8px 25px rgba(67, 97, 238, 0.35);
    position: relative;
    bottom: 16px;
    cursor: pointer;
    transition: var(--transition);
}

.fab-punch:hover {
    transform: scale(1.06);
}

/* Responsive Overrides */
@media (max-width: 991px) {
    .app-sidebar {
        transform: translateX(-100%);
    }

    .main-content {
        margin-left: 0;
        padding: 16px;
        padding-top: calc(var(--header-height) + 16px);
        padding-bottom: 90px;
    }

    .app-header {
        left: 0;
        padding: 0 16px;
    }

    .mobile-nav-bar {
        display: flex;
    }
}

/* User Profile Mini Widget Styling */
.user-profile-sm {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-profile-sm img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
    flex-shrink: 0;
}

.user-profile-sm .profile-info {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.user-profile-sm .profile-info h5 {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
    line-height: 1.2;
}

.user-profile-sm .profile-info p {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.2;
}

/* Modals Styling */
.navix-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    padding: 16px;
}

.navix-modal.show {
    display: flex;
}

.navix-modal-content {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    overflow: hidden;
    animation: modalFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.navix-modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.navix-modal-header h5 {
    font-weight: 700;
    margin: 0;
}

.navix-modal-body {
    padding: 24px;
}

.navix-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn-close {
    background-color: transparent;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
}

.btn-close:hover {
    color: var(--text-color);
}

/* --- Mobile Responsiveness and Touch Target Enhancements --- */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden;
        width: 100%;
    }
    .card-premium {
        padding: 16px 12px;
        border-radius: 12px;
        max-width: 100% !important;
        box-sizing: border-box;
    }
    .main-content {
        padding: 12px;
        padding-top: calc(var(--header-height) + 12px);
        padding-bottom: 90px;
        min-width: 0 !important;
        max-width: 100% !important;
        overflow-x: hidden;
    }
    /* Compact Table Styles on Mobile */
    .table-custom th {
        padding: 10px 8px !important;
        font-size: 0.65rem !important;
        letter-spacing: 0.5px !important;
    }
    .table-custom td {
        padding: 10px 8px !important;
        font-size: 0.78rem !important;
    }
    /* Compact swipable Calendar Grid */
    .attendance-calendar-grid {
        gap: 4px !important;
    }
    .calendar-header-day {
        font-size: 0.7rem !important;
        padding: 4px 0 !important;
    }
    .calendar-day-cell {
        padding: 4px 2px !important;
        aspect-ratio: 1 !important;
        min-width: 0 !important;
    }
    .calendar-day-num {
        font-size: 0.75rem !important;
    }
    .calendar-day-cell span.small {
        font-size: 0.6rem !important;
    }
    /* Touch Target Size Compliance (min 44px for easy mobile tapping) */
    .btn-custom, .btn, .btn-primary-custom, .btn-secondary-custom {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    /* Stop digital clock text wrapping on extra-narrow viewports */
    .digital-clock {
        font-size: 2rem !important;
    }
    /* Swipable Tab Bar Navigation (Gmail / YouTube Style) */
    .nav-pills, .nav-tabs {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        gap: 8px;
        padding-bottom: 8px;
        scrollbar-width: none; /* Hide scrollbar Firefox */
    }
    .nav-pills::-webkit-scrollbar, .nav-tabs::-webkit-scrollbar {
        display: none; /* Hide scrollbar Safari / Chrome */
    }
    .nav-pills .nav-item, .nav-tabs .nav-item {
        flex: 0 0 auto !important;
    }
}
