/* ============================================
   ENHANCED DASHBOARD STYLES V2
   ============================================ */

:root {
    --primary-color: #1f77b4;
    --secondary-color: #2ca02c;
    --danger-color: #d62728;
    --warning-color: #ff7f0e;
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --text-dark: #2c3e50;
    --text-light: #7f8c8d;
    --border-color: #e1e8ed;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-hover: 0 4px 16px rgba(0,0,0,0.15);
    --success-color: #27ae60;
    --live-color: #e74c3c;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-dark);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ============================================
   HEADER
   ============================================ */

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px 0;
    box-shadow: var(--shadow);
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 8px;
    text-align: center;
}

.subtitle {
    text-align: center;
    font-size: 1.1rem;
    opacity: 0.95;
}

/* ============================================
   NAVIGATION TABS
   ============================================ */

.tabs-container {
    background: white;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 2px solid var(--border-color);
}

.tabs {
    display: flex;
    gap: 10px;
    padding: 15px 0;
    overflow-x: auto;
}

.tab-btn {
    padding: 12px 24px;
    background: transparent;
    border: 2px solid transparent;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.tab-btn:hover {
    background: var(--bg-color);
    border-color: var(--primary-color);
}

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

/* ============================================
   MAIN CONTENT
   ============================================ */

.main-content {
    padding: 30px 0;
}

.company-selector {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.company-selector label {
    font-weight: 600;
    font-size: 1.1rem;
}

.dropdown {
    padding: 10px 15px;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: white;
    cursor: pointer;
    min-width: 250px;
    transition: border-color 0.3s;
}

.dropdown:hover {
    border-color: var(--primary-color);
}

.dropdown:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(31, 119, 180, 0.1);
}

/* ============================================
   CONTENT GRID
   ============================================ */

.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

.left-column, .right-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ============================================
   CARDS
   ============================================ */

.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 25px;
    box-shadow: var(--shadow);
    transition: box-shadow 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-hover);
}

.card-title {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: var(--primary-color);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
}

/* ============================================
   METRICS GRID - ENHANCED
   ============================================ */

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.metric-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

/* Live Price Card - Special Styling */
.live-price-card {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    50% {
        box-shadow: 0 4px 20px rgba(231, 76, 60, 0.4);
    }
}

.live-indicator {
    display: inline-block;
    font-size: 0.75rem;
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    margin-left: 8px;
    animation: blink 1.5s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.metric-label {
    font-size: 0.9rem;
    opacity: 0.9;
    margin-bottom: 8px;
}

.metric-value {
    font-size: 1.8rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.metric-change {
    font-size: 0.9rem;
    font-weight: 600;
}

.metric-change.positive {
    color: #2ecc71;
}

.metric-change.negative {
    color: #ffcccb;
}

/* Data Quality Badge */
.data-quality-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.2);
}

.data-quality-badge.high {
    background: rgba(46, 204, 113, 0.3);
}

.data-quality-badge.medium {
    background: rgba(255, 193, 7, 0.3);
}

.data-quality-badge.low {
    background: rgba(231, 76, 60, 0.3);
}

/* ============================================
   NEWS ITEMS
   ============================================ */

.news-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-height: 500px;
    overflow-y: auto;
}

.news-item {
    padding: 15px;
    background: var(--bg-color);
    border-left: 4px solid var(--primary-color);
    border-radius: 6px;
    transition: all 0.3s ease;
}

.news-item:hover {
    transform: translateX(5px);
    background: #e8f4ff;
    box-shadow: var(--shadow);
}

.news-title {
    font-weight: 600;
    font-size: 1.05rem;
    margin-bottom: 8px;
    color: var(--text-dark);
}

.news-meta {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 10px;
}

.news-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: color 0.3s;
}

.news-link:hover {
    text-decoration: underline;
    color: #0d5a9e;
}

/* ============================================
   DOCUMENTS
   ============================================ */

.docs-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 500px;
    overflow-y: auto;
}

.doc-item {
    padding: 15px;
    background: linear-gradient(135deg, #e7f3ff 0%, #f0f8ff 100%);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s;
}

.doc-item:hover {
    background: linear-gradient(135deg, #d4e8ff 0%, #e3f2ff 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.doc-info {
    flex: 1;
}

.doc-title {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 5px;
}

.doc-meta {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.doc-type {
    font-size: 0.8rem;
    background: white;
    color: var(--primary-color);
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 500;
}

.doc-date {
    font-size: 0.8rem;
    color: var(--text-light);
}

.doc-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    padding: 8px 16px;
    background: white;
    border-radius: 6px;
    transition: all 0.3s;
}

.doc-link:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.05);
}

/* ============================================
   CHARTS
   ============================================ */

#performanceChart, #marginChart {
    min-height: 300px;
    border-radius: 8px;
}

/* ============================================
   NEWS TICKER
   ============================================ */

.ticker-card {
    height: 300px;
    overflow: hidden;
}

.news-ticker {
    height: 250px;
    overflow: hidden;
    position: relative;
}

.ticker-content {
    animation: scroll 30s linear infinite;
}

.ticker-content:hover {
    animation-play-state: paused;
}

@keyframes scroll {
    0% { transform: translateY(0); }
    100% { transform: translateY(-50%); }
}

.ticker-item {
    padding: 12px;
    margin-bottom: 10px;
    background: var(--bg-color);
    border-left: 3px solid var(--danger-color);
    border-radius: 4px;
    transition: background 0.3s;
}

.ticker-item:hover {
    background: #ffe8e8;
}

.ticker-item strong {
    display: block;
    margin-bottom: 5px;
    color: var(--text-dark);
}

.ticker-item small {
    display: inline-block;
    margin-right: 10px;
    color: var(--text-light);
}

/* ============================================
   LOADING & ERROR STATES
   ============================================ */

.loading {
    text-align: center;
    color: var(--text-light);
    padding: 40px 20px;
    font-style: italic;
    font-size: 1.1rem;
}

.error {
    text-align: center;
    color: var(--danger-color);
    padding: 40px 20px;
    font-size: 1.1rem;
    background: #ffe8e8;
    border-radius: 8px;
    border: 2px solid var(--danger-color);
}

/* Loading Spinner */
.loading::before {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
    vertical-align: middle;
}

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

/* ============================================
   SCROLLBAR STYLING
   ============================================ */

.news-list::-webkit-scrollbar,
.docs-list::-webkit-scrollbar {
    width: 8px;
}

.news-list::-webkit-scrollbar-track,
.docs-list::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: 4px;
}

.news-list::-webkit-scrollbar-thumb,
.docs-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.news-list::-webkit-scrollbar-thumb:hover,
.docs-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

/* ============================================
   FOOTER
   ============================================ */

.footer {
    background: var(--text-dark);
    color: white;
    padding: 30px 0;
    margin-top: 50px;
    text-align: center;
}

.footer p {
    margin: 8px 0;
}

.footer small {
    opacity: 0.8;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 968px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .metrics-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .header h1 {
        font-size: 1.5rem;
    }
    
    .subtitle {
        font-size: 0.9rem;
    }
    
    .tab-btn {
        padding: 10px 16px;
        font-size: 0.9rem;
    }
    
    .company-selector {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .dropdown {
        width: 100%;
    }
    
    .metric-value {
        font-size: 1.4rem;
    }
}
