/* Competitor Intelligence Tracker - Main Styles */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --dark: #1e293b;
    --light: #f8fafc;
    --border: #e2e8f0;
    --bg-card: #ffffff;
    --text: #334155;
    --text-muted: #94a3b8;
    --sidebar-width: 240px;
    --header-height: 56px;
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f1f5f9;
    color: var(--text);
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* Layout */
#app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

#app-header {
    background: var(--dark);
    color: white;
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 1030;
    gap: 16px;
}

#app-header .brand {
    font-weight: 700;
    font-size: 18px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
}

#app-header .brand i { color: var(--primary); }

#global-search {
    flex: 1;
    max-width: 400px;
    position: relative;
}

#global-search input {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    color: white;
    border-radius: 6px;
    padding: 6px 12px 6px 34px;
    width: 100%;
    font-size: 14px;
    transition: background 0.2s;
}

#global-search input::placeholder { color: rgba(255,255,255,0.5); }
#global-search input:focus { background: rgba(255,255,255,0.15); outline: none; border-color: var(--primary); }
#global-search .search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: rgba(255,255,255,0.5); }

#search-results-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: none;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1050;
}

#search-results-dropdown.show { display: block; }
#search-results-dropdown .search-item {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    color: var(--text);
    font-size: 14px;
}
#search-results-dropdown .search-item:hover { background: #f0f4ff; }
#search-results-dropdown .search-type-badge {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.alert-badge {
    position: relative;
    cursor: pointer;
    font-size: 20px;
}

.alert-badge .badge {
    position: absolute;
    top: -6px;
    right: -8px;
    font-size: 10px;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    padding: 0 4px;
}

/* Navigation Tabs */
#main-nav {
    background: white;
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
}

#main-nav .nav-tabs {
    border-bottom: none;
    flex-wrap: nowrap;
    gap: 2px;
}

#main-nav .nav-link {
    color: var(--secondary);
    border: none;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    transition: all 0.2s;
}

#main-nav .nav-link:hover {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: none;
}

#main-nav .nav-link.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: none;
    font-weight: 600;
}

#main-nav .nav-link i { margin-right: 4px; }

/* Main Content Area */
#main-content {
    flex: 1;
    padding: 20px;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

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

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body { padding: 16px; }

/* KPI Cards */
.kpi-card {
    border-left: 3px solid var(--primary);
    padding: 16px;
    border-radius: 8px;
    background: white;
    border: 1px solid var(--border);
    transition: transform 0.2s;
}

.kpi-card:hover { transform: translateY(-2px); }
.kpi-card .kpi-value { font-size: 28px; font-weight: 700; color: var(--dark); }
.kpi-card .kpi-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.kpi-card.border-success { border-left-color: var(--success); }
.kpi-card.border-warning { border-left-color: var(--warning); }
.kpi-card.border-danger { border-left-color: var(--danger); }
.kpi-card.border-info { border-left-color: var(--info); }

/* Threat Level Stars */
.threat-stars { display: inline-flex; gap: 2px; }
.threat-stars .bi-star-fill { color: var(--warning); font-size: 14px; }
.threat-stars .bi-star { color: #ddd; font-size: 14px; }

.threat-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.threat-1 { background: #dcfce7; color: #166534; }
.threat-2 { background: #fef9c3; color: #854d0e; }
.threat-3 { background: #fed7aa; color: #9a3412; }
.threat-4 { background: #fecaca; color: #991b1b; }
.threat-5 { background: #fee2e2; color: #7f1d1d; border: 1px solid #fca5a5; }

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.status-active { background: #dcfce7; color: #166534; }
.status-inactive { background: #f1f5f9; color: #475569; }
.status-acquired { background: #e0e7ff; color: #3730a3; }

.severity-badge { padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.severity-info { background: #e0f2fe; color: #0369a1; }
.severity-warning { background: #fef3c7; color: #92400e; }
.severity-critical { background: #fee2e2; color: #991b1b; }
.severity-minor { background: #f1f5f9; color: #475569; }
.severity-moderate { background: #fef3c7; color: #92400e; }
.severity-major { background: #fee2e2; color: #991b1b; }

/* Health Score Bar */
.health-bar {
    width: 60px;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    display: inline-block;
    vertical-align: middle;
}

.health-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}

.health-good .health-bar-fill { background: var(--success); }
.health-ok .health-bar-fill { background: var(--warning); }
.health-poor .health-bar-fill { background: var(--danger); }

/* Table styles */
.table { font-size: 14px; }
.table th { font-weight: 600; color: var(--secondary); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.table td { vertical-align: middle; }
.table-hover tbody tr:hover { background: #f0f4ff; }

.clickable-row { cursor: pointer; }
.clickable-row:hover td { color: var(--primary); }

/* DataTables override */
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px 10px;
}

.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--border);
    border-radius: 6px;
}

/* Activity Feed */
.activity-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

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

.activity-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.activity-icon.website_change { background: #dbeafe; color: #2563eb; }
.activity-icon.price_change { background: #fef3c7; color: #d97706; }
.activity-icon.company_added { background: #dcfce7; color: #16a34a; }
.activity-icon.company_updated { background: #e0e7ff; color: #4f46e5; }
.activity-icon.note_added { background: #f3e8ff; color: #7c3aed; }
.activity-icon.product_added { background: #cffafe; color: #0891b2; }
.activity-icon.social_added { background: #ffe4e6; color: #e11d48; }
.activity-icon.monitor_complete { background: #dcfce7; color: #16a34a; }

.activity-content { flex: 1; }
.activity-title { font-weight: 500; font-size: 14px; }
.activity-detail { font-size: 13px; color: var(--text-muted); }
.activity-time { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* Company Detail */
.company-header {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 20px;
}

.company-logo {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    background: var(--light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: var(--primary);
    flex-shrink: 0;
}

.company-logo img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }

.company-info h2 { margin: 0 0 4px 0; font-size: 22px; }
.company-meta { display: flex; gap: 16px; flex-wrap: wrap; }
.company-meta span { font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }

/* SWOT Grid */
.swot-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.swot-quadrant {
    border-radius: 8px;
    padding: 16px;
    min-height: 150px;
}

.swot-strengths { background: #dcfce7; border: 1px solid #bbf7d0; }
.swot-weaknesses { background: #fee2e2; border: 1px solid #fecaca; }
.swot-opportunities { background: #dbeafe; border: 1px solid #bfdbfe; }
.swot-threats { background: #fef3c7; border: 1px solid #fde68a; }

.swot-quadrant h5 { margin-bottom: 10px; font-size: 14px; font-weight: 700; }
.swot-item { font-size: 13px; padding: 4px 0; border-bottom: 1px solid rgba(0,0,0,0.05); }
.swot-item:last-child { border-bottom: none; }

/* Card Grid View */
.company-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.company-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.company-card:hover { border-color: var(--primary); box-shadow: 0 4px 12px rgba(37,99,235,0.1); }
.company-card .card-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.company-card .card-location { font-size: 13px; color: var(--text-muted); }

/* Buttons */
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

/* Custom Overlay (replaces confirm dialogs) */
.overlay-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.15s ease;
}

.overlay-dialog {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 440px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: slideUp 0.2s ease;
}

.overlay-dialog h5 { margin-bottom: 12px; }
.overlay-dialog p { color: var(--text-muted); font-size: 14px; }
.overlay-dialog .btn-row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.spin-icon { display: inline-block; animation: spin 1s linear infinite; }

/* Scan progress */
.scan-progress { margin: 10px 0; }
.scan-progress .progress-info { font-size: 0.85em; color: var(--text-muted); margin-top: 4px; }
.scan-progress .progress { height: 8px; border-radius: 4px; }

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty-state i { font-size: 48px; margin-bottom: 12px; display: block; }
.empty-state p { font-size: 14px; }

/* Loading Spinner */
.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

/* Tags */
.tag-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    background: #e0e7ff;
    color: #3730a3;
    margin: 1px 2px;
}

/* Site Status Indicator */
.site-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}
.site-status.up { background: var(--success); }
.site-status.redirect { background: var(--warning); }
.site-status.down { background: var(--danger); }
.site-status.unknown { background: #cbd5e1; }

/* Toast notifications */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9998;
}

.toast-item {
    background: var(--dark);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    margin-top: 8px;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    animation: slideUp 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast-item.success { border-left: 3px solid var(--success); }
.toast-item.error { border-left: 3px solid var(--danger); }
.toast-item.warning { border-left: 3px solid var(--warning); }

/* Responsive */
@media (max-width: 768px) {
    #main-content { padding: 12px; }
    .company-header { flex-direction: column; text-align: center; }
    .company-meta { justify-content: center; }
    .swot-grid { grid-template-columns: 1fr; }
    .company-grid { grid-template-columns: 1fr; }
    .kpi-card .kpi-value { font-size: 22px; }
    #app-header .brand span { display: none; }
    #global-search { max-width: 200px; }
    .header-actions { gap: 8px; }
}

@media (max-width: 576px) {
    #main-nav .nav-link { padding: 10px 10px; font-size: 12px; }
    #main-nav .nav-link span { display: none; }
    .overlay-dialog { width: 95%; }
}

/* Screenshot thumbnails */
.screenshot-thumb {
    width: 80px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.screenshot-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.screenshot-thumb-sm {
    width: 60px;
    height: 45px;
    object-fit: cover;
    border-radius: 3px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform 0.2s;
}

.screenshot-thumb-sm:hover {
    transform: scale(1.15);
}

.screenshot-placeholder {
    width: 80px;
    height: 60px;
    border-radius: 4px;
    border: 1px dashed var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 20px;
    background: var(--light);
}

.screenshot-placeholder-sm {
    width: 60px;
    height: 45px;
    border-radius: 3px;
    border: 1px dashed var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 16px;
    background: var(--light);
}

/* Screenshot lightbox */
.screenshot-lightbox {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.85);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.15s ease;
    cursor: pointer;
}

.screenshot-lightbox img {
    max-width: 95vw;
    max-height: 95vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.screenshot-lightbox-close {
    position: absolute;
    top: 16px;
    right: 24px;
    color: white;
    font-size: 32px;
    cursor: pointer;
    background: none;
    border: none;
    z-index: 10001;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.screenshot-lightbox-close:hover { opacity: 1; }

/* Before/After screenshot comparison */
.screenshot-compare {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--light);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.screenshot-compare-pane {
    flex: 1;
    text-align: center;
}

.screenshot-compare-pane .compare-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    color: var(--secondary);
}

.screenshot-compare-pane .compare-label.old { color: var(--danger); }
.screenshot-compare-pane .compare-label.new { color: var(--success); }

.screenshot-compare-pane img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: box-shadow 0.2s;
}

.screenshot-compare-pane img:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Screenshot timeline grid */
.screenshot-timeline {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    padding: 16px 0;
}

.screenshot-timeline-item {
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    background: white;
    transition: box-shadow 0.2s;
}

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

.screenshot-timeline-item img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    display: block;
    cursor: pointer;
}

.screenshot-timeline-item .timeline-meta {
    padding: 8px 10px;
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

.screenshot-timeline-item .timeline-meta .timeline-title {
    font-weight: 500;
    color: var(--text);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Responsive overrides for screenshots */
@media (max-width: 768px) {
    .screenshot-compare { flex-direction: column; }
    .screenshot-timeline { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

/* Print styles */
@media print {
    #app-header, #main-nav, .btn, .toast-container { display: none !important; }
    #main-content { padding: 0; max-width: none; }
    .card { break-inside: avoid; border: 1px solid #ccc; }
}
