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

:root {
    --primary: #4f46e5;
    --primary-light: #eef2ff;
    --success: #10b981;
    --success-light: #ecfdf5;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --dark: #0f172a;
    --light: #f8fafc;
    --border: #e2e8f0;
    --sidebar-width: 240px;
    --font-family: 'Outfit', sans-serif;
}

html {
    font-size: 13.5px; /* Compact ERP scale to fit more content on screen */
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-family);
    background-color: var(--light);
    color: var(--dark);
    margin: 0;
    padding: 0;
    font-size: 0.88rem;
    line-height: 1.45;
}

/* Headings Scaling */
h1, .h1 { font-size: 1.35rem; font-weight: 700; }
h2, .h2 { font-size: 1.22rem; font-weight: 700; }
h3, .h3 { font-size: 1.12rem; font-weight: 650; }
h4, .h4 { font-size: 1.02rem; font-weight: 650; }
h5, .h5 { font-size: 0.94rem; font-weight: 600; }
h6, .h6 { font-size: 0.85rem; font-weight: 600; }

/* Sidebar Styling (Desktop Only) */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    color: #fff;
    padding-top: 1.25rem;
    z-index: 1000;
    transition: all 0.3s ease;
}

.sidebar-logo {
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: -0.5px;
    color: #fff;
    text-decoration: none;
    padding: 0.4rem 1.25rem;
    display: block;
    margin-bottom: 1.25rem;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    padding: 0.65rem 1.25rem;
    color: #94a3b8;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.86rem;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
}

.sidebar-menu li a i {
    font-size: 1.1rem;
    margin-right: 0.7rem;
    width: 18px;
    text-align: center;
}

.sidebar-menu li a:hover,
.sidebar-menu li.active a {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.05);
    border-left-color: var(--primary);
}

/* Main Content Area */
.main-wrapper {
    margin-left: var(--sidebar-width);
    padding: 1.2rem 1.4rem;
    min-height: 100vh;
    transition: all 0.3s ease;
}

/* Top Header Bar */
.top-header {
    background-color: #fff;
    border-radius: 12px;
    padding: 0.55rem 1.15rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
    margin-bottom: 1.2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Dashboard Stat Cards */
.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 1rem 1.15rem;
    border: 1px solid var(--border);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02), 0 2px 4px -1px rgba(0, 0, 0, 0.02);
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

.stat-icon.primary { background-color: var(--primary-light); color: var(--primary); }
.stat-icon.success { background-color: var(--success-light); color: var(--success); }
.stat-icon.warning { background-color: var(--warning-light); color: var(--warning); }
.stat-icon.danger { background-color: var(--danger-light); color: var(--danger); }

/* Premium Table Styles */
.custom-table-container {
    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow-x: auto;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
    -webkit-overflow-scrolling: touch;
}

.custom-table {
    margin-bottom: 0;
    width: 100%;
    min-width: 800px;
}

.custom-table th {
    background-color: #f8fafc;
    font-weight: 600;
    color: #475569;
    border-bottom: 1px solid var(--border);
    padding: 0.6rem 0.75rem;
    font-size: 0.76rem;
}

.custom-table td {
    padding: 0.6rem 0.75rem;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.83rem;
}

/* Rounded Status Badges */
.badge-status {
    padding: 0.28rem 0.65rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.72rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.badge-status::before {
    content: '';
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
}

.badge-status.available { background-color: var(--success-light); color: var(--success); }
.badge-status.available::before { background-color: var(--success); }

.badge-status.running { background-color: var(--warning-light); color: var(--warning); }
.badge-status.running::before { background-color: var(--warning); }

.badge-status.maintenance { background-color: #fef3c7; color: #d97706; }
.badge-status.maintenance::before { background-color: #d97706; }

.badge-status.completed { background-color: var(--primary-light); color: var(--primary); }
.badge-status.completed::before { background-color: var(--primary); }

.badge-status.cancelled { background-color: var(--danger-light); color: var(--danger); }
.badge-status.cancelled::before { background-color: var(--danger); }

/* Forms UI */
.custom-card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 1.25rem 1.4rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
}

.form-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 0.25rem;
}

.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid var(--border);
    padding: 0.42rem 0.75rem;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

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

.btn {
    border-radius: 8px;
    padding: 0.42rem 0.85rem;
    font-size: 0.84rem;
    font-weight: 550;
    transition: all 0.2s ease;
}

.btn-sm {
    padding: 0.25rem 0.55rem;
    font-size: 0.78rem;
    border-radius: 6px;
}

.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background-color: #4338ca;
    border-color: #4338ca;
}

/* Floating Action Button (FAB) for Mobile */
.fab-btn {
    position: fixed;
    bottom: 80px;
    right: 18px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.3), 0 4px 6px -2px rgba(79, 70, 229, 0.3);
    border: none;
    z-index: 999;
    text-decoration: none;
    transition: all 0.2s ease;
}

.fab-btn:hover, .fab-btn:active {
    transform: scale(1.05);
    background-color: #4338ca;
    color: #fff;
}

/* Sticky Bottom Navigation for Mobile */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 65px;
    background-color: #fff;
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.05);
    z-index: 1001;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 10px;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 550;
    transition: all 0.2s ease;
    padding: 5px 0;
    width: 20%;
}

.mobile-nav-item i {
    font-size: 1.4rem;
    margin-bottom: 2px;
}

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

/* Responsive Overrides (Mobile First focus) */
@media (max-width: 991.98px) {
    .sidebar {
        left: -100%;
        display: none;
    }
    
    .sidebar.active {
        left: 0;
        display: block;
    }
    
    .main-wrapper {
        margin-left: 0;
        padding: 0.75rem 0.75rem 130px 0.75rem !important; /* Generous bottom padding so cards/buttons are never covered */
    }
    
    .top-header {
        margin-bottom: 1rem;
        border-radius: 12px;
        padding: 0.6rem 1rem;
    }
    
    .mobile-bottom-nav {
        display: flex;
    }
    
    /* Card layouts for listings instead of tables on mobile */
    .mobile-hide {
        display: none !important;
    }
    
    .mobile-card-list {
        display: block;
    }
    
    .mobile-card {
        background: #fff;
        border-radius: 12px;
        padding: 1rem;
        border: 1px solid var(--border);
        margin-bottom: 0.8rem;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.01);
    }
    
    .mobile-card-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 0.5rem;
    }
    
    .mobile-card-title {
        font-weight: 600;
        font-size: 1.05rem;
        margin-bottom: 0;
    }
    
    .mobile-card-row {
        display: flex;
        justify-content: space-between;
        font-size: 0.85rem;
        color: #475569;
        margin-bottom: 0.35rem;
    }
    
    .mobile-card-actions {
        display: flex;
        justify-content: flex-end;
        gap: 0.5rem;
        margin-top: 0.8rem;
        border-top: 1px solid #f1f5f9;
        padding-top: 0.6rem;
    }
}

@media (min-width: 992px) {
    .mobile-card-list {
        display: none;
    }
    .fab-btn {
        display: none;
    }
}

/* Image preview box style */
.image-preview-container {
    width: 100%;
    max-width: 300px;
    height: 180px;
    border: 2px dashed var(--border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: #f8fafc;
    margin-top: 0.5rem;
    position: relative;
    cursor: pointer;
}

.image-preview-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #64748b;
    font-size: 0.85rem;
}

.image-preview-placeholder i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

/* Custom Red Validation Text below required inputs */
.invalid-feedback {
    color: var(--danger) !important;
    font-size: 0.8rem !important;
    font-weight: 500;
    margin-top: 0.25rem;
    text-align: left;
}
.input-group > .invalid-feedback {
    display: none;
    width: 100%;
}
.was-validated .form-control:invalid ~ .invalid-feedback,
.was-validated .form-select:invalid ~ .invalid-feedback {
    display: block !important;
}

/* Desktop collapsed sidebar styling */
@media (min-width: 992px) {
    body.sidebar-collapsed .sidebar {
        left: -260px;
    }
    body.sidebar-collapsed .main-wrapper {
        margin-left: 0;
    }
}

/* Mobile Header padding and layout tweaks */
@media (max-width: 575.98px) {
    .top-header {
        padding: 0.5rem 0.6rem !important;
        margin-bottom: 1rem !important;
        border-radius: 12px !important;
    }
    .top-header .btn-group-sm > .btn {
        padding: 0.25rem 0.45rem !important;
        font-size: 0.72rem !important;
    }
    .top-header .dropdown-toggle {
        padding: 0.25rem 0.45rem !important;
        font-size: 0.85rem !important;
    }
    .top-header .gap-3 {
        gap: 0.5rem !important;
    }
}

/* Responsive FullCalendar month-grid scale-down for mobile view */
@media (max-width: 767.98px) {
    .fc .fc-toolbar {
        flex-direction: column !important;
        gap: 0.5rem !important;
        align-items: center !important;
    }
    .fc .fc-toolbar-title {
        font-size: 1.15rem !important;
        margin: 0.2rem 0 !important;
    }
    .fc .fc-button {
        padding: 0.25rem 0.5rem !important;
        font-size: 0.72rem !important;
    }
    .fc .fc-col-header-cell-cushion {
        font-size: 0.68rem !important;
        padding: 2px !important;
    }
    .fc .fc-daygrid-day-number {
        font-size: 0.7rem !important;
        padding: 2px !important;
    }
    .fc .fc-event {
        font-size: 0.62rem !important;
        padding: 1px 2px !important;
        margin: 1px 0 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    .fc .fc-daygrid-day-frame {
        min-height: 48px !important;
    }
}

/* DataTables custom styling integration */
.custom-table-container {
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 0.85rem 1rem;
    box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.03);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.custom-table {
    margin-bottom: 0 !important;
    width: 100% !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
}

.custom-table thead th {
    background-color: #f8fafc !important;
    color: #64748b !important;
    font-size: 0.72rem !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.4px !important;
    padding: 0.55rem 0.7rem !important;
    border-bottom: 1px solid var(--border) !important;
    white-space: nowrap !important;
}

.custom-table tbody tr {
    transition: background-color 0.15s ease;
}

.custom-table tbody tr:hover {
    background-color: #f8fafc !important;
}

.custom-table tbody td {
    padding: 0.55rem 0.7rem !important;
    vertical-align: middle !important;
    border-bottom: 1px solid #f1f5f9 !important;
    font-size: 0.82rem !important;
}

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

.text-nowrap {
    white-space: nowrap !important;
}

.dataTables_wrapper .dataTables_length select {
    border-radius: 8px !important;
    padding: 0.25rem 1.8rem 0.25rem 0.6rem !important;
    border: 1px solid #cbd5e1 !important;
    outline: none !important;
    font-size: 0.8rem !important;
    font-weight: 500;
    color: #475569;
}

.dataTables_wrapper .dataTables_filter input {
    border-radius: 8px !important;
    padding: 0.3rem 0.65rem !important;
    border: 1px solid #cbd5e1 !important;
    outline: none !important;
    font-size: 0.82rem !important;
    margin-left: 0.4rem !important;
    box-shadow: none !important;
    min-width: 180px;
}

.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 0.25rem 0.6rem !important;
    border-radius: 6px !important;
    font-size: 0.8rem !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.active .page-link {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
}

div.dataTables_wrapper div.dataTables_filter {
    text-align: right !important;
    margin-bottom: 0.75rem !important;
}

div.dataTables_wrapper div.dataTables_length {
    margin-bottom: 0.75rem !important;
}

.dataTables_wrapper .pagination {
    margin-top: 0.75rem !important;
    justify-content: flex-end !important;
}

.dataTables_wrapper .dataTables_info {
    font-size: 0.78rem !important;
    color: #64748b !important;
    padding-top: 0.35rem !important;
}

/* ==========================================================================
   Mobile-First Optimization (90% Mobile Usage Responsive Rules)
   ========================================================================== */

@media (max-width: 767.98px) {
    html {
        font-size: 13.2px;
    }

    /* Main Layout Padding - 135px bottom padding ensures last card / button is 100% visible above bottom nav & FAB */
    .main-wrapper {
        padding: 0.5rem 0.5rem 135px 0.5rem !important;
        margin-left: 0 !important;
    }

    /* Extra bottom clearance for last element on mobile */
    .main-wrapper > *:last-child,
    .container-fluid > *:last-child {
        margin-bottom: 30px !important;
    }

    /* Top Header Bar */
    .top-header {
        padding: 0.45rem 0.65rem !important;
        margin-bottom: 0.65rem !important;
        border-radius: 10px !important;
    }

    /* Container Fluid Reset */
    .container-fluid {
        padding-left: 0.1rem !important;
        padding-right: 0.1rem !important;
    }

    /* Cards & Containers on Mobile */
    .card, .custom-card, .stat-card, .kpi-card {
        padding: 0.75rem !important;
        border-radius: 12px !important;
        margin-bottom: 0.65rem !important;
    }

    /* Headings & Typography */
    h3, .h3 { font-size: 1.08rem !important; }
    h4, .h4 { font-size: 0.98rem !important; }
    h5, .h5 { font-size: 0.88rem !important; }
    h6, .h6 { font-size: 0.8rem !important; }

    /* Touch-Friendly Horizontal Table Scroll */
    .table-responsive,
    .custom-table-container {
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        border-radius: 10px !important;
        margin-bottom: 0.65rem !important;
        padding: 0.35rem !important;
    }

    .table, .custom-table {
        font-size: 0.76rem !important;
        margin-bottom: 0 !important;
        width: 100% !important;
    }

    .table th, .custom-table th {
        font-size: 0.68rem !important;
        padding: 0.45rem 0.55rem !important;
        white-space: nowrap !important;
        letter-spacing: 0 !important;
    }

    .table td, .custom-table td {
        padding: 0.45rem 0.55rem !important;
        font-size: 0.76rem !important;
        vertical-align: middle !important;
    }

    /* Mobile card list */
    .mobile-card {
        padding: 0.7rem !important;
        border-radius: 10px !important;
        margin-bottom: 0.6rem !important;
    }

    .mobile-card-title {
        font-size: 0.9rem !important;
    }

    .mobile-card-row {
        font-size: 0.78rem !important;
        margin-bottom: 0.25rem !important;
    }

    /* DataTables Controls on Mobile */
    div.dataTables_wrapper div.dataTables_filter {
        text-align: left !important;
        margin-bottom: 0.65rem !important;
    }

    div.dataTables_wrapper div.dataTables_length {
        text-align: left !important;
        margin-bottom: 0.65rem !important;
    }

    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        margin-left: 0 !important;
        margin-top: 0.25rem !important;
        min-width: 100% !important;
        display: block !important;
        font-size: 0.8rem !important;
        padding: 0.3rem 0.6rem !important;
    }

    .dataTables_wrapper .pagination {
        justify-content: center !important;
        flex-wrap: wrap !important;
        gap: 0.2rem !important;
        margin-top: 0.65rem !important;
    }

    /* Nav Tabs / Pills on Mobile */
    .nav-pills .nav-link {
        padding: 0.35rem 0.65rem !important;
        font-size: 0.78rem !important;
    }

    /* Buttons & Touch Targets */
    .btn {
        padding: 0.35rem 0.75rem !important;
        font-size: 0.8rem !important;
        border-radius: 8px !important;
    }

    .btn-sm {
        padding: 0.22rem 0.5rem !important;
        font-size: 0.74rem !important;
    }

    /* Badges & Status Pills */
    .badge {
        font-size: 0.68rem !important;
        padding: 0.28em 0.5em !important;
    }

    /* Modal Windows on Mobile */
    .modal-dialog {
        margin: 0.35rem !important;
    }

    .modal-content {
        border-radius: 14px !important;
    }

    .modal-body {
        padding: 0.85rem !important;
    }

    .modal-footer {
        padding: 0.65rem 0.85rem !important;
    }

    /* Form Controls on Mobile */
    .form-control, .form-select {
        font-size: 0.82rem !important;
        padding: 0.4rem 0.6rem !important;
        border-radius: 8px !important;
    }
}
