/* Sales Page Styles */

/* Date Range Badge */
.date-range-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.1));
    color: #6366f1;
    font-size: 12px;
    font-weight: 500;
    border-radius: 20px;
    margin-left: 12px;
}

/* Sales Page Container */
#page-sales {
    min-width: 100%;
    padding-bottom: 20px;
}

/* Allow horizontal scroll only for tables on mobile */
@media (max-width: 768px) {
    #page-sales {
        overflow-x: visible;
    }
}

/* Sales Filter Card */
.sales-filter-card {
    margin-bottom: 20px;
}

.sales-filter-card .card-header {
    margin-bottom: 16px;
}

.sales-filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
}

.sales-filters-row .filter-group {
    flex: 1;
    min-width: 150px;
    max-width: 200px;
}

.sales-filter-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-left: auto;
}

@media (max-width: 768px) {
    .sales-filters-row {
        flex-direction: column;
        align-items: stretch;
    }

    .sales-filters-row .filter-group {
        max-width: none;
    }

    .sales-filter-actions {
        margin-left: 0;
        justify-content: flex-start;
    }
}

/* Sales Stat Cards - Revenue focused (green gradients) */
.sales-stat-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.sales-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.sales-stat-card-inner {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.sales-stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sales-stat-icon svg {
    width: 24px;
    height: 24px;
}

/* Sales color variations */
.sales-stat-icon.revenue {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(52, 211, 153, 0.15));
    color: #10B981;
}

.sales-stat-icon.conversion {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(96, 165, 250, 0.15));
    color: #3B82F6;
}

.sales-stat-icon.deals {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(167, 139, 250, 0.15));
    color: #8B5CF6;
}

.sales-stat-icon.calls {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.15), rgba(34, 211, 238, 0.15));
    color: #06B6D4;
}

.sales-stat-icon.gold {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(251, 191, 36, 0.15));
    color: #F59E0B;
}

.sales-stat-icon.velocity {
    background: linear-gradient(135deg, rgba(236, 72, 153, 0.15), rgba(244, 114, 182, 0.15));
    color: #EC4899;
}

.sales-stat-content {
    flex: 1;
    min-width: 0;
}

.sales-stat-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
    line-height: 1.2;
}

.sales-stat-value.currency {
    color: #10B981;
}

.sales-stat-label {
    font-size: 12px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

/* Sales Performer Cards */
.sales-performer-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.sales-performer-card {
    padding: 24px;
    border-radius: 16px;
    color: var(--white);
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.sales-performer-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 24px -8px rgba(0, 0, 0, 0.25);
}

.sales-performer-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    pointer-events: none;
}

.sales-performer-card.top-seller {
    background: linear-gradient(135deg, #10B981 0%, #047857 100%);
}

.sales-performer-card.best-converter {
    background: linear-gradient(135deg, #3B82F6 0%, #1D4ED8 100%);
}

.sales-performer-card.best-revenue-per-call {
    background: linear-gradient(135deg, #8B5CF6 0%, #6D28D9 100%);
}

.sales-performer-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.sales-performer-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 20px;
    border: 2px solid rgba(255,255,255,0.3);
}

.sales-performer-info {
    flex: 1;
}

.sales-performer-name {
    font-weight: 600;
    font-size: 18px;
    margin-bottom: 4px;
}

.sales-performer-title {
    font-size: 13px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 6px;
}

.sales-performer-title svg {
    width: 14px;
    height: 14px;
}

.sales-performer-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    text-align: center;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,0.2);
}

.sales-performer-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sales-performer-stat-value {
    font-size: 20px;
    font-weight: 700;
}

.sales-performer-stat-label {
    font-size: 10px;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Sales Leaderboard Table */
.sales-table {
    width: 100%;
    border-collapse: collapse;
}

.sales-table th {
    background: var(--gray-50);
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--gray-200);
    cursor: pointer;
    transition: background 0.2s ease;
    white-space: nowrap;
}

.sales-table th:hover {
    background: var(--gray-100);
}

.sales-table th.sorted {
    color: var(--primary);
}

.sales-table th .sort-icon {
    margin-left: 4px;
    opacity: 0.5;
}

.sales-table th.sorted .sort-icon {
    opacity: 1;
}

.sales-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 14px;
    color: var(--gray-700);
}

.sales-table tbody tr {
    transition: background 0.2s ease;
    cursor: pointer;
}

.sales-table tbody tr:hover {
    background: var(--gray-50);
}

/* Rank cell */
.sales-rank-cell {
    width: 50px;
    text-align: center;
}

.sales-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-weight: 600;
    font-size: 12px;
}

.sales-rank.rank-1 {
    background: linear-gradient(135deg, #F59E0B, #D97706);
    color: white;
}

.sales-rank.rank-2 {
    background: linear-gradient(135deg, #9CA3AF, #6B7280);
    color: white;
}

.sales-rank.rank-3 {
    background: linear-gradient(135deg, #D97706, #B45309);
    color: white;
}

.sales-rank.rank-other {
    background: var(--gray-100);
    color: var(--gray-600);
}

/* User cell */
.sales-user-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sales-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    color: white;
    flex-shrink: 0;
}

.sales-user-info {
    display: flex;
    flex-direction: column;
}

.sales-user-name {
    font-weight: 500;
    color: var(--gray-900);
}

.sales-user-subtitle {
    font-size: 12px;
    color: var(--gray-500);
}

/* Revenue cell */
.sales-revenue-cell {
    font-weight: 600;
    color: #10B981;
}

/* KPI Badge */
.kpi-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}

.kpi-badge.good {
    background: rgba(16, 185, 129, 0.1);
    color: #10B981;
}

.kpi-badge.warning {
    background: rgba(245, 158, 11, 0.1);
    color: #D97706;
}

.kpi-badge.danger {
    background: rgba(239, 68, 68, 0.1);
    color: #EF4444;
}

/* Score Bar */
.score-bar {
    width: 60px;
    height: 6px;
    background: var(--gray-100);
    border-radius: 3px;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
}

.score-bar-fill {
    display: block;
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.score-bar-fill.high {
    background: linear-gradient(90deg, #10B981, #34D399);
}

.score-bar-fill.medium {
    background: linear-gradient(90deg, #F59E0B, #FBBF24);
}

.score-bar-fill.low {
    background: linear-gradient(90deg, #EF4444, #F87171);
}

/* Sales Charts Grid */
.sales-charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

@media (max-width: 1200px) {
    .sales-charts-grid {
        grid-template-columns: 1fr;
    }
}

.sales-chart-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    padding: 20px;
}

.sales-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.sales-chart-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-900);
}

.sales-chart-container {
    height: 280px;
    position: relative;
}

/* Empty State */
.sales-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-500);
}

.sales-empty-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    background: var(--gray-100);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sales-empty-icon svg {
    width: 40px;
    height: 40px;
    color: var(--gray-400);
}

.sales-empty-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.sales-empty-text {
    font-size: 14px;
    max-width: 400px;
    margin: 0 auto 20px;
}

/* CRM Import Section */
.crm-import-section {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.05), rgba(52, 211, 153, 0.05));
    border: 1px dashed rgba(16, 185, 129, 0.3);
    border-radius: 12px;
    margin-bottom: 24px;
}

.crm-import-icon {
    width: 48px;
    height: 48px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #10B981;
}

.crm-import-icon svg {
    width: 24px;
    height: 24px;
}

.crm-import-info {
    flex: 1;
}

.crm-import-title {
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.crm-import-desc {
    font-size: 13px;
    color: var(--gray-500);
}

.crm-import-btn {
    background: linear-gradient(135deg, #10B981, #059669);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.crm-import-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.crm-import-btn svg {
    width: 18px;
    height: 18px;
}

/* Sales Summary Row */
.sales-summary-row {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.08), rgba(52, 211, 153, 0.08));
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 12px;
    margin-bottom: 24px;
}

.sales-summary-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sales-summary-label {
    font-size: 13px;
    color: var(--gray-600);
}

.sales-summary-value {
    font-weight: 600;
    color: #10B981;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .sales-performer-cards {
        grid-template-columns: 1fr;
    }

    .sales-performer-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .sales-table {
        font-size: 13px;
    }

    .sales-table th,
    .sales-table td {
        padding: 10px 12px;
    }

    .sales-summary-row {
        flex-wrap: wrap;
        gap: 12px;
    }
}

/* ===========================================
   SALES USER DETAIL MODAL
   =========================================== */

.sales-modal {
    max-width: 800px;
}

.sales-modal-header {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    color: white;
    border-radius: 16px 16px 0 0;
}

.sales-modal-header .modal-title {
    color: white;
}

.sales-modal-header .modal-close {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.sales-modal-header .modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.sales-modal-title-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sales-modal-subtitle {
    font-size: 12px;
    opacity: 0.85;
}

/* Sales Modal Stats */
.sales-modal-stats {
    grid-template-columns: repeat(4, 1fr);
}

.sales-modal-stat {
    position: relative;
    overflow: hidden;
}

.sales-modal-stat::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    border-radius: 4px 0 0 4px;
}

.sales-modal-stat.revenue::before {
    background: linear-gradient(180deg, #10B981, #34D399);
}

.sales-modal-stat.deals::before {
    background: linear-gradient(180deg, #8B5CF6, #A78BFA);
}

.sales-modal-stat.conversion::before {
    background: linear-gradient(180deg, #3B82F6, #60A5FA);
}

.sales-modal-stat.calls::before {
    background: linear-gradient(180deg, #06B6D4, #22D3EE);
}

.sales-modal-stat .modal-stat-value {
    font-size: 22px;
}

/* Secondary Stats Row */
.sales-modal-secondary-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 12px 16px;
    background: var(--gray-50);
    border-radius: 8px;
    margin-bottom: 20px;
}

.sales-modal-secondary-stat {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.sales-modal-secondary-stat .stat-label {
    color: var(--gray-500);
}

.sales-modal-secondary-stat .stat-value {
    font-weight: 600;
    color: #10B981;
}

/* Deals List */
.sales-deals-list {
    max-height: 350px;
    overflow-y: auto;
}

.sales-deal-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-100);
    transition: background 0.15s ease;
}

.sales-deal-item:hover {
    background: var(--gray-50);
}

.sales-deal-item:last-child {
    border-bottom: none;
}

.sales-deal-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.sales-deal-name {
    font-weight: 500;
    color: var(--gray-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sales-deal-meta {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--gray-500);
}

.sales-deal-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.sales-deal-amount {
    font-weight: 600;
    font-size: 15px;
    color: #10B981;
    white-space: nowrap;
    padding-left: 16px;
}

/* Monthly Chart Container */
.sales-monthly-chart-container {
    height: 200px;
    margin-bottom: 20px;
}

/* Monthly Table */
.sales-monthly-table {
    max-height: 200px;
    overflow-y: auto;
}

.sales-monthly-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 13px;
}

.sales-monthly-row:hover {
    background: var(--gray-50);
}

.sales-monthly-month {
    font-weight: 500;
    color: var(--gray-700);
}

.sales-monthly-stats {
    display: flex;
    gap: 20px;
}

.sales-monthly-stats span {
    color: var(--gray-600);
}

.sales-monthly-stats .revenue {
    color: #10B981;
    font-weight: 600;
}

/* Calls Summary Tab */
.sales-calls-summary {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.sales-call-stat-card {
    background: var(--gray-50);
    padding: 16px;
    border-radius: 10px;
    text-align: center;
}

.sales-call-stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.sales-call-stat-label {
    font-size: 12px;
    color: var(--gray-500);
    text-transform: uppercase;
}

.sales-call-stat-card.highlight {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(52, 211, 153, 0.1));
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.sales-call-stat-card.highlight .sales-call-stat-value {
    color: #10B981;
}

/* Empty State in Modal */
.sales-modal-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray-500);
}

.sales-modal-empty svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* Clickable table rows */
.sales-table tbody tr {
    cursor: pointer;
}

.sales-table tbody tr:hover {
    background: var(--gray-50);
}

/* Payment badge */
.payment-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    background: var(--gray-100);
    color: var(--gray-600);
}

.payment-badge.cash {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

.payment-badge.card {
    background: rgba(59, 130, 246, 0.1);
    color: #2563EB;
}

.payment-badge.transfer {
    background: rgba(139, 92, 246, 0.1);
    color: #7C3AED;
}

.payment-badge.check {
    background: rgba(245, 158, 11, 0.1);
    color: #D97706;
}

@media (max-width: 600px) {
    .sales-modal-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .sales-modal-secondary-stats {
        flex-direction: column;
        gap: 8px;
    }

    .sales-calls-summary {
        grid-template-columns: 1fr;
    }
}

/* Enhanced Mobile Sales Styles */
@media (max-width: 768px) {
    .sales-stat-card {
        padding: 16px;
    }

    .sales-stat-card-inner {
        gap: 12px;
    }

    .sales-stat-icon {
        width: 40px;
        height: 40px;
    }

    .sales-stat-icon svg {
        width: 20px;
        height: 20px;
    }

    .sales-stat-value {
        font-size: 20px;
    }

    .sales-performer-card {
        padding: 16px;
    }

    .sales-performer-header {
        gap: 12px;
    }

    .sales-performer-avatar {
        width: 44px;
        height: 44px;
        font-size: 16px;
    }

    .sales-performer-name {
        font-size: 15px;
    }

    .sales-performer-stat-value {
        font-size: 16px;
    }

    .sales-performer-stat-label {
        font-size: 9px;
    }

    /* Table scroll container */
    .sales-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -16px;
        padding: 0 16px;
    }

    .sales-table {
        min-width: 700px;
    }

    .sales-chart-container {
        height: 220px;
    }

    .crm-import-section {
        flex-direction: column;
        text-align: center;
        padding: 16px;
    }

    .crm-import-btn {
        width: 100%;
        justify-content: center;
    }

    .date-range-badge {
        display: block;
        margin-left: 0;
        margin-top: 8px;
    }
}

@media (max-width: 480px) {
    .sales-stat-card-inner {
        flex-direction: column;
        text-align: center;
    }

    .sales-stat-value {
        font-size: 18px;
    }

    .sales-stat-label {
        font-size: 10px;
    }

    .sales-performer-header {
        flex-direction: column;
        text-align: center;
    }

    .sales-performer-stats {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .sales-performer-stat {
        padding: 8px;
        background: rgba(255, 255, 255, 0.1);
        border-radius: 8px;
    }

    .kpi-badge {
        padding: 3px 6px;
        font-size: 10px;
    }

    .score-bar {
        width: 40px;
    }

    .sales-deal-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .sales-deal-amount {
        padding-left: 0;
    }

    .sales-summary-row {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
}
