/* Import Gilroy font with font-display: swap for better performance */
@import url('https://fonts.googleapis.com/css2?family=Gilroy:wght@400;700&display=swap');

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Gilroy', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f9f9f9;
}

/* Color variables */
:root {
    --primary: #00DBDB;
    --secondary: #37AEAE;
    --tertiary: #647D7D;
    --accent: #66FFFF;
}

/* Layout */
header {
    background: linear-gradient(135deg, #00DBDB 0%, #37AEAE 100%);
    color: white;
    padding: 1rem 2rem;
    box-shadow: 0 4px 20px rgba(0, 219, 219, 0.2);
    position: relative;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.header-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    padding: 0.5rem 1rem;
    border-radius: 10px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    width: fit-content;
    flex-shrink: 0;
}

.user-details {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-icon {
    font-size: 1rem;
    opacity: 0.9;
}

.user-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.user-text strong {
    font-size: 0.9rem;
    font-weight: 600;
}

.user-text small {
    font-size: 0.75rem;
    opacity: 0.8;
    font-weight: 400;
}

.btn-logout {
    background: linear-gradient(135deg, #18A8B3 0%, #16a0ab 100%);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 12px;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    box-shadow: 0 4px 15px rgba(24, 168, 179, 0.25);
    display: inline-block;
}

.btn-logout:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(24, 168, 179, 0.35);
    background: linear-gradient(135deg, #1bb5c1 0%, #18A8B3 100%);
    color: white;
    text-decoration: none;
}

.btn-logout:active {
    transform: translateY(-1px);
}

.btn-logout::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.6s ease;
}

.btn-logout:hover::before {
    left: 100%;
}

.header-logos {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-shrink: 0;
}

.header-logos .logo {
    height: 45px;
    width: auto;
    transition: transform 0.3s ease;
}

.header-logos .logo:hover {
    transform: scale(1.05);
}

header h1 {
    font-family: 'Gilroy', sans-serif;
    font-weight: 700;
    font-size: 1.6rem;
    color: rgb(255, 255, 255);
    margin: 0;
    letter-spacing: 1px;
    text-align: center;
}

nav {
    margin: 0;
    display: block;
}

nav ul {
    display: flex;
    list-style: none;
    gap: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50px;
    padding: 0.25rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    width: fit-content;
}

nav ul li {
    margin: 0;
}

nav ul li a {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 25px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    font-size: 1rem;
    position: relative;
    display: block;
    white-space: nowrap;
}

nav ul li a:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

nav ul li a.active {
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* Remove duplicate logo styles - already defined above */

main {
    max-width: 1200px;
    margin: 1rem auto;
    padding: 0 1rem;
}

section {
    margin-bottom: 3rem;
}

section h2 {
    color: #37AEAE;
    border-bottom: 2px solid #66FFFF;
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
    display: inline-block;
}

/* Widgets Container */
.widgets-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 1rem;
    width: calc(100% - 50px);
}

/* Widget Styling - Combined and optimized */
.widget {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
    border-top: 3px solid #66FFFF;
    transition: box-shadow 0.3s ease;
}

.widget:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.widget h3 {
    margin: 0 0 1rem 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: #647D7D;
    position: relative;
}

.widget h3::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 40px;
    height: 2px;
    background-color: #00DBDB;
}

/* Chart Container - Optimized for faster loading */
.chart-placeholder {
    width: 100%;
    height: 450px; /* Reduced from 500px to 450px */
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1rem;
    position: relative;
    background: #f8f9fa;
}

/* Loading state styling */
.chart-placeholder.loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Loaded state with fade-in */
.chart-placeholder.loaded iframe {
    opacity: 0;
    animation: fadeIn 0.3s ease-in-out forwards;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Footer overlay for cross-origin iframes */
.footer-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    background: linear-gradient(to top, 
        var(--widget-background, #ffffff) 0%, 
        rgba(255,255,255,0.95) 70%, 
        transparent 100%);
    z-index: 10;
    pointer-events: none;
    border-radius: 0 0 4px 4px;
    transition: opacity 0.3s ease;
}

/* Chart container hover state */
.chart-placeholder:hover .footer-overlay {
    opacity: 0.8;
}

/* Iframe optimization */
.chart-placeholder iframe {
    width: 100%;
    height: calc(100% + 30px); /* Extend height to hide footer */
    margin-bottom: -30px; /* Pull up to hide footer */
    border: none;
    border-radius: 4px 4px 0 0;
    background: transparent;
}

/* Loading state with footer consideration - Optimized */
.chart-placeholder.loading::before {
    content: 'Loading...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #666;
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 5;
}

/* Loading spinner animation */
.chart-placeholder.loading::after {
    content: '';
    position: absolute;
    top: calc(50% + 25px);
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 20px;
    border: 2px solid #e0e0e0;
    border-top: 2px solid #00DBDB;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 6;
}

@keyframes spin {
    0% { transform: translateX(-50%) rotate(0deg); }
    100% { transform: translateX(-50%) rotate(360deg); }
}

/* Media market main chart adjustments - Reduced Height */
.media-market-main .chart-placeholder {
    height: 520px; /* Reduced from 600px to 520px */
}

/* Responsive adjustments for media market - Reduced Heights */
@media (min-width: 1200px) {
    .media-market-main .chart-placeholder {
        height: 580px; /* Reduced from 700px to 580px */
    }
}

@media (min-width: 768px) and (max-width: 1199px) {
    .media-market-main .chart-placeholder {
        height: 480px; /* Reduced from 550px to 480px */
    }
}

@media (max-width: 767px) {
    .media-market-main .chart-placeholder {
        height: 360px; /* Reduced from 400px to 360px */
    }
}

/* Enhanced iframe handling for reduced height */
.media-market-main .chart-placeholder iframe {
    height: calc(100% + 30px); /* Maintains footer hiding */
    margin-bottom: -30px;
}

/* Responsive adjustments */
@media (max-width: 767px) {
    .chart-placeholder iframe {
        height: calc(100% + 25px);
        margin-bottom: -25px;
    }
    
    .footer-overlay {
        height: 25px;
    }
}

/* Responsive Design - Large Screens */
@media (min-width: 1024px) {
    .widgets-container {
        display: flex;
        flex-direction: row;
        gap: 2rem;
    }
    
    .widget {
        flex: 1;
        min-width: 0;
    }
    
    .chart-placeholder {
        height: 400px; /* Reduced from 450px to 400px for horizontal layout */
    }
}

/* Medium Screens - Two columns */
@media (min-width: 768px) and (max-width: 1023px) {
    .widgets-container {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 1.5rem;
    }
    
    .widget {
        flex: 1 1 calc(50% - 0.75rem);
        min-width: 300px;
    }
    
    .widget:nth-child(3) {
        flex: 1 1 100%;
    }
    
    .chart-placeholder {
        height: 380px; /* Reduced from 420px to 380px for tablets */
    }
}

/* Small Screens - Stack vertically */
@media (max-width: 767px) {
    .chart-placeholder {
        height: 320px; /* Reduced from 350px to 320px for mobile */
    }
    
    .widget {
        margin: 0 -1rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    .widgets-container {
        gap: 1rem;
        margin-top: 1rem;
    }
    
    .data-source {
        font-size: 0.7rem; /* Even smaller on mobile */
        margin-top: 0.25rem;
    }
}

footer {
    text-align: center;
    padding: 2rem;
    background-color: #647D7D;
    color: white;
}

/* Media Market Page Specific Styles */
.media-market-main {
    max-width: 100%;
}

.media-market-main .chart-placeholder {
    height: 600px; /* Larger height for the main market chart */
}

/* Responsive adjustments for media market */
@media (min-width: 1200px) {
    .media-market-main .chart-placeholder {
        height: 700px;
    }
}

@media (min-width: 768px) and (max-width: 1199px) {
    .media-market-main .chart-placeholder {
        height: 550px;
    }
}

@media (max-width: 767px) {
    .media-market-main .chart-placeholder {
        height: 400px;
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    header {
        padding: 0.5rem 1rem 0.25rem;
    }
      header h1 {
        font-family: 'Gilroy', sans-serif;
        font-weight: 700;
        font-size: 1.3rem;
        color: black;
        margin-bottom: 0.25rem;
    }
      nav ul {
        flex-direction: column;
        background: rgba(255, 255, 255, 0.15);
        border-radius: 15px;
        padding: 0.5rem;
        gap: 0.15rem;
    }
    
    nav ul li a {
        padding: 0.5rem 0.75rem;
        border-radius: 10px;
        text-align: center;
        font-size: 0.9rem;
    }
    
    .header-logos {
        position: static !important;
        transform: none !important;
        justify-content: center;
        margin-bottom: 1rem;
    }
      .dashboard-widgets {
        grid-template-columns: 1fr;
    }    .chart-placeholder {
        height: auto;
        min-height: 280px;
        aspect-ratio: 4 / 3;
        overflow: hidden;
    }
    
    .chart-placeholder iframe {
        overflow: hidden !important;
        scrollbar-width: none !important; /* Firefox */
        -ms-overflow-style: none !important; /* Internet Explorer 10+ */
    }
    
    .chart-placeholder iframe::-webkit-scrollbar {
        display: none !important; /* WebKit */
        width: 0 !important;
        height: 0 !important;
    }
}

/* Ensure logo displays properly */
/* Logo display styling */
.logo img {
    max-height: 40px;
    width: auto;
    display: block;
}

/* Responsive design for header */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .header-center {
        order: 2;
    }
    
    .user-info {
        justify-content: center;
        order: 1;
    }
    
    .header-logos {
        justify-content: center;
        order: 3;
    }
    
    header h1 {
        font-size: 1.4rem;
    }
    
    nav ul {
        justify-content: center;
    }
}

@media (max-width: 1024px) {
    .header-content {
        gap: 1rem;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
}
