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

:root {
    --bg-primary: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    --bg-card: rgba(255, 255, 255, 0.05);
    --border-card: rgba(255, 255, 255, 0.1);
    --text-primary: #fff;
    --text-secondary: #ccd6f6;
    --text-muted: #8892b0;
    --shadow-hover: rgba(0, 0, 0, 0.3);
}

[data-theme="light"] {
    --bg-primary: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
    --bg-card: rgba(255, 255, 255, 0.9);
    --border-card: rgba(0, 0, 0, 0.1);
    --text-primary: #1a1a2e;
    --text-secondary: #374151;
    --text-muted: #6b7280;
    --shadow-hover: rgba(0, 0, 0, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    min-height: 100vh;
    color: var(--text-primary);
    transition: background 0.3s ease, color 0.3s ease;
}

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

header {
    text-align: center;
    margin-bottom: 50px;
}

.header-top {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 10px;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(90deg, #00d4ff, #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.theme-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: 50px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    transform: scale(1.1);
}

.icon-sun {
    display: none;
}

.icon-moon {
    display: inline;
}

[data-theme="light"] .icon-sun {
    display: inline;
}

[data-theme="light"] .icon-moon {
    display: none;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.stocks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 30px;
    margin-bottom: 30px;
}

.stock-card {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 30px;
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-card);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
}

.stock-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px var(--shadow-hover);
}

.stock-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
}

.stock-logo {
    background: linear-gradient(135deg, #7c3aed, #00d4ff);
    padding: 15px 20px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1.2rem;
    color: #fff;
}

.stock-name {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.stock-body {
    margin-bottom: 25px;
}

.price-section {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 10px;
}

.current-price {
    font-size: 2.5rem;
    font-weight: 700;
}

.currency {
    color: var(--text-muted);
    font-size: 1rem;
}

.change-section {
    display: flex;
    gap: 10px;
    font-size: 1.1rem;
}

.change.positive,
.change-percent.positive {
    color: #10b981;
}

.change.negative,
.change-percent.negative {
    color: #ef4444;
}

.stock-metrics {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    padding-top: 20px;
    border-top: 1px solid var(--border-card);
}

.metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: rgba(124, 58, 237, 0.1);
    border-radius: 10px;
    transition: background 0.3s ease;
}

.metric:hover {
    background: rgba(124, 58, 237, 0.2);
}

.metric-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

.metric-value {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.stock-footer {
    display: flex;
    justify-content: space-between;
    padding-top: 20px;
    border-top: 1px solid var(--border-card);
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

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

.stat-value {
    font-weight: 600;
    font-size: 1rem;
}

.update-info {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

#refresh-btn {
    background: linear-gradient(135deg, #7c3aed, #00d4ff);
    border: none;
    padding: 10px 25px;
    border-radius: 25px;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.3s ease;
}

#refresh-btn:hover {
    opacity: 0.8;
}

#refresh-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.loading {
    animation: pulse 1.5s infinite;
}

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

.error-message {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.5);
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    color: #ef4444;
}

/* --- Chat Section --- */
.chat-section {
    margin-top: 50px;
    padding: 40px;
    background: var(--bg-card);
    border-radius: 20px;
    border: 1px solid var(--border-card);
    backdrop-filter: blur(10px);
}

.chat-title {
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 30px;
    background: linear-gradient(90deg, #00d4ff, #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.chat-box {
    height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border-card);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .chat-box {
    background: rgba(0, 0, 0, 0.05);
}

.chat-message {
    margin-bottom: 10px;
    line-height: 1.5;
}

.chat-timestamp {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-right: 8px;
}

.chat-nickname {
    font-weight: 700;
    color: var(--text-secondary);
}

.chat-text {
    color: var(--text-primary);
}

.chat-input-area {
    display: flex;
    gap: 10px;
}

.chat-input-area input {
    flex-grow: 1;
    padding: 12px 16px;
    border: 1px solid var(--border-card);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.chat-input-area input:focus {
    outline: none;
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
}

.chat-input-area input::placeholder {
    color: var(--text-muted);
}

.chat-input-area #chat-nickname {
    flex-grow: 0;
    width: 120px;
}

.chat-input-area button {
    padding: 12px 20px;
    background: linear-gradient(135deg, #7c3aed, #00d4ff);
    border: none;
    border-radius: 10px;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.3s ease;
}

.chat-input-area button:hover {
    opacity: 0.9;
}


@media (max-width: 768px) {
    .header-top {
        flex-direction: column;
        gap: 15px;
    }

    header h1 {
        font-size: 1.8rem;
    }

    .stocks-grid {
        grid-template-columns: 1fr;
    }

    .current-price {
        font-size: 2rem;
    }

    .stock-card {
        padding: 20px;
    }
}
