/*
===================================
M&A News Hub - Stylesheet
===================================

BEGINNER EXPLANATION:
CSS (Cascading Style Sheets) controls how your website LOOKS.
- Colors, fonts, spacing, layouts - everything visual!
- Each "rule" targets HTML elements and applies styles to them
*/

/* ===== GLOBAL STYLES ===== */
/* These apply to the entire website */

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

:root {
    /* CSS Variables - Dark Blue Professional Theme */
    --primary-color: #1e3a8a;
    --primary-dark: #1e40af;
    --secondary-color: #312e81;
    --success-color: #1e40af;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.2;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: 8px; /* Super tiny - 50% smaller */
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 15px;
    width: 100%;
}

/* ===== HEADER ===== */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1rem 0;
    box-shadow: var(--shadow-md);
}

.header-content {
    text-align: center;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.logo i {
    font-size: 2.5rem;
}

.logo h1 {
    font-size: 2rem;
    font-weight: 700;
}

.tagline {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 300;
}

/* ===== NAVIGATION ===== */
.main-nav {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

.nav-link {
    color: white;
    text-decoration: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    transition: var(--transition);
    background-color: rgba(255, 255, 255, 0.1);
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.nav-link.active {
    background-color: rgba(255, 255, 255, 0.25);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    padding: 1rem 0;
}

/* ===== CONTROL PANEL ===== */
.control-panel {
    background: var(--card-bg);
    padding: 1rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.controls-left {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

/* ===== BUTTONS ===== */
.btn {
    padding: 0.4rem 0.85rem;
    border: none;
    border-radius: 5px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: var(--transition);
    font-family: inherit;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

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

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: #475569;
}

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

/* ===== SEARCH BOX ===== */
.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box i {
    display: none;
}

.search-box input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.85rem;
    width: 250px;
    transition: var(--transition);
    font-family: inherit;
    position: relative;
    z-index: 1;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ===== STATS ===== */
.stats {
    display: flex;
    gap: 2rem;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.stat-value {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* ===== STATUS MESSAGE ===== */
.status-message {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    animation: slideDown 0.3s ease;
}

.status-message.success {
    background-color: #d1fae5;
    color: #065f46;
    border-left: 4px solid var(--success-color);
}

.status-message.error {
    background-color: #fee2e2;
    color: #991b1b;
    border-left: 4px solid var(--danger-color);
}

.status-message.hidden {
    display: none;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== NEWS SECTION ===== */
.news-section {
    background: var(--card-bg);
    padding: 0.4rem;
    border-radius: 5px;
    box-shadow: var(--shadow-sm);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.35rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border-color);
}

.section-header h2 {
    font-size: 0.75rem;
    color: var(--text-primary);
}

/* ===== LOADING SPINNER ===== */
.loading-spinner {
    text-align: center;
    padding: 3rem;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

.loading-spinner.hidden {
    display: none;
}

/* ===== NEWS GRID ===== */
.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

/* ===== NEWS CARD ===== */
.news-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1.5rem;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    position: relative;
    overflow: hidden;
}

.news-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.news-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
    border-color: #667eea;
}

.news-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.news-source {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: 0.5px;
}

.news-source i {
    font-size: 0.75rem;
}

.news-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 0.75rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.news-description {
    color: #6b7280;
    margin-bottom: 1rem;
    flex-grow: 1;
    font-size: 0.9rem;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.news-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid #f3f4f6;
    margin-top: auto;
}

.news-date {
    color: #9ca3af;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.news-link {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.8rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.news-link:hover {
    transform: translateX(2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 2.5rem 1.5rem;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1rem;
    margin-bottom: 0.4rem;
    color: var(--text-primary);
}

.empty-state.hidden {
    display: none;
}

/* ===== FOOTER ===== */
.footer {
    background-color: var(--text-primary);
    color: white;
    text-align: center;
    padding: 2rem 0;
    margin-top: auto;
}

.footer p {
    margin: 0.5rem 0;
    opacity: 0.9;
}

.footer-note {
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* ===== PORTFOLIO TABLE ===== */
.portfolio-table-wrapper {
    overflow-x: visible;
    overflow-y: visible;
    margin-top: 1rem;
    width: 100%;
    position: relative;
    display: block;
}

/* Firm Section Grouping */
.firm-section {
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow-x: auto;
    overflow-y: visible;
    background: var(--card-bg);
    box-shadow: var(--shadow-sm);
    -webkit-overflow-scrolling: touch;
    width: 100%;
    display: block;
    position: relative;
}



.firm-section .firm-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    width: 100%;
    min-width: 3000px;
    position: relative;
    overflow: visible;
}

.firm-section .firm-header::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    z-index: -1;
    width: 100%;
    min-width: 3000px;
    transform: translateX(0);
}

.firm-header {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: white;
    padding: 0.65rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-width: 100%;
    width: 100%;
    position: relative;
}

.firm-header::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    z-index: -1;
    width: 100%;
    min-width: 3000px;
    transform: translateX(0);
}

.firm-header-link {
    text-decoration: none;
    color: white;
    flex: 1;
    transition: var(--transition);
}

.firm-header-link:hover {
    opacity: 0.9;
}

.firm-header-link:hover i.fa-external-link-alt {
    opacity: 1 !important;
}

.firm-header h3 {
    margin: 0;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.firm-header i {
    font-size: 0.85rem;
}

/* PE Firm Logo */
.firm-logo {
    height: 40px;
    width: auto;
    max-width: 150px;
    object-fit: contain;
    background: white;
    padding: 0.5rem;
    border-radius: 8px;
    filter: brightness(1.1);
}

.firm-icon-fallback {
    font-size: 1.75rem;
}

.firm-count {
    background-color: rgba(255, 255, 255, 0.2);
    padding: 0.3rem 0.6rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.7rem;
}

.portfolio-table {
    width: 100%;
    min-width: max-content;
    border-collapse: collapse;
    background: var(--card-bg);
    white-space: nowrap;
    table-layout: auto;
}

.portfolio-table thead {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: white;
}

.portfolio-table th {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: white;
    padding: 0.35rem 0.45rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

/* Column-specific widths */
.portfolio-table th:nth-child(1) { min-width: 140px; } /* Company */
.portfolio-table th:nth-child(2) { min-width: 110px; } /* Sector */
.portfolio-table th:nth-child(3) { min-width: 90px; } /* Fund */
.portfolio-table th:nth-child(4) { min-width: 80px; } /* Market */
.portfolio-table th:nth-child(5) { min-width: 100px; } /* Headquarters */
.portfolio-table th:nth-child(6) { min-width: 70px; }  /* Entry Year */
.portfolio-table th:nth-child(7) { min-width: 85px; } /* Holding Period */
.portfolio-table th:nth-child(8) { min-width: 70px; }  /* Status */
.portfolio-table th:nth-child(9) { min-width: 90px; } /* Deal Size */
.portfolio-table th:nth-child(10) { min-width: 85px; } /* Geography */
.portfolio-table th:nth-child(11) { min-width: 250px; } /* Description */
.portfolio-table th:nth-child(12) { min-width: 60px; }  /* Website */

.portfolio-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
    animation: fadeInUp 0.3s ease forwards;
    opacity: 0;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.portfolio-table tbody tr:hover {
    background-color: var(--bg-color);
    transform: scale(1.01);
}

.portfolio-table tbody tr.has-description {
    cursor: pointer;
}

.portfolio-table tbody tr.has-description:hover {
    background-color: #e3f2fd;
}

.portfolio-table td {
    padding: 0.35rem 0.45rem;
    font-size: 0.65rem;
    vertical-align: middle;
}

.company-name {
    font-weight: 600;
    color: var(--text-primary);
}

.company-name i {
    color: var(--primary-color);
}

.company-link {
    color: var(--primary-color);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
    font-weight: 600;
}

.company-link:hover {
    color: var(--primary-dark);
    transform: translateX(3px);
}

.company-link .external-icon {
    font-size: 0.75rem;
    opacity: 0.6;
}

.company-link:hover .external-icon {
    opacity: 1;
}

/* Company Logo */
.company-logo {
    height: 24px;
    width: 24px;
    object-fit: contain;
    border-radius: 4px;
    margin-right: 0.5rem;
    vertical-align: middle;
}

.company-icon-fallback {
    margin-right: 0.5rem;
}

.fund-badge {
    background-color: var(--primary-color);
    color: white;
    padding: 0.15rem 0.4rem;
    border-radius: 12px;
    font-size: 0.5rem;
    font-weight: 600;
    display: inline-block;
}

/* ===== RESPONSIVE DESIGN ===== */
/* Makes the website look good on phones and tablets */

@media (max-width: 768px) {
    .logo h1 {
        font-size: 1.75rem;
    }
    
    .control-panel {
        flex-direction: column;
        align-items: stretch;
    }
    
    .controls-left {
        flex-direction: column;
    }
    
    .search-box input {
        width: 100%;
    }
    
    .stats {
        justify-content: center;
    }
    
    .section-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .news-grid {
        grid-template-columns: 1fr;
    }
    
    /* Portfolio Charts Mobile Responsive */
    .portfolio-stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
    
    /* Make charts stack vertically on mobile */
    div[style*="grid-template-columns: 1fr 1fr 1fr"] {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
        margin-bottom: 1rem !important;
    }
    
    /* Increase chart height on mobile */
    canvas[id*="Chart"] {
        max-height: 200px !important;
        min-height: 180px !important;
    }
    
    /* Make chart titles more readable on mobile */
    .content-card-title {
        font-size: 0.8rem !important;
    }
}

@media (max-width: 480px) {
    .logo {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .logo h1 {
        font-size: 1.5rem;
    }
    
    /* Extra small mobile optimizations for portfolio charts */
    .portfolio-stats-grid {
        grid-template-columns: 1fr;
        gap: 0.3rem;
    }
    
    /* Make charts even taller on very small screens */
    canvas[id*="Chart"] {
        max-height: 250px !important;
        min-height: 220px !important;
    }
    
    /* Larger chart titles on small phones */
    .content-card-title {
        font-size: 0.9rem !important;
    }
    
    /* Better spacing for chart cards on small screens */
    div[style*="grid-template-columns: 1fr 1fr 1fr"] {
        gap: 1.5rem !important;
        margin-bottom: 1.5rem !important;
    }
}

