:root {
    --bg-dark: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --primary: #3b82f6;
    --accent: #8b5cf6;
    --success: #10b981;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass-border: rgba(255, 255, 255, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    background-image:
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.15) 0px, transparent 50%);
    background-attachment: fixed;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: 300px;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border-right: 1px solid var(--glass-border);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.brand {
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(to right, var(--primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.portfolio-section h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.ticker-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
    max-height: 400px;
}

.ticker-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border: 1px solid transparent;
}

.ticker-name {
    font-weight: 600;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: 0.2s;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-remove {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
}

.btn-remove:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: 0.2s;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    padding-bottom: 4rem;
}

.header {
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.025em;
}

.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 1.5rem;
}

.news-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.news-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.2);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.news-title {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.4;
}

.news-title a {
    color: var(--text-main);
    text-decoration: none;
    transition: color 0.2s;
}

.news-title a:hover {
    color: var(--primary);
    text-decoration: underline;
}

.ticker-tag {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}

.news-summary {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
}

.card-footer {
    border-top: 1px solid var(--glass-border);
    padding-top: 1rem;
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.timestamp {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.4);
}

.badges {
    display: flex;
    gap: 0.5rem;
}

.badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    border-radius: 20px;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.badge.es {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge.whale {
    background: rgba(249, 115, 22, 0.2);
    color: #fb923c;
    border: 1px solid rgba(249, 115, 22, 0.3);
    animation: pulse 2s infinite;
}

.btn-read-more {
    display: block;
    text-align: center;
    background: rgba(59, 130, 246, 0.15);
    color: var(--primary);
    text-decoration: none;
    padding: 0.75rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: 0.2s;
    margin-top: 0.5rem;
}

.btn-read-more:hover {
    background: rgba(59, 130, 246, 0.25);
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: #1e293b;
    width: 90%;
    max-width: 500px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-body {
    padding: 1.5rem;
}

.add-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.add-form input {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    padding: 0.75rem;
    border-radius: 8px;
    color: white;
    outline: none;
}

.modal-list-container h3 {
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.modal-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.modal-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
}

@keyframes pulse {
    0% {
        opacity: 0.8;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.8;
    }
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
        overflow: auto;
    }

    body {
        overflow: auto;
    }

    .sidebar {
        width: 100%;
        position: relative;
        padding: 1rem;
        height: auto;
        background: var(--bg-card);
        /* Ensure better contrast */
        z-index: 50;
    }

    .ticker-list {
        display: flex !important;
        /* Force override */
        flex-direction: row;
        overflow-x: auto;
        width: 100%;
        padding-bottom: 0.5rem;
        gap: 0.5rem;
        border-bottom: 1px solid var(--glass-border);
        margin-bottom: 1rem;
        /* Scrollbar styles */
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .ticker-list::-webkit-scrollbar {
        display: none;
    }

    .ticker-item {
        white-space: nowrap;
        min-width: auto;
        /* Allow auto scaling */
        flex: 0 0 auto;
        /* Prevent shrinking */
        padding: 0.5rem 1rem;
        justify-content: center;
        background: rgba(255, 255, 255, 0.1);
    }

    .portfolio-section h3 {
        display: none;
    }

    /* Ensure Title and 'Ver Todo' are visible */
    .portfolio-section div[style*="justify-content:space-between"] {
        margin-bottom: 0.5rem;
    }

    .main-content {
        padding: 1rem;
        padding-top: 0;
    }

    .news-grid {
        grid-template-columns: 1fr;
    }
}

/* Login Styles */
.login-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    padding: 2.5rem;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.login-form label {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
}

.login-form input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    padding: 0.75rem;
    border-radius: 8px;
    color: white;
    outline: none;
    transition: border-color 0.2s;
}

.login-form input:focus {
    border-color: var(--primary);
}

.error-msg {
    color: #ef4444;
    font-size: 0.9rem;
    text-align: center;
    background: rgba(239, 68, 68, 0.1);
    padding: 0.5rem;
    border-radius: 4px;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border: 1px solid var(--glass-border);
    padding: 0.75rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    flex: 1;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.selectable {
    cursor: pointer;
}

.selectable:hover {
    background: rgba(255, 255, 255, 0.1);
}

.active {
    border-left: 3px solid var(--primary);
    background: rgba(59, 130, 246, 0.1);
}

.btn-xs {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    border-radius: 4px;
    cursor: pointer;
    transition: 0.2s;
}

.btn-xs:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}