/* =========================================================================
   Modern Theme Override for Perfex CRM
   =========================================================================
   Transforms standard Bootstrap 3 / Tailwind 3 flat look into a modern, 
   clean Material Design 3 / iOS-inspired aesthetic.
   Loads automatically as custom.css
========================================================================= */

/* ========= CSS CUSTOM PROPERTIES ========= */
/* ========= FIXED LAYOUT — Sidebar & Header stay still, only content scrolls ========= */
html, body {
    height: 100%;
    overflow: hidden; /* Prevent full-page scroll */
}

/* Fixed sidebar */
#menu.sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    height: 100vh !important;
    width: 230px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    z-index: 200 !important;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}
#menu.sidebar::-webkit-scrollbar { width: 4px; }
#menu.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

/* Fixed top header */
#header {
    position: fixed !important;
    top: 0 !important;
    left: 230px !important;
    right: 0 !important;
    z-index: 199 !important;
    height: 63px !important;
}

/* Main content area — offset from fixed sidebar & header, scrollable */
#wrapper {
    margin-left: 230px !important;
    padding-top: 63px !important;
    height: 100vh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

/* Mobile: collapse sidebar above the content */
@media (max-width: 767px) {
    #menu.sidebar {
        width: 230px !important;
        transform: translateX(-230px);
        transition: transform 0.3s ease;
    }
    body.sidebar-open #menu.sidebar {
        transform: translateX(0);
    }
    #header {
        left: 0 !important;
    }
    #wrapper {
        margin-left: 0 !important;
    }
}

:root {
    /* Colors */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    
    /* Backgrounds */
    --bg-canvas: #f8fafc;
    --bg-surface: #ffffff;
    --bg-sidebar: #0f172a;
    
    /* Text */
    --text-main: #0f172a;
    --text-muted: #64748b;
    
    /* Borders & Shadows */
    --border-color: #e2e8f0;
    --border-soft: rgba(226, 232, 240, 0.7);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-modal: 0 24px 48px rgba(0,0,0,0.12);
    --shadow-dropdown: 0 8px 32px rgba(0,0,0,0.1), 0 2px 8px rgba(0,0,0,0.04);
    
    /* Gradients */
    --grad-primary: linear-gradient(135deg, #3b82f6, #2563eb);
    --grad-success: linear-gradient(135deg, #34d399, #10b981);
    --grad-warning: linear-gradient(135deg, #fbbf24, #f59e0b);
    --grad-danger: linear-gradient(135deg, #f87171, #ef4444);
    --grad-info: linear-gradient(135deg, #7dd3fc, #0ea5e9);
    
    /* Radii */
    --radius-sm: 8px;
    --radius-md: 10px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-pill: 9999px;
    
    /* Animation */
    --transition-base: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========= GLOBAL & BASE ========= */
body {
    color: var(--text-main);
}
#wrapper {
    background-color: var(--bg-canvas) !important;
}

/* Scrollbar (Webkit) */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background-color: #94a3b8;
}

/* Links & Interactive Transitions */
a, .btn, .panel_s, .card, .widget, tr {
    transition: var(--transition-base);
}
a:not(.btn):not(.dropdown-item) {
    text-decoration: none;
}
a:not(.btn):not(.dropdown-item):hover {
    color: var(--primary-hover);
    text-decoration: none;
}

/* Separators */
hr, .hr-panel-separator {
    border-color: #f1f5f9 !important;
    margin-top: 15px;
    margin-bottom: 15px;
}

/* ========= CARDS & PANELS ========= */
.panel_s, .panel, .widget, .top_stats_wrapper {
    border-radius: var(--radius-xl) !important;
    background-color: var(--bg-surface) !important;
    border: 1px solid var(--border-soft) !important;
    box-shadow: var(--shadow-sm) !important;
    margin-bottom: 24px;
    overflow: hidden;
}
.panel_s:hover, .widget:hover, .top_stats_wrapper:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md) !important;
}
.panel-body {
    padding: 22px !important;
    border-radius: inherit !important;
}
.panel-heading {
    background-color: transparent !important;
    border-bottom: 1px solid var(--border-soft) !important;
    font-weight: 600;
    padding: 16px 22px !important;
}

/* ========= HEADER / NAVBAR ========= */
#header {
    background: rgba(255, 255, 255, 0.85) !important;
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
    border-bottom: 1px solid rgba(226, 232, 240, 0.6) !important;
    box-shadow: none !important;
    height: 63px !important;
}

/* Search Bar */
#top_search {
    border-radius: var(--radius-pill) !important;
    background-color: rgba(241, 245, 249, 0.8) !important;
    border: 1px solid transparent !important;
    padding: 8px 16px !important;
    transition: var(--transition-base) !important;
}
#top_search:focus {
    background-color: #ffffff !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15) !important;
}

/* Header Quick Action (+) */
.header-add-btn {
    border-radius: var(--radius-pill) !important;
}

/* ========= SIDEBAR MENU ========= */
#menu.sidebar, #side-menu, .sidebar-menu-inner {
    background-color: var(--bg-sidebar) !important;
}
#side-menu li a {
    color: #cbd5e1 !important;
    transition: var(--transition-base);
}
#side-menu li a:hover, #side-menu li a:focus {
    background-color: rgba(255, 255, 255, 0.05) !important;
    color: #ffffff !important;
}
/* Active Top-Level Item */
#side-menu > li.active > a {
    background: var(--grad-primary) !important;
    color: #ffffff !important;
    border-radius: var(--radius-md) !important;
    margin: 3px 12px !important;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3) !important;
}
/* Submenu */
#side-menu .nav-second-level {
    background-color: transparent !important;
    padding-left: 12px;
}
/* Active Submenu Item */
#side-menu .nav-second-level > li.active > a {
    background-color: rgba(59, 130, 246, 0.15) !important;
    color: #60a5fa !important;
    border-radius: var(--radius-sm) !important;
    margin: 2px 12px 2px 0 !important;
}

/* ========= BUTTONS ========= */
.btn {
    border-radius: var(--radius-md) !important;
    font-weight: 500 !important;
    letter-spacing: 0.01em;
    border: none !important;
    transition: var(--transition-base) !important;
}
.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.btn:active, .btn:focus {
    transform: translateY(0);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1) !important;
}
/* Button Variants */
.btn-primary { background: var(--grad-primary) !important; color: #fff !important; }
.btn-success { background: var(--grad-success) !important; color: #fff !important; }
.btn-warning { background: var(--grad-warning) !important; color: #fff !important; }
.btn-danger  { background: var(--grad-danger) !important; color: #fff !important; }
.btn-info    { background: var(--grad-info) !important; color: #fff !important; }
.btn-default { 
    background: #ffffff !important; 
    color: var(--text-main) !important; 
    border: 1px solid var(--border-color) !important; 
}
.btn-default:hover { background: #f1f5f9 !important; }

.btn-icon {
    border-radius: var(--radius-md) !important;
}
.btn-icon.btn-rounded {
    border-radius: var(--radius-pill) !important;
}

/* ========= STATUS BADGES / LABELS ========= */
.label {
    border-radius: var(--radius-pill) !important;
    padding: 4px 12px !important;
    font-weight: 600 !important;
    font-size: 11.5px !important;
    letter-spacing: 0.02em !important;
    display: inline-block;
    line-height: 1.2;
}
.label-success { background-color: #dcfce7 !important; color: #15803d !important; border: 1px solid #bbf7d0 !important; }
.label-warning { background-color: #fef3c7 !important; color: #b45309 !important; border: 1px solid #fde68a !important; }
.label-danger  { background-color: #fee2e2 !important; color: #b91c1c !important; border: 1px solid #fecaca !important; }
.label-info    { background-color: #e0f2fe !important; color: #0369a1 !important; border: 1px solid #bae6fd !important; }
.label-primary { background-color: #dbeafe !important; color: #1d4ed8 !important; border: 1px solid #bfdbfe !important; }
.label-default { background-color: #f1f5f9 !important; color: #475569 !important; border: 1px solid #e2e8f0 !important; }

/* ========= PROGRESS BARS ========= */
.progress {
    border-radius: var(--radius-pill) !important;
    height: 8px !important;
    background-color: var(--border-color) !important;
    box-shadow: none !important;
    margin-bottom: 12px !important;
}
.progress-bar {
    border-radius: var(--radius-pill) !important;
    box-shadow: none !important;
}
.progress-bar-success { background: var(--grad-success) !important; }
.progress-bar-warning { background: var(--grad-warning) !important; }
.progress-bar-danger  { background: var(--grad-danger) !important; }
.progress-bar-info    { background: var(--grad-info) !important; }
/* Mini variant */
.progress-bar-mini, .progress.progress-bar-mini {
    height: 5px !important;
}

/* ========= DATATABLES & TABLES ========= */
.table-responsive {
    border: none !important;
}
.table, .dt-table {
    border-radius: var(--radius-xl) !important;
    border-collapse: separate !important;
    border-spacing: 0;
    width: 100% !important;
    border: 1px solid var(--border-color) !important;
    overflow: hidden;
}
.table thead th {
    text-transform: uppercase;
    font-size: 11px !important;
    font-weight: 600 !important;
    letter-spacing: 0.05em;
    color: var(--text-muted) !important;
    border-bottom: 2px solid var(--border-color) !important;
    padding: 14px 16px !important;
    background-color: var(--bg-canvas) !important;
    border-top: none !important;
}
.table tbody td {
    padding: 14px 16px !important;
    vertical-align: middle !important;
    border-bottom: 1px solid #f1f5f9 !important;
    border-top: none !important;
}
.table tbody tr:hover td {
    background-color: #f8fafc !important;
}
.table-striped tbody tr:nth-of-type(odd) {
    background-color: #fafbfc !important;
}
/* DataTables wrappers */
.dataTables_wrapper {
    padding-top: 10px;
}

/* ========= MODALS ========= */
.modal-content {
    border-radius: var(--radius-xl) !important;
    border: none !important;
    box-shadow: var(--shadow-modal) !important;
}
.modal-header {
    border-radius: var(--radius-xl) var(--radius-xl) 0 0 !important;
    border-bottom: 1px solid var(--border-color) !important;
    padding: 20px 24px !important;
}
.modal-footer {
    border-radius: 0 0 var(--radius-xl) var(--radius-xl) !important;
    border-top: 1px solid var(--border-color) !important;
    padding: 16px 24px !important;
    background-color: var(--bg-canvas) !important;
}
.modal-backdrop {
    opacity: 0.6 !important;
}

/* ========= FORM INPUTS ========= */
.form-control {
    border-radius: var(--radius-md) !important;
    border: 1.5px solid var(--border-color) !important;
    padding: 10px 14px !important;
    height: auto !important;
    box-shadow: none !important;
    transition: var(--transition-base) !important;
}
.form-control:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(37, 130, 246, 0.12) !important;
    outline: none !important;
}
.form-group label, .control-label {
    font-weight: 500 !important;
    color: #334155 !important;
    margin-bottom: 6px !important;
}
/* Selectpicker / Bootstrap Select */
.bootstrap-select .dropdown-toggle {
    border-radius: var(--radius-md) !important;
    border: 1.5px solid var(--border-color) !important;
}
.bootstrap-select.open .dropdown-toggle, .bootstrap-select:focus .dropdown-toggle {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(37, 130, 246, 0.12) !important;
}
textarea.form-control {
    border-radius: var(--radius-md) !important;
}

/* ========= QUICK STATS WIDGET ========= */
.top_stats_wrapper .tw-bg-white {
    background-color: transparent !important;
}
.top_stats_wrapper i {
    opacity: 0.8;
}

/* ========= DROPDOWN MENUS ========= */
.dropdown-menu {
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-dropdown) !important;
    border: 1px solid var(--border-soft) !important;
    padding: 6px !important;
    margin-top: 8px !important;
}
.dropdown-menu > li > a {
    border-radius: 6px !important;
    padding: 8px 16px !important;
    margin: 2px 4px !important;
    transition: var(--transition-base);
}
.dropdown-menu > li > a:hover, .dropdown-menu > li > a:focus {
    background-color: #f1f5f9 !important;
    color: var(--text-main) !important;
}

/* ========= ALERTS ========= */
.alert {
    border-radius: var(--radius-lg) !important;
    border: none !important;
    padding: 16px !important;
    box-shadow: var(--shadow-sm);
}
.alert-success { background-color: #dcfce7 !important; color: #15803d !important; border-left: 4px solid #22c55e !important; }
.alert-warning { background-color: #fef3c7 !important; color: #b45309 !important; border-left: 4px solid #f59e0b !important; }
.alert-danger  { background-color: #fee2e2 !important; color: #b91c1c !important; border-left: 4px solid #ef4444 !important; }
.alert-info    { background-color: #e0f2fe !important; color: #0369a1 !important; border-left: 4px solid #3b82f6 !important; }

/* ========= BREADCRUMBS & HEADERS ========= */
.page-title {
    font-weight: 700 !important;
    color: var(--text-main) !important;
    margin-bottom: 15px;
}
.breadcrumb {
    background-color: transparent !important;
    padding: 0 !important;
    margin-bottom: 20px !important;
}
.breadcrumb > li {
    font-size: 13px;
}

/* ========= TABS ========= */
.nav-tabs {
    border-bottom: 1px solid var(--border-color) !important;
    margin-bottom: 20px;
}
.nav-tabs > li > a {
    border: none !important;
    color: var(--text-muted) !important;
    font-weight: 500;
    padding: 12px 16px !important;
    margin-right: 8px !important;
    border-radius: var(--radius-md) var(--radius-md) 0 0 !important;
    transition: var(--transition-base);
}
.nav-tabs > li > a:hover {
    background-color: #f1f5f9 !important;
    color: var(--text-main) !important;
}
.nav-tabs > li.active > a, 
.nav-tabs > li.active > a:hover, 
.nav-tabs > li.active > a:focus {
    color: var(--primary) !important;
    background-color: transparent !important;
    border-bottom: 2px solid var(--primary) !important;
}

/* ========= PAGINATION ========= */
.pagination > li > a, .pagination > li > span {
    border-radius: var(--radius-sm) !important;
    margin: 0 2px !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-muted) !important;
    transition: var(--transition-base);
}
.pagination > li > a:hover {
    background-color: #f1f5f9 !important;
    color: var(--text-main) !important;
}
.pagination > .active > a, 
.pagination > .active > span, 
.pagination > .active > a:hover, 
.pagination > .active > span:hover {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #fff !important;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2) !important;
}

/* ========= TOOLTIPS & POPOVERS ========= */
.tooltip-inner {
    border-radius: var(--radius-sm) !important;
    padding: 6px 12px !important;
    background-color: #334155 !important;
    font-size: 12px !important;
}
.popover {
    border-radius: var(--radius-lg) !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: var(--shadow-lg) !important;
}
.popover-title {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
    background-color: var(--bg-canvas) !important;
    border-bottom: 1px solid var(--border-color) !important;
    font-weight: 600;
}
