/* ── CRM System Custom Styles ── */

:root {
    --sidebar-width: 260px;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --primary-color: #3b82f6;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.sidebar .nav-link {
    border-radius: 0.5rem;
    padding: 0.55rem 0.75rem;
    font-size: 0.9rem;
    transition: background-color 0.15s;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    background-color: var(--sidebar-hover);
}

#page-content-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    background: #f1f5f9;
}

/* Module cards on dashboard */
.module-card {
    transition: transform 0.15s, box-shadow 0.15s;
    border-radius: 0.75rem;
}

.module-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1) !important;
}

.quick-actions-card {
    background: linear-gradient(135deg, #ffffff 0%, #e8f0fe 100%);
}

.mobile-fab {
    position: fixed;
    right: 18px;
    bottom: 18px;
    width: 56px;
    height: 56px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 22px rgba(59, 130, 246, 0.35);
    z-index: 1060;
}

.service-calculator-card {
    background: linear-gradient(135deg, #ffffff 0%, #edf4ff 100%);
}

.calc-pos-page {
    max-width: 1200px;
    margin: 0 auto;
}

.calc-pos-form .card {
    border-radius: 0.9rem;
}

.calc-total-value {
    font-size: 1.35rem;
    font-weight: 800;
    line-height: 1;
    color: #0f172a;
}

.calc-category-btn.active {
    background: #0f172a;
    border-color: #0f172a;
    color: #ffffff;
}

.calc-locations-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
}

.calc-location-btn {
    min-height: 92px;
}

.calc-location-btn:hover {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #94a3b8;
}

.calc-location-btn.is-selected {
    background: #e6f1ff;
    border-color: #3b82f6;
    color: #0f172a;
    box-shadow: inset 0 0 0 1px #60a5fa;
}

.calc-location-btn.is-selected .text-muted {
    color: #334155 !important;
}

.point-prices-table-wrap {
    max-height: 68vh;
    overflow: auto;
}

.point-prices-table-wrap thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #f8fafc;
}

#point-prices-table td,
#point-prices-table th {
    padding: 0.45rem 0.5rem;
}

.matrix-cell {
    transition: background-color 0.2s ease;
}

.matrix-cell-updating {
    background: #fef3c7;
}

.matrix-cell-saved {
    background: #dcfce7;
}

.matrix-cell-error {
    background: #fee2e2;
}

.calc-actions-fixed {
    position: sticky;
    bottom: 0;
    background: rgba(241, 245, 249, 0.96);
    backdrop-filter: blur(4px);
    border-top: 1px solid #d8e0ea;
    padding: 0.6rem 0.25rem 0.25rem;
    z-index: 20;
}

.calculator-result {
    border: 1px dashed #cbd5e1;
    border-radius: 0.75rem;
    background: #f8fafc;
    padding: 0.9rem 1rem;
    min-height: 86px;
    display: flex;
    align-items: center;
}

.calculator-breakdown {
    padding-left: 1rem;
    font-size: 0.86rem;
    color: #475569;
}

.calculator-breakdown li + li {
    margin-top: 0.2rem;
}

/* Record rows */
.record-row:hover {
    background-color: #e8f0fe !important;
}

.status-pill {
    display: inline-flex;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.78rem;
}

.record-row.status-row--default {
    background-color: #ffffff;
}

.record-row.status-row--custom {
    background-color: var(--status-row-color, #ffffff);
}

.table > tbody > tr.record-row.status-row--default > td {
    background-color: #ffffff;
}

.table > tbody > tr.record-row.status-row--custom > td {
    background-color: var(--status-row-color, #ffffff) !important;
}

.record-row:hover.status-row--custom,
.record-row:hover.status-row--default {
    filter: brightness(0.98);
}

.table.table-hover > tbody > tr.record-row.status-row--custom:hover > td,
.table.table-hover > tbody > tr.record-row.status-row--default:hover > td {
    filter: brightness(0.98);
}

.record-row[data-readonly="true"]:hover,
.table.table-hover > tbody > tr.record-row[data-readonly="true"]:hover > td {
    filter: none;
}

.record-row.js-order-row-toggle.is-expanded > td {
    border-bottom-color: transparent;
}

.order-expand-indicator {
    transition: transform 0.18s ease;
}

.record-row.js-order-row-toggle.is-expanded .order-expand-indicator {
    transform: rotate(180deg);
}

.order-details-row > td {
    background: #f8fafc;
    border-top: 0;
}

.order-details-wrap {
    border-left: 3px solid #cbd5e1;
    padding: 0.85rem 1rem;
}

.js-order-edit-btn {
    min-width: 2.1rem;
}

.js-status-select {
    min-width: 130px;
    font-size: 0.8rem;
    font-weight: 600;
}

.records-table {
    min-width: 780px;
}

.records-table td.record-cell {
    max-width: 280px;
    white-space: normal;
    word-break: break-word;
}

/* Login page */
.login-page .card {
    border-radius: 1rem;
}

/* Table improvements */
.table th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    font-weight: 600;
}

.table td {
    font-size: 0.9rem;
    vertical-align: middle;
}

/* Modal */
.modal-content {
    border: 0;
    border-radius: 1rem;
}

/* Cards */
.card {
    border-radius: 0.75rem;
}

/* Badges */
.badge {
    font-weight: 500;
}

/* Pagination */
.pagination .page-link {
    border-radius: 0.5rem;
    margin: 0 2px;
    border: none;
    color: #475569;
}

.pagination .page-item.active .page-link {
    background-color: var(--primary-color);
}

/* ── MOBILE RESPONSIVE ── */
@media (max-width: 767.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    #page-content-wrapper {
        margin-left: 0;
    }

    .calc-locations-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .calc-actions-fixed {
        padding-bottom: 0.5rem;
    }

    .records-table {
        min-width: 660px;
    }

}

@media (max-width: 575.98px) {
    .calc-locations-grid {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 768px) {
    .d-md-none .navbar {
        display: none !important;
    }
}

/* Scrollbar styling (webkit) */
.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

/* Form controls in modals */
.modal .form-control-plaintext {
    border: 1px solid #e2e8f0;
}

.record-edit-modal-body {
    max-height: calc(100vh - 240px);
    overflow-y: auto;
    overflow-x: hidden;
}

.drawer-edit-form {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.drawer-edit-form .record-edit-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
}

.record-edit-field {
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    padding: 0.75rem;
    background: #f8fafc;
}

.record-edit-field .form-control,
.record-edit-field .form-select,
.record-edit-field .form-control-plaintext {
    background: #fff;
}

@media (max-width: 767.98px) {
    .record-edit-modal-body {
        max-height: calc(100vh - 200px);
    }
}

/* Smooth transitions */
* {
    scroll-behavior: smooth;
}
