/**
 * Partners CRM Module Styles
 */

/* Partners Toolbar & Filters */
.partners-filters {
    padding: 1rem;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.filter-row {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

.filter-row:last-child {
    margin-bottom: 0;
}

.view-toggle {
    display: flex;
    gap: 0.25rem;
}

/* Tag Filters */
.tag-filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: opacity 0.2s;
}

.tag-chip:hover {
    opacity: 0.9;
}

.tag-chip.active {
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.2);
}

/* Partners Grid (Tiles) */
.partners-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    padding: 1.5rem;
}

.partner-card {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.partner-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.partner-card-header h3 {
    margin: 0;
    font-size: 1.125rem;
    color: #111827;
}

.partner-card-body {
    padding: 1rem 0;
}

.partner-card-body p {
    margin: 0.5rem 0;
    font-size: 0.875rem;
    color: #6b7280;
}

.partner-primary-contact {
    font-weight: 500;
    color: #374151;
}

.partner-location {
    color: #6b7280;
}

.partner-last-comm {
    font-size: 0.875rem;
}

.last-comm-recent {
    color: #10b981;
}

.last-comm-aging {
    color: #f59e0b;
}

.last-comm-stale {
    color: #ef4444;
}

.partner-card-footer {
    display: flex;
    gap: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid #e5e7eb;
}

/* Partners List */
.partners-list {
    padding: 1.5rem;
}

/* Partner Detail */
.partner-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1.5rem;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
}

.header-left {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.header-info h1 {
    margin: 0;
    font-size: 1.875rem;
    color: #111827;
}

.partner-meta {
    margin: 0.5rem 0 0 0;
    font-size: 1rem;
    color: #6b7280;
}

.header-right {
    display: flex;
    gap: 0.5rem;
}

/* Tabs */
.mts-tabs {
    display: flex;
    gap: 0;
    padding: 0 1.5rem;
    background: #fff;
    border-bottom: 2px solid #e5e7eb;
}

.mts-tab {
    padding: 1rem 1.5rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-size: 1rem;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}

.mts-tab:hover {
    color: #111827;
}

.mts-tab.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
}

/* Partner Detail Grid */
.partner-detail-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 1.5rem;
    padding: 1.5rem;
}

.partner-detail-main {
    min-width: 0; /* Prevent overflow */
}

.partner-detail-sidebar {
    position: sticky;
    top: 1.5rem;
    align-self: start;
}

/* Overview Tab */
.partner-overview {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.info-item label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 0.25rem;
}

.info-item p {
    margin: 0;
    color: #111827;
}

.tag-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* KPI Sidebar */
.kpi-sidebar .mts-card {
    margin-bottom: 0;
}

.kpi-item {
    display: flex;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid #e5e7eb;
}

.kpi-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.kpi-icon {
    font-size: 1.5rem;
}

.kpi-content {
    flex: 1;
}

.kpi-label {
    font-size: 0.875rem;
    color: #6b7280;
    margin-bottom: 0.25rem;
}

.kpi-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: #111827;
}

/* Visits Timeline */
.visits-timeline {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.visit-item {
    padding: 1rem;
    background: #f9fafb;
    border-radius: 0.5rem;
    border-left: 3px solid #2563eb;
}

.visit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.visit-type {
    font-weight: 600;
    color: #374151;
    text-transform: capitalize;
}

.visit-date {
    font-size: 0.875rem;
    color: #6b7280;
}

.visit-summary {
    color: #111827;
    margin-bottom: 0.5rem;
    white-space: pre-wrap;
}

.visit-footer {
    font-size: 0.875rem;
    color: #6b7280;
}

/* Tag Selector */
.tag-selector {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.tag-chips-selected {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    min-height: 2rem;
    padding: 0.5rem;
    background: #f9fafb;
    border-radius: 0.375rem;
    border: 1px solid #e5e7eb;
}

.tag-selector-input {
    position: relative;
}

.tag-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-top: none;
    border-radius: 0 0 0.375rem 0.375rem;
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.tag-suggestion {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.tag-suggestion:hover {
    background-color: #f3f4f6;
}

.tag-chip-small {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
}

.tag-chips-available {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag-remove {
    margin-left: 0.5rem;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-weight: bold;
}

/* Form Styles */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    background: #f3f4f6;
    color: #374151;
}

.badge-primary {
    background: #dbeafe;
    color: #1e40af;
}

.badge-new {
    background: #dbeafe;
    color: #1e40af;
}

.badge-contacted {
    background: #e0e7ff;
    color: #4338ca;
}

.badge-qualified {
    background: #d1fae5;
    color: #065f46;
}

.badge-lost {
    background: #fee2e2;
    color: #991b1b;
}

.badge-won {
    background: #d1fae5;
    color: #065f46;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}

.empty-state h2 {
    margin: 0 0 0.5rem 0;
    font-size: 1.5rem;
    color: #111827;
}

.empty-state p {
    margin: 0 0 1.5rem 0;
    color: #6b7280;
}

/* Reports Dashboard */
.reports-dashboard {
    padding: 1.5rem;
}

.date-range-selector {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.report-kpis .kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.report-kpis .kpi-card .mts-card-body {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
}

.report-kpis .kpi-icon {
    font-size: 2rem;
}

.report-kpis .kpi-content {
    flex: 1;
}

.report-kpis .kpi-label {
    font-size: 0.875rem;
    color: #6b7280;
    margin-bottom: 0.25rem;
}

.report-kpis .kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #111827;
}

.report-kpis .kpi-sublabel {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 0.25rem;
}

/* Communications Timeline */
.communications-timeline {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.timeline-filters {
    padding: 1rem;
    background: #f9fafb;
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.timeline-item {
    padding: 1rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-left: 3px solid #3b82f6;
    border-radius: 0.375rem;
    transition: box-shadow 0.2s;
}

.timeline-item:hover {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.timeline-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.timeline-item-type {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: #374151;
}

.timeline-item-date {
    font-size: 0.875rem;
    color: #6b7280;
}

.timeline-item-content {
    color: #111827;
    margin-bottom: 0.5rem;
    white-space: pre-wrap;
}

.timeline-item-meta {
    font-size: 0.875rem;
    color: #6b7280;
}

.timeline-type-visit {
    border-left-color: #3b82f6;
}

.timeline-type-lead {
    border-left-color: #10b981;
}

.timeline-type-note {
    border-left-color: #f59e0b;
}

.timeline-empty {
    text-align: center;
    padding: 3rem;
    color: #6b7280;
}

/* Responsive */
@media (max-width: 1024px) {
    .partner-detail-grid {
        grid-template-columns: 1fr;
    }

    .partner-detail-sidebar {
        position: static;
    }

    .report-kpis .kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
}

@media (max-width: 768px) {
    .partners-grid {
        grid-template-columns: 1fr;
    }

    .filter-row {
        flex-direction: column;
        align-items: stretch;
    }

    .partner-detail-header {
        flex-direction: column;
        gap: 1rem;
    }

    .header-right {
        align-self: stretch;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    .date-range-selector > div {
        flex-direction: column;
    }

    .timeline-filters {
        flex-direction: column;
    }
}

/* Partner KPI Cards - Use semantic tokens for theme colors */
.partner-kpi-card {
    background: var(--gradient-primary);
    color: var(--btn-primary-text);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 10px 25px var(--card-accent);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

.partner-kpi-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px var(--card-accent-strong);
}

.partner-kpi-card:focus-visible {
    outline: 2px solid var(--focus-ring-color);
    outline-offset: 2px;
    box-shadow: 0 0 0 3px var(--focus-ring);
}

/* ===== PARTNERS MAP VIEW ===== */

/* Fix Leaflet divIcon default styling */
.partner-map-marker {
    background: transparent !important;
    border: none !important;
}

/* Map container */
#partners-map {
    width: 100%;
    height: 100%;
    min-height: 400px;
    background: #f3f4f6;
}

/* Leaflet popup styling */
.leaflet-popup-content-wrapper {
    border-radius: 12px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

.leaflet-popup-content {
    margin: 0 !important;
    padding: 0 !important;
}

.leaflet-popup-tip {
    background: white !important;
}
