/* Construction Sales Management ERP/CRM Corporate SaaS Theme */

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

:root {
    /* Color Palette */
    --bg-main: #0b0f19;
    --bg-sidebar: #111827;
    --bg-panel: #1f2937;
    --bg-input: #111827;
    
    --border-color: #374151;
    --border-light: rgba(255, 255, 255, 0.05);
    
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --primary: #3b82f6;       /* Clean Blue */
    --primary-hover: #2563eb;
    --success: #10b981;       /* Professional Emerald Green */
    --danger: #ef4444;        /* Rose Red */
    --warning: #f59e0b;       /* Amber Warning */
    --info: #6366f1;          /* Indigo */
    
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --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);
    
    --border-radius: 8px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: #374151;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #4b5563;
}

/* Layout Container */
.app-container {
    display: flex;
    width: 100%;
    min-height: 100vh;
    position: relative;
}

/* Sidebar & Nested Collapsible Trees */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 1000;
    transition: transform 0.25s ease;
}

.sidebar-brand {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-brand-title {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.35;
    letter-spacing: -0.3px;
}

.sidebar-brand-title i {
    color: var(--primary);
    font-size: 1.1rem;
    margin-top: 2px;
}

.sidebar-close-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
}

.sidebar-user {
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
}

.user-avatar {
    width: 36px;
    height: 36px;
    background-color: var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    border: 1px solid var(--text-muted);
}

.user-info {
    overflow: hidden;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Sidebar Menu Tree */
.sidebar-menu {
    list-style: none;
    padding: 16px 8px;
    flex-grow: 1;
    overflow-y: auto;
}

.sidebar-item {
    margin-bottom: 4px;
    display: flex;
    flex-direction: column;
}

.sidebar-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--border-radius);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.sidebar-link-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-link i {
    font-size: 1rem;
    width: 20px;
    text-align: center;
}

.sidebar-link:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.04);
}

.sidebar-link.active {
    color: #fff;
    background-color: var(--primary);
}

.arrow-icon {
    font-size: 0.75rem;
    transition: transform 0.2s ease;
    color: var(--text-muted);
}

.sidebar-link.open .arrow-icon {
    transform: rotate(90deg);
}

/* Submenu Lists */
.sidebar-submenu {
    list-style: none;
    padding-left: 20px;
    margin-top: 2px;
    margin-bottom: 4px;
    display: none;
    flex-direction: column;
    gap: 2px;
    border-left: 1px dashed var(--border-color);
    margin-left: 26px;
}

.sidebar-submenu.open {
    display: flex;
}

.submenu-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.submenu-link:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.03);
}

.submenu-link.active {
    color: var(--primary);
    background-color: rgba(59, 130, 246, 0.08);
    font-weight: 600;
}

.sidebar-logout {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

/* Main Area Wrapper */
.main-content {
    flex-grow: 1;
    margin-left: 260px;
    padding: 30px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    width: calc(100% - 260px);
    transition: margin-left 0.25s ease, width 0.25s ease;
}

/* Mobile Hamburger Menu */
.menu-toggle-btn {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
}

/* Header bar */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 20px;
}

.page-title h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.5px;
}

.page-title p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Top bar actions & Global Search */
.nav-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.search-bar-container {
    position: relative;
    width: 260px;
}

.search-bar-container input {
    padding-left: 36px;
}

.search-bar-container i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.notification-bell {
    position: relative;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-secondary);
    transition: var(--transition);
}

.notification-bell:hover {
    color: #fff;
}

.notification-count {
    position: absolute;
    top: -6px;
    right: -8px;
    background-color: var(--danger);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Quick Actions Widget */
.quick-actions-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

/* 8-Card Responsive Grid system (Fixes cutoffs) */
.card-grid-8 {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 16px;
    margin-bottom: 24px;
    width: 100%;
}

@media (min-width: 576px) {
    .card-grid-8 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 992px) {
    .card-grid-8 { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1200px) {
    .card-grid-8 { grid-template-columns: repeat(4, 1fr); }
}

/* Stat Cards */
.stat-card {
    background: linear-gradient(135deg, #1e293b, #111827);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-left: 4px solid var(--primary);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 4px 20px -5px rgba(0, 0, 0, 0.3), inset 0 1px 1px 0 rgba(255, 255, 255, 0.04);
    position: relative;
    overflow: hidden;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 110px;
}

.stat-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px -5px rgba(0, 0, 0, 0.5), inset 0 1px 1px 0 rgba(255, 255, 255, 0.08);
}

.stat-icon {
    position: absolute;
    right: 16px;
    top: 16px;
    font-size: 1.25rem;
    color: var(--text-muted);
}

.stat-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    padding-right: 25px;
}

.stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    margin-top: 10px;
    color: #fff;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-desc {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 6px;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

/* Panel Layout rows */
.dashboard-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.dashboard-row-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.dashboard-row-equal {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

@media (max-width: 1024px) {
    .dashboard-row, .dashboard-row-3, .dashboard-row-equal {
        grid-template-columns: 1fr;
    }
}

.panel-card {
    background: linear-gradient(145deg, #1e293b, #111827);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5), inset 0 1px 1px 0 rgba(255, 255, 255, 0.05);
    position: relative;
    transition: var(--transition);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.panel-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-title i {
    color: var(--text-secondary);
}

/* Funnel indicators styling */
.funnel-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.funnel-row {
    display: flex;
    align-items: center;
    gap: 15px;
}

.funnel-label {
    width: 90px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.funnel-bar-wrapper {
    flex-grow: 1;
    background-color: #111827;
    height: 20px;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.funnel-bar {
    height: 100%;
    background-color: var(--primary);
    border-radius: 4px;
    transition: width 0.4s ease;
}

.funnel-value {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
}

/* Table Grid */
.table-responsive {
    overflow-x: auto;
    width: 100%;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
}

.custom-table th {
    padding: 10px 14px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    background-color: rgba(17, 24, 39, 0.5);
}

.custom-table td {
    padding: 12px 14px;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.custom-table tbody tr {
    transition: var(--transition);
}

.custom-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.badge-new { background-color: rgba(59, 130, 246, 0.1); color: #60a5fa; }
.badge-contacted { background-color: rgba(99, 102, 241, 0.1); color: #818cf8; }
.badge-followup { background-color: rgba(245, 158, 11, 0.1); color: #fbbf24; }
.badge-sitevisit { background-color: rgba(16, 185, 129, 0.1); color: #34d399; }
.badge-negotiation { background-color: rgba(236, 72, 153, 0.1); color: #f472b6; }
.badge-success { background-color: rgba(16, 185, 129, 0.1); color: #34d399; }
.badge-danger { background-color: rgba(239, 68, 68, 0.1); color: #f87171; }
.badge-warning { background-color: rgba(245, 158, 11, 0.1); color: #fbbf24; }
.badge-info { background-color: rgba(99, 102, 241, 0.1); color: #818cf8; }
.badge-secondary { background-color: rgba(107, 114, 128, 0.1); color: #9ca3af; }

/* Form Elements */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 8px 12px;
    color: #fff;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%239ca3af' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 10px center;
    background-repeat: no-repeat;
    background-size: 18px;
    padding-right: 32px;
}

select.form-control option {
    background-color: #1f2937;
    color: #ffffff;
}

/* Button UI */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--border-radius);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    text-decoration: none;
}

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

.btn-secondary {
    background-color: #374151;
    border-color: var(--border-color);
    color: var(--text-primary);
}
.btn-secondary:hover {
    background-color: #4b5563;
}

.btn-danger {
    background-color: var(--danger);
    color: #fff;
}
.btn-danger:hover {
    background-color: #dc2626;
}

.btn-success {
    background-color: var(--success);
    color: #fff;
}
.btn-success:hover {
    background-color: #059669;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.75rem;
}

/* Modal Popup */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    padding: 24px;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal.active .modal-content {
    transform: scale(1);
}

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

.modal-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: #fff;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
}

/* Progress indicator */
.progress-bar-container {
    width: 100%;
    background-color: #111827;
    border-radius: 9999px;
    height: 8px;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    background-color: var(--primary);
    border-radius: 9999px;
    transition: width 0.4s ease;
}

/* Podium Step */
.podium-container {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 12px;
    margin-top: 15px;
    height: 150px;
}

.podium-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    width: 80px;
    text-align: center;
    padding-bottom: 8px;
}

.podium-step.first {
    height: 130px;
    border-color: #f59e0b;
}
.podium-step.second {
    height: 95px;
    border-color: #9ca3af;
}
.podium-step.third {
    height: 75px;
    border-color: #b45309;
}

.podium-badge {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    position: absolute;
    top: -14px;
    font-size: 0.8rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.podium-step.first .podium-badge { background-color: #f59e0b; color: #1e1b4b; }
.podium-step.second .podium-badge { background-color: #9ca3af; color: #111827; }
.podium-step.third .podium-badge { background-color: #b45309; color: #fff; }

.podium-name {
    font-size: 0.7rem;
    font-weight: 600;
    margin-top: 20px;
    padding: 0 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
    color: #fff;
}

.podium-value {
    font-size: 0.7rem;
    color: var(--primary);
    font-weight: 700;
    margin-top: 2px;
}

/* Alert notifications */
.alert {
    padding: 10px 16px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background-color: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: #34d399;
}

.alert-danger {
    background-color: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.alert-warning {
    background-color: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

/* Detail views styling */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.detail-item {
    background-color: rgba(0, 0, 0, 0.15);
    padding: 10px 14px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.02);
}

.detail-item-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.detail-item-value {
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
}

/* Tab Headers */
.tabs-header {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 8px 16px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 6px;
    transition: var(--transition);
}

.tab-btn:hover {
    color: #fff;
    background-color: rgba(255,255,255,0.03);
}

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

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* Media Queries for Sidebar collapsibility & Drawer drawers */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-260px);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-close-btn {
        display: block;
    }
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 20px;
    }
    .menu-toggle-btn {
        display: block;
    }
}
