:root {
    --bg-color: #f5f5f7;
    --card-bg: #ffffff;
    --text-primary: #1d1d1f;
    --text-secondary: #86868b;
    --accent-color: #0066cc;
    --card-radius: 18px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

body.no-scroll {
    overflow: hidden;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: clamp(12px, 3vw, 20px);
    padding-top: 100px; /* Account for fixed header */
}

header.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px clamp(15px, 4vw, 40px);
    
    /* Fixed Position */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;

    /* Liquid Glass Effect */
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.03);
}

h1.gradient-text {
    font-size: clamp(20px, 5vw, 32px);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0;
    background: linear-gradient(135deg, #1a1a1a 0%, #4a4a4a 100%); /* Fallback / Dark */
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    /* Apple-like colorful gradient option if preferred, but "Apple gradient" usually refers to text gradients seen in marketing */
    background-image: linear-gradient(90deg, #c744ff 0%, #3eccff 100%); 
}

.navbar-title-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.navbar-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 400;
    letter-spacing: -0.01em;
}

.search-section {
    max-width: 1400px;
    margin: 0 auto;
    padding: clamp(10px, 2vw, 20px) clamp(10px, 2vw, 20px) clamp(20px, 4vw, 40px) clamp(10px, 2vw, 20px);
    display: flex;
    justify-content: center;
    align-items: center;
}

.search-box {
    width: 100%;
    max-width: 600px;
    position: relative;
    margin: 0 auto;
}

.search-input-wrapper {
    position: relative;
    width: 100%;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08); /* Add shadow for floating effect */
    border-radius: 16px; /* Match input radius */
}

input[type="text"], input[type="password"] {
    padding: 16px 24px; /* Larger padding for hero search */
    border-radius: 16px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 18px;
    width: 100%; /* Take full width of wrapper */
    outline: none;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.9);
}

input[type="text"]:focus {
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(0, 102, 204, 0.15);
    border-color: var(--accent-color);
}

input[type="text"]:disabled {
    background-color: #e5e5e5;
    cursor: not-allowed;
}

button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

input[type="text"]:focus, input[type="password"]:focus {
    border-color: var(--accent-color);
}

button {
    background-color: var(--accent-color);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 17px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

button:hover {
    background-color: #004499;
}

.api-key-config {
    display: flex;
    align-items: center;
    gap: 10px;
}

.login-btn {
    background-color: var(--text-primary);
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: opacity 0.2s;
}

.login-btn:hover {
    opacity: 0.8;
    background-color: var(--text-primary);
}

.user-status {
    font-size: 14px;
    color: #34c759;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
}

.user-status::before {
    content: '';
    display: block;
    width: 8px;
    height: 8px;
    background-color: #34c759;
    border-radius: 50%;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background-color: white;
    padding: 40px;
    border-radius: 24px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    text-align: center;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-content h2 {
    margin-bottom: 10px;
    font-size: 24px;
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 25px;
    font-size: 15px;
}

.modal-content input {
    width: 100%;
    margin-bottom: 20px;
    padding: 14px;
    font-size: 16px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.modal-actions button {
    flex: 1;
    padding: 12px;
    border-radius: 12px;
    font-size: 15px;
    cursor: pointer;
}

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

.secondary-btn {
    background-color: #f5f5f7;
    color: var(--text-primary);
    border: none;
}

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

.modal-content small {
    color: var(--text-secondary);
    font-size: 13px;
}

.modal-content a {
    color: var(--accent-color);
    text-decoration: none;
}

.dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.card-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.card-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 24px;
}

.chart-container {
    position: relative;
    height: clamp(220px, 40vh, 300px);
    width: 100%;
}

.chart-container canvas {
    max-height: 100% !important;
    height: 100%;
}

.chart-container-small {
    position: relative;
    height: clamp(160px, 30vh, 200px);
    width: 100%;
}

.chart-container-small canvas {
    max-height: 100% !important;
    height: 100%;
    margin-top: 0; /* Remove global margin to fit container */
}

.scrollable {
    max-height: 300px;
    overflow-y: auto;
}

.card {
    background-color: var(--card-bg);
    border-radius: var(--card-radius);
    padding: 24px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
}

/* .card.wide is no longer strictly needed for grid span if we use flex rows, 
   but we can keep it for specific styling if needed. */
.card.wide {
    width: 100%;
}

h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.card-content {
    flex: 1;
    font-size: 15px;
    color: var(--text-secondary);
}

.data-point {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 4px;
}

.data-label {
    color: var(--text-secondary);
}

.data-value {
    color: var(--text-primary);
    font-weight: 500;
    text-align: right;
}

.placeholder {
    color: #d2d2d7;
    font-style: italic;
}

canvas {
    margin-top: 15px;
    max-height: 200px;
    width: 100%;
}

.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #d2d2d7;
    border-radius: 12px;
    margin-top: 5px;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 1000;
    display: none; /* Hidden by default */
}

.search-dropdown.active {
    display: block;
}

.search-result-item {
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.search-result-item:hover {
    background-color: #f5f5f7;
}

.item-symbol {
    font-weight: 600;
    color: var(--text-primary);
}

.item-name {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

/* DevTools Styles */
#devToolsToggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: #333;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999;
    font-size: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transition: transform 0.2s;
}

#devToolsToggle:hover {
    transform: scale(1.1);
}

#devToolsPanel {
    position: fixed;
    bottom: 70px;
    right: 20px;
    width: clamp(300px, 90vw, 400px);
    height: 500px;
    background: #1e1e1e;
    color: #d4d4d4;
    border-radius: 12px;
    display: none; /* Hidden by default */
    flex-direction: column;
    z-index: 9998;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 12px;
    border: 1px solid #333;
}

#devToolsPanel.active {
    display: flex;
}

.dev-header {
    padding: 10px;
    background: #252526;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 12px 12px 0 0;
}

.dev-header h3 {
    margin: 0;
    font-size: 14px;
    color: #fff;
}

.dev-actions button {
    background: #333;
    border: 1px solid #444;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
}

.dev-actions button:hover {
    background: #444;
}

#logContainer {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.log-entry {
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid #333;
    word-break: break-all;
}

.log-time {
    color: #86868b;
    margin-right: 5px;
}

.log-type-info { color: #4fc1ff; }
.log-type-success { color: #4ec9b0; }
.log-type-warn { color: #cca700; }
.log-type-error { color: #f14c4c; }
.log-type-api { color: #ce9178; }

/* Footer Styles */
.site-footer {
    background-color: #fdfdfd;
    color: var(--text-secondary);
    font-size: 12px;
    padding: 24px 0;
    margin-top: 40px;
    border-top: 1px solid #fdfdfd;
}

.footer-content {
    max-width: 980px;
    margin: 0 auto;
    padding: 0 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.footer-text a {
    color: inherit;
    text-decoration: none;
}

.footer-text a:hover {
    text-decoration: underline;
}

/* Toggle Buttons */
.toggle-btn {
    padding: 8px 16px;
    border: 1px solid #d2d2d7;
    background: #fff;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.toggle-btn.active {
    background: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
}

.toggle-btn:hover:not(.active) {
    background: #f5f5f7;
}

/* Trend Variable Buttons */
.trend-var-btn {
    padding: 6px 12px;
    border: 1px solid #e5e5ea;
    background: #f5f5f7;
    border-radius: 16px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.trend-var-btn.active {
    background: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
}

.trend-var-btn:hover:not(.active) {
    background: #e5e5ea;
    color: var(--text-primary);
}

.scrollable-x::-webkit-scrollbar {
    height: 4px;
}

.scrollable-x::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 2px;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .card-row-2, .card-row-3 {
        grid-template-columns: 1fr;
    }

    input[type="text"], input[type="password"] {
        padding: 12px 16px;
        font-size: 16px; /* Prevent zoom on iOS */
    }

    button {
        padding: 12px 16px;
    }

    .card {
        padding: 16px;
    }

    h3 {
        font-size: 18px;
        margin-bottom: 12px;
    }

    .card-content {
        font-size: 13px;
    }

    .data-point {
        margin-bottom: 8px;
    }

    /* Modal Mobile Optimizations */
    .modal-content {
        padding: 20px;
        width: 95%;
        max-height: 90vh;
        overflow-y: auto;
    }
}

@media (max-width: 375px) {
    .navbar {
        padding: 10px 15px;
    }
    
    .api-key-config {
        gap: 5px;
    }
    
    .login-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
}
