/* HCPLY Global Dashboard v2 - Data-Driven Styles */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-hover: #3b4a63;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #10b981;
    --accent-hover: #059669;
    --accent-light: rgba(16, 185, 129, 0.1);
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.1);
    --danger: #f87171;
    --info: #3b82f6;
    --border: #334155;
    --border-light: #475569;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--accent-hover); }

/* Header */
.header {
    background: linear-gradient(180deg, var(--bg-secondary) 0%, rgba(30, 41, 59, 0.95) 100%);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(8px);
}

.header-content {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 18px;
    text-decoration: none;
}

.logo:hover { color: var(--text-primary); }

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent) 0%, #059669 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

/* Search Box in Header */
.header-search {
    flex: 1;
    max-width: 500px;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 10px 16px 10px 44px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
}

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.search-input::placeholder { color: var(--text-muted); }

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 16px;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-top: 4px;
    max-height: 400px;
    overflow-y: auto;
    display: none;
    box-shadow: var(--shadow);
    z-index: 1000;
}

.search-results.show { display: block; }

.search-result-item {
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
}

.search-result-item:hover { background: var(--bg-hover); }
.search-result-item:last-child { border-bottom: none; }

.search-result-type {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.search-result-type.supplier { background: var(--warning-light); color: var(--warning); }
.search-result-type.company { background: var(--accent-light); color: var(--accent); }

/* Navigation */
.nav {
    display: flex;
    gap: 4px;
}

.nav-link {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    text-decoration: none;
}

.nav-link:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--accent);
    color: white;
}

/* Breadcrumb */
.breadcrumb {
    padding: 12px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.breadcrumb-inner {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
}

.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .current { color: var(--text-primary); font-weight: 500; }

/* Main Container */
.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 24px;
}

/* Page Header */
.page-header {
    margin-bottom: 24px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.page-header-main { flex: 1; }

.page-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.badge-vip { background: var(--warning-light); color: var(--warning); }
.badge-email { background: var(--accent-light); color: var(--accent); }
.badge-region { background: var(--bg-tertiary); color: var(--text-secondary); }

.product-badge {
    padding: 3px 8px;
    font-size: 11px;
    border-radius: 4px;
    font-weight: 500;
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    transition: all 0.2s;
}

.stat-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.2;
}

.stat-value.warning { color: var(--warning); }
.stat-value.info { color: var(--info); }

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Cards */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
    transition: border-color 0.2s;
}

.card:hover { border-color: var(--border-light); }

.card-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.1);
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title.warning { color: var(--warning); }

.card-actions {
    display: flex;
    gap: 8px;
}

.card-body {
    padding: 16px 20px;
}

.card-body.no-padding { padding: 0; }

/* Info Box */
.info-box {
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 16px;
}

.info-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 14px;
}

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

.info-icon {
    color: var(--text-muted);
    width: 20px;
    flex-shrink: 0;
}

.info-label {
    color: var(--text-muted);
    min-width: 80px;
}

.info-value {
    color: var(--text-primary);
    word-break: break-word;
}

.info-value.copyable {
    cursor: pointer;
    padding: 2px 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    transition: all 0.2s;
}

.info-value.copyable:hover {
    background: var(--accent-light);
    color: var(--accent);
}

.info-value.copied {
    background: var(--accent);
    color: white;
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th {
    text-align: left;
    padding: 12px 16px;
    background: var(--bg-primary);
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
}

th.right { text-align: right; }
th.center { text-align: center; }

th.sortable {
    cursor: pointer;
    user-select: none;
}

th.sortable:hover { color: var(--accent); }
th.sortable.asc::after { content: ' ↑'; }
th.sortable.desc::after { content: ' ↓'; }

td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(51, 65, 85, 0.5);
    color: var(--text-secondary);
    vertical-align: top;
}

td.right { text-align: right; }
td.center { text-align: center; }

tr:hover td { background: rgba(16, 185, 129, 0.03); }

td.product-cell {
    max-width: 400px;
}

.product-full {
    color: var(--text-primary);
    line-height: 1.5;
}

.supplier-link {
    color: var(--warning);
    font-weight: 500;
}

.supplier-link:hover { text-decoration: underline; }

.value { color: var(--accent); font-weight: 600; }
.value-large { font-size: 15px; }

/* List Items */
.list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    transition: all 0.2s;
    cursor: pointer;
}

.list-item:hover {
    background: var(--accent-light);
    transform: translateX(4px);
}

.list-item:last-child { margin-bottom: 0; }

.list-item-rank {
    width: 32px;
    height: 32px;
    background: var(--bg-tertiary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    flex-shrink: 0;
}

.list-item-rank.top-3 {
    background: linear-gradient(135deg, var(--warning) 0%, #d97706 100%);
    color: white;
}

.list-item-flag {
    font-size: 24px;
    flex-shrink: 0;
}

.list-item-info {
    flex: 1;
    min-width: 0;
}

.list-item-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.list-item-name a { color: inherit; }
.list-item-name a:hover { color: var(--accent); }

.list-item-detail {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.list-item-stats {
    text-align: right;
    flex-shrink: 0;
}

.list-item-value {
    font-size: 15px;
    font-weight: 600;
    color: var(--accent);
}

.list-item-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Region Cards */
.regions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.region-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: all 0.2s;
    display: block;
    color: inherit;
    text-decoration: none;
}

.region-card:hover {
    border-color: var(--accent);
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.region-card-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

.region-card-icon {
    font-size: 36px;
    line-height: 1;
}

.region-card-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.region-card-stats {
    display: flex;
    justify-content: space-between;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.region-card-stat { text-align: center; }
.region-card-value { font-size: 18px; font-weight: 700; color: var(--accent); }
.region-card-label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Filters */
.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-label {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
}

.filter-select,
.filter-input {
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    min-width: 150px;
}

.filter-select:focus,
.filter-input:focus {
    border-color: var(--accent);
}

.filter-btn {
    padding: 8px 16px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn:hover { background: var(--accent-hover); }

.filter-btn.secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.filter-btn.secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
}

.page-btn {
    padding: 8px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.page-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.page-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Loading */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

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

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* Footer */
.footer {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 13px;
    border-top: 1px solid var(--border);
    margin-top: 48px;
}

/* Responsive */
@media (max-width: 1024px) {
    .header-content {
        flex-wrap: wrap;
    }
    .header-search {
        order: 3;
        max-width: 100%;
        width: 100%;
        margin-top: 12px;
    }
}

@media (max-width: 768px) {
    .container { padding: 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .regions-grid { grid-template-columns: 1fr; }
    .page-title { font-size: 22px; }
    .filters-bar { flex-direction: column; }
    .filter-group { width: 100%; }
    .filter-select, .filter-input { flex: 1; }
}

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-warning { color: var(--warning); }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.hidden { display: none !important; }

/* Two column layout */
.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 1024px) {
    .two-col { grid-template-columns: 1fr; }
}
