/* SIMAPP - Standardized Stylesheet
   Built for Bootstrap 5.3.3, jQuery 3.7.1, Font Awesome 6.4.0, DataTables 2.1.8, Chart.js 4.4.7, Quill 2.0.3 */

/* 1. GLOBAL LAYOUT & BASE STYLES */

html {
    /* Keep anchored/scrolled-into-view targets clear of the fixed top navbar */
    scroll-padding-top: 60px;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding-top: 50px;
    padding-bottom: 40px;
}

/* 2. TOP NAVBAR */

.top-navbar {
    background: linear-gradient(135deg, #183f8d 0%, #1e4fa0 100%);
    color: white;
    padding: 0.5rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    z-index: 1030;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.top-navbar .brand {
    font-size: 1.25rem;
    font-weight: 600;
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
}

.top-navbar .brand .logo-image {
    max-height: 40px;
    height: 40px;
    width: auto;
    object-fit: contain;
    border-radius: 8px;
}

.top-navbar .user-menu {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* 3. SIDEBAR NAVIGATION */

.sidebar {
    width: 240px;
    background: linear-gradient(180deg, #1e4fa0 0%, #183f8d 100%);
    color: white;
    position: fixed;
    top: 50px;
    bottom: 40px;
    left: 0;
    overflow-y: auto;
    transition: all 0.3s;
    z-index: 1020;
    box-shadow: 2px 0 8px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
}

.sidebar .nav-section {
    padding: 0.5rem 0;
}

.sidebar .nav-section-title {
    padding: 0.5rem 1.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #95a5a6;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.sidebar .nav-link {
    color: #ecf0f1;
    padding: 0.4rem 1.25rem;
    display: flex;
    align-items: center;
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    font-size: 0.95rem;
}

.sidebar .nav-link:hover {
    background: rgba(52, 152, 219, 0.1);
    color: white;
    border-left-color: #3498db;
    padding-left: 1.5rem;
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
}

.sidebar .nav-link.active {
    background: rgba(52, 152, 219, 0.2);
    color: white;
    border-left: 3px solid #3498db;
    font-weight: 500;
}

.sidebar .nav-link i,
.sidebar .nav-link svg {
    width: 20px;
    margin-right: 10px !important;
    font-size: 1rem;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    display: none;
}

/* Dimmed backdrop behind the off-canvas sidebar on small screens */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 50px;
    bottom: 40px;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1019;
}

.sidebar-backdrop.show {
    display: block;
}

/* 4. MAIN CONTENT AREA */

.content-wrapper {
    display: flex;
    flex: 1;
}

.main-content {
    flex: 1;
    margin-left: 220px;
    padding: 1.75rem;
    background: #f5f6fa;
    min-height: calc(100vh - 90px);
    /* Flex items default to min-width:auto, which lets wide children (tab strips,
       scrollable tables) push the page past the viewport. */
    min-width: 0;
    max-width: 100%;
}

/* 5. FOOTER */

.footer {
    background: linear-gradient(135deg, #183f8d 0%, #1e4fa0 100%);
    color: white;
    padding: 0.65rem 1.5rem;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    z-index: 1025;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 0.85rem;
}

/* 6. ENHANCED FORM CONTROLS */

.form-control:focus,
.form-select:focus {
    border-color: #1b6ec2;
    box-shadow: 0 0 0 0.2rem rgba(27, 110, 194, 0.25);
}

.form-control-lg {
    transition: all 0.3s ease;
}

.form-control-lg:focus {
    transform: translateY(-2px);
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #183f8d;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

/* 7. ENHANCED BUTTONS */

.btn {
    transition: all 0.3s ease;
    font-weight: 500;
    border-radius: 6px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, #1b6ec2 0%, #1861ac 100%);
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #1861ac 0%, #155a9a 100%);
}

.btn-success {
    background: #2ecc71;
    border: none;
}

.btn-success:hover {
    background: #27ae60;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(46, 204, 113, 0.3);
}

.btn-warning {
    background: #f39c12;
    border: none;
}

.btn-danger {
    background: #e74c3c;
    border: none;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-info {
    background: #16a085;
    border: none;
}

.btn-secondary {
    background: #95a5a6;
    border: none;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

/* 8. ENHANCED CARDS */

.card {
    transition: all 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.card:hover {
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.card-header {
    background: white;
    border-bottom: 2px solid #f0f0f0;
    padding: 1rem 1.25rem;
    border-radius: 12px 12px 0 0 !important;
    font-weight: 600;
}

.card-body {
    padding: 1.25rem;
}

/* 9. DROPDOWN MENUS */

.dropdown-toggle::after {
    margin-left: 0.5em;
}

.dropdown-menu {
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border: none;
    margin-top: 0.5rem;
}

.dropdown-item {
    padding: 0.5rem 1rem;
    transition: all 0.2s;
}

.dropdown-item:hover {
    background-color: #f8f9fa;
    transform: translateX(5px);
}

/* 10. TABLES */

.table {
    margin-bottom: 0;
}

.table thead th {
    background: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    color: #495057;
    padding: 0.85rem;
}

.table tbody td {
    padding: 0.85rem;
    vertical-align: middle;
}

.table-hover tbody tr:hover {
    background-color: #f8f9fa;
}

.table-responsive {
    overflow-x: auto;
}

.table-actions button {
    margin-right: 5px;
}

.action-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* DataTables Customization */
.dataTables_wrapper {
    padding: 0;
}

.dataTables_filter {
    margin-bottom: 1rem;
}

.dataTables_filter input {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 0.5rem;
    margin-left: 0.5rem;
}

/* 11. BADGES */

.badge {
    padding: 0.35rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

.badge-success {
    background: #d4edda;
    color: #155724;
}

.badge-warning {
    background: #fff3cd;
    color: #856404;
}

.badge-danger {
    background: #f8d7da;
    color: #721c24;
}

.badge-info {
    background: #d1ecf1;
    color: #0c5460;
}

.badge-secondary {
    background: #e2e3e5;
    color: #383d41;
}

.badge-primary {
    background: #cfe2ff;
    color: #084298;
}

/* 12. SHADOW UTILITIES */

.shadow-sm {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
}

.shadow-lg {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15) !important;
}

/* 13. DASHBOARD COMPONENTS */

/* Dashboard Collapse Styles */
.metrics-collapsible-content {
    max-height: 1000px;
    overflow: hidden;
    transition: max-height 0.4s ease-in-out, opacity 0.3s ease-in-out, margin 0.3s ease-in-out;
    opacity: 1;
}

.metrics-collapsible-content.collapsed {
    max-height: 0;
    opacity: 0;
    margin-bottom: 0 !important;
}

#dashboardCollapseBtn {
    transition: all 0.2s ease;
}

#dashboardCollapseBtn:hover {
    transform: scale(1.05);
}

.dashboard-section {
    position: relative;
    transition: all 0.4s ease-in-out;
    flex: 0 0 auto;
    min-height: 60px;
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.dashboard-section.collapsed-dashboard {
    flex: 0 0 60px;
    min-height: 60px;
    padding: 0.75rem 1.5rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    height: 100%;
}

.dashboard-row-2 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-top: 1rem;
}

.dashboard-row-2.two-up {
    grid-template-columns: repeat(2, 1fr);
}

.dashboard-grid.five-up {
    grid-template-columns: repeat(5, 1fr);
}

/* Metric Cards */
.metric-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 10px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    transition: all 0.3s;
    cursor: pointer;
}

.metric-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.metric-card.blue {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.metric-card.green {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

.metric-card.orange {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

.metric-card.purple {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.metric-card.red {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
}

.metric-card.teal {
    background: linear-gradient(135deg, #16a085 0%, #1abc9c 100%);
}

.metric-card.pink {
    background: linear-gradient(135deg, #c471ed 0%, #f64f59 100%);
}

.metric-card.indigo {
    background: linear-gradient(135deg, #5f72bd 0%, #9b23ea 100%);
}

.metric-value {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.metric-label {
    font-size: 1rem;
    opacity: 0.95;
    font-weight: 500;
}

/* Stat Cards (Alternative style) */
.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 10px;
    padding: 1.5rem;
    text-align: center;
    transition: all 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

.stat-card.assets {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.stat-card.services {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.stat-card.tasks-pending {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.stat-card.tasks-progress {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

.stat-card.green {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

.stat-card.blue {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.stat-card.orange {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

.stat-card h3 {
    margin: 0;
    font-size: 2.5rem;
}

.stat-card p {
    margin: 5px 0 0 0;
    opacity: 0.9;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Menu Cards */
.menu-card {
    transition: all 0.3s ease;
}

.menu-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15) !important;
}

.menu-card:active {
    transform: translateY(-2px);
}

/* 14. TAB SYSTEMS */

/* Menu Section */
.menu-section {
    flex: 1;
    min-height: 0;
    min-width: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.4s ease-in-out;
}

.menu-tabs {
    border-bottom: 2px solid #f0f0f0;
    padding: 0 1rem;
    display: flex;
    flex-wrap: nowrap;
    gap: 0.125rem;
    background: #fafafa;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.menu-tab {
    padding: 0.85rem 0.9rem;
    border: none;
    white-space: nowrap;
    flex-shrink: 0;
    background: none;
    color: #666;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
    font-size: 0.95rem;
}

.menu-tab:hover {
    color: #3498db;
    background: rgba(52, 152, 219, 0.05);
}

.menu-tab.active {
    color: #3498db;
    border-bottom-color: #3498db;
    background: white;
}

.menu-content {
    flex: 1;
    overflow: hidden;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}


/* Nav Tabs (Bootstrap Override) */
.nav-tabs .nav-link {
    color: #666;
    border: none;
    border-bottom: 3px solid transparent;
    font-weight: 500;
}

.nav-tabs .nav-link:hover {
    border-bottom-color: #3498db;
    color: #3498db;
}

.nav-tabs .nav-link.active {
    color: #3498db;
    border-bottom-color: #3498db;
    background: transparent;
}

/* Tab Panes */
.tab-pane {
    display: none;
}

.tab-pane.active {
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: auto;
}

#pos-tab.tab-pane.active {
    overflow: hidden;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 15. MODULE-SPECIFIC CONTAINERS */

.crm-container,
.sales-container,
.ecommerce-container,
.hr-container,
.payroll-container,
.utility-container,
.bookkeeping-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    height: calc(100vh - 130px);
    padding: 0;
}

.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

/* 16. SALES / POS INTERFACE */

.pos-container {
    display: grid;
    grid-template-columns: 6fr 4fr;
    gap: 1.5rem;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.product-search-section {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 0;
    height: 100%;
}

.search-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.search-input {
    flex: 1;
    padding: 0.6rem 0.85rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95rem;
}

.search-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.category-filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.category-chip {
    padding: 0.4rem 0.85rem;
    background: white;
    border: 1px solid #ddd;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
}

.category-chip:hover,
.category-chip.active {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    align-content: start;
}

.product-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.product-card:hover {
    border-color: #3498db;
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.2);
    transform: translateY(-2px);
}

.product-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: #333;
}

.product-price {
    color: #3498db;
    font-weight: 700;
    font-size: 1.1rem;
}

/* Cart Section */
.cart-section {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 0;
    height: 100%;
}

/* Reduce spacing for form groups within cart section */
.cart-section .form-group {
    margin-bottom: 0.5rem;
}

/* Compact empty state in cart */
.cart-items .empty-state {
    padding: 2rem 1rem;
}

.cart-items .empty-state i {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.cart-header {
    font-size: 1.1rem;
    font-weight: 700;
    color: #333;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid #ddd;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.cart-item {
    background: white;
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cart-item-details {
    flex: 1;
}

.cart-item-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: #333;
}

.cart-item-price {
    color: #666;
    font-size: 0.85rem;
}

.cart-item-qty {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.qty-btn {
    width: 30px;
    height: 30px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

.qty-btn:hover {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

.qty-value {
    width: 40px;
    text-align: center;
    font-weight: 600;
}

.cart-remove {
    color: #e74c3c;
    cursor: pointer;
    padding: 0.5rem;
}

.cart-remove:hover {
    color: #c0392b;
}

.cart-totals {
    background: white;
    padding: 0.75rem;
    border-radius: 6px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    padding: 0.35rem 0;
}

.total-row.grand-total {
    font-size: 1.2rem;
    font-weight: 700;
    color: #183f8d;
    border-top: 2px solid #ddd;
    padding-top: 0.75rem;
    margin-top: 0.35rem;
}

.cart-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* 17. AUTOCOMPLETE */

.autocomplete-container {
    position: relative;
}

.autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.autocomplete-results.show {
    display: block;
}

.autocomplete-item {
    padding: 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
}

.autocomplete-item:hover {
    background: #f8f9fa;
}

/* 18. MODALS */

.modal-xl {
    max-width: 1200px;
}

.modal-lg {
    max-width: 900px;
}

.modal .close-btn {
    font-size: 1.5rem;
    cursor: pointer;
    color: #95a5a6;
    background: none;
    border: none;
    padding: 0.5rem;
    line-height: 1;
}

.modal .close-btn:hover {
    color: #e74c3c;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #183f8d;
}

.modal-header.text-white .modal-title,
.modal-header.text-dark .modal-title {
    color: inherit;
}

/* Modal optimization for better viewport fitting */
.modal-dialog.modal-lg {
    max-width: 800px;
}

/* Sales document modal (Invoice/Quote/Receipt/Credit Note/Debit Note) */
#salesDocumentModal .modal-dialog {
    max-width: 1050px;
}

#adminModal .modal-dialog {
    max-width: min(1320px, calc(100vw - 1rem));
}

#adminModal .modal-content {
    overflow: hidden;
}

#adminModal .modal-body {
    overflow-x: auto;
}

.admin-transactions-table-wrap {
    width: 100%;
    overflow-x: auto;
}

#transactionsTable {
    min-width: 1120px;
}

.modal-body {
    scrollbar-width: thin;
    scrollbar-color: #95a5a6 #ecf0f1;
}

.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: #ecf0f1;
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: #95a5a6;
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: #7f8c8d;
}

/* Ensure modals are centered and responsive.
   Between sm and lg Bootstrap collapses .modal-lg/.modal-xl to 500px; below sm
   the .modal-fullscreen-sm-down variant takes over, so leave phones alone. */
@media (min-width: 576px) and (max-width: 991.98px) {
    .modal-lg,
    .modal-xl {
        max-width: 94%;
        margin-left: auto;
        margin-right: auto;
    }
}

/* 19. FILE MANAGER */

.file-list-item {
    padding: 10px;
    border-bottom: 1px solid #dee2e6;
    cursor: pointer;
    transition: background 0.2s;
}

.file-list-item:hover {
    background: #f8f9fa;
}

.file-list-item .file-icon {
    font-size: 1.5rem;
    width: 40px;
    text-align: center;
}

.file-list-item.folder {
    color: #ffc107;
}

.file-list-item.file {
    color: #6c757d;
}

.breadcrumb-nav {
    background: #f8f9fa;
    padding: 10px 15px;
    border-radius: 5px;
}

/* 20. USER ROLES / AVATARS */

.avatar-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #0d6efd;
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
}

#usersTable tbody tr {
    transition: background-color 0.2s;
}

#usersTable tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.05);
}

/* 21. HR APPLICATION FORM */

.application-container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    padding: 2rem;
}

.section-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.form-section {
    margin-bottom: 2rem;
}

.required-indicator {
    color: #e74c3c;
}

.btn-submit {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
    padding: 0.75rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
}

.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(17, 153, 142, 0.4);
}

/* 22. QUILL EDITOR */

.ql-container {
    min-height: 200px;
    font-size: 1rem;
}

.ql-editor {
    min-height: 200px;
}

/* 23. STOCK INDICATORS */

.stock-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 5px;
}

.stock-indicator.in-stock {
    background: #2ecc71;
}

.stock-indicator.low-stock {
    background: #f39c12;
}

.stock-indicator.out-of-stock {
    background: #e74c3c;
}

/* 24. EMPTY STATES */

.empty-state {
    text-align: center;
    padding: 3rem;
    color: #95a5a6;
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 1rem;
}

/* 25. LOADING SPINNERS */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Chart.js wrapper: charts fill this box (maintainAspectRatio: false) */
.chart-box {
    position: relative;
    width: 100%;
    height: 300px;
}

@media (max-width: 767.98px) {
    .chart-box {
        height: 240px;
    }
}

/* 26. RESPONSIVE DESIGN */

/* Tablets and below (< 992px): off-canvas sidebar, natural page scroll,
   scrollable tab strips, 2-up metric grids. */
@media (max-width: 991.98px) {
    .sidebar {
        left: -240px;
        box-shadow: none;
    }

    .sidebar.show {
        left: 0;
        box-shadow: 2px 0 12px rgba(0, 0, 0, 0.3);
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
    }

    .sidebar-toggle {
        display: block;
    }

    /* Let the page scroll instead of pinning modules to the viewport height */
    .crm-container,
    .sales-container,
    .ecommerce-container,
    .hr-container,
    .payroll-container,
    .utility-container,
    .bookkeeping-container {
        height: auto;
        min-height: 0;
        gap: 1rem;
    }

    .menu-section,
    .menu-content {
        overflow: visible;
    }

    .menu-content {
        padding: 1rem;
    }

    .tab-pane.active,
    #pos-tab.tab-pane.active {
        overflow: visible;
        min-height: auto;
    }

    .menu-tabs {
        padding: 0 0.5rem;
        gap: 0;
    }

    .menu-tab {
        padding: 0.75rem 0.75rem;
        font-size: 0.9rem;
    }

    /* Bootstrap nav-tabs / nav-pills: scroll sideways instead of stacking rows */
    .nav-tabs,
    .nav-pills {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .nav-tabs .nav-item,
    .nav-pills .nav-item,
    .nav-tabs > .nav-link,
    .nav-pills > .nav-link {
        flex-shrink: 0;
        white-space: nowrap;
    }

    .dashboard-grid,
    .dashboard-grid.five-up,
    .dashboard-row-2 {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-grid {
        height: auto;
    }

    .pos-container {
        grid-template-columns: 1fr;
        height: auto;
        overflow: visible;
    }

    .products-grid {
        overflow-y: visible;
        min-height: auto;
    }

    .cart-section {
        height: auto;
    }

    .financial-statement {
        padding: 1rem;
    }
}

/* Phones (< 768px): wrap toolbars, tighten spacing, keep buttons tappable */
@media (max-width: 767.98px) {
    .main-content {
        padding: 0.75rem;
    }

    .top-navbar {
        padding: 0.5rem 0.75rem;
    }

    /* Heading + action-button rows wrap instead of squeezing the heading */
    .d-flex.justify-content-between {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .metric-card {
        padding: 1rem;
    }

    .metric-value {
        font-size: 1.75rem;
    }

    .metric-label {
        font-size: 0.8rem;
    }

    .menu-card {
        padding: 1rem;
    }

    /* Two-option radio button groups stack vertically */
    .btn-group.w-100 {
        flex-wrap: wrap;
    }

    .btn-group.w-100 > .btn,
    .btn-group.w-100 > .btn-check + .btn {
        flex: 1 1 100%;
        border-radius: var(--bs-border-radius) !important;
        margin-left: 0;
    }

    /* Keep tables readable when they do scroll */
    .table-responsive > .table {
        margin-bottom: 0;
    }

    .dataTables_wrapper .dt-length,
    .dataTables_wrapper .dt-search {
        text-align: left;
    }
}

/* Small phones (< 576px): single-column metric grids */
@media (max-width: 575.98px) {
    .dashboard-grid,
    .dashboard-grid.five-up,
    .dashboard-row-2,
    .dashboard-row-2.two-up {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .modal-footer {
        justify-content: stretch;
    }

    .modal-footer > .btn {
        flex: 1 1 auto;
    }
}

/* 27. PARTIAL-SPECIFIC STYLES */

/* General Ledger Partial */
.card-header button[data-bs-toggle="collapse"] {
    color: #333;
    font-weight: 500;
}

.card-header button[data-bs-toggle="collapse"]:hover {
    color: #0056b3;
}

#generalLedgerTable tbody tr:hover {
    background-color: #f8f9fa;
}

/* Journal Entries Partial */
.group-start {
    border-top: 2px solid #dee2e6;
}

/* Financial Statements */
.financial-statement {
    background: white;
    padding: 2rem;
    border-radius: 8px;
}

.statement-header h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #183f8d;
    margin-bottom: 0.5rem;
}

.statement-header h5 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #1e4fa0;
    margin-bottom: 0.5rem;
}

.section-title {
    font-weight: 600;
    border-radius: 4px;
    margin-bottom: 0;
}

.statement-section table {
    margin-bottom: 0;
}

.statement-section table td {
    padding: 0.5rem;
    border: none;
}

.statement-section table tr.border-top td {
    border-top: 2px solid #dee2e6 !important;
    padding-top: 0.75rem;
}

/* CRM Ticket Modal */
.email-body {
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: 6px;
    word-wrap: break-word;
}

.note-content {
    padding: 0.5rem;
    background-color: #f0f8f0;
    border-radius: 4px;
    word-wrap: break-word;
}

/* SUBSCRIPTION SYSTEM STYLES */

/* Subscription Warning Banner (Dashboard) */
.subscription-warning-banner {
    margin-bottom: 1.5rem;
    border-left: 4px solid #ffc107;
    animation: fadeInDown 0.5s ease-in-out;
}

.subscription-warning-banner.alert-danger {
    border-left-color: #dc3545;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Sidebar Subscription Footer */
.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.1);
}

.subscription-info small {
    font-size: 0.75rem;
    line-height: 1.2;
}

.subscription-info strong {
    font-size: 0.85rem;
}

/* Subscription Tab (Settings Page) */
#subscription .card-header {
    border-bottom: 2px solid #dee2e6;
}

#subscription .border.rounded {
    transition: all 0.2s ease-in-out;
}

#subscription .border.rounded:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* Available Plans Grid */
#availablePlansContainer .plan-card {
    transition: all 0.3s ease-in-out;
    cursor: pointer;
}

#availablePlansContainer .plan-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-4px);
}

#availablePlansContainer .plan-card.selected {
    border-color: #0d6efd;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.25);
}

/* Renewal Modal */
#renewalModal .alert-info {
    background-color: #e7f3ff;
    border-color: #b3d9ff;
}

#renewalModal .alert-success {
    background-color: #d4edda;
    border-color: #c3e6cb;
}

/* Admin Subscription Plans Table */
#subscriptionPlansTable .badge {
    font-size: 0.8rem;
    padding: 0.35em 0.65em;
}

/* Website Registration Modal */
#registrationModal .alert-success {
    background-color: #d1f2eb;
    border-color: #a8e6cf;
}

#registrationModal .form-control:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Website Pricing Cards */
.price-tier-card {
    transition: all 0.3s ease-in-out;
}

.price-tier-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.price-tier-card .card.border-success {
    box-shadow: 0 4px 12px rgba(25, 135, 84, 0.3);
}

.price-tier-card .card-header {
    font-size: 1.25rem;
    font-weight: 600;
}

.price-tier-card .pricing-options h3 {
    color: #183f8d;
    margin-bottom: 0.25rem;
}

.price-tier-card .feature-list {
    list-style: none;
    padding-left: 0;
}

.price-tier-card .feature-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
}

.price-tier-card .feature-list li:last-child {
    border-bottom: none;
}

.price-tier-card .feature-list i {
    margin-right: 0.5rem;
    font-size: 1.1em;
}

/* System Settings PayPal Toggle */
#togglePayPalSecret {
    cursor: pointer;
    transition: color 0.2s ease-in-out;
}

#togglePayPalSecret:hover {
    color: #0d6efd;
}

/* Status Badges */
.badge.bg-trial {
    background-color: #17a2b8 !important;
}

.badge.bg-expired {
    background-color: #6c757d !important;
}

.badge.bg-disabled {
    background-color: #dc3545 !important;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .subscription-info {
        font-size: 0.85rem;
    }

    #availablePlansContainer .col-12 {
        margin-bottom: 1rem;
    }

    .price-tier-card {
        margin-bottom: 1.5rem;
    }
}

/* Email features while the organization has no enabled Email Configuration (site.ts shows #emailRequiredModal on click) */
body[data-email-configured="false"] [data-requires-email] {
    opacity: 0.55;
    cursor: not-allowed;
    filter: grayscale(0.4);
}
