:root {
    --bs-border-radius-lg: 1rem;
    --sidebar-width: 40%;
    --transition-speed: 0.3s;
    --font-size-xxl: clamp(0.875rem, 0.5rem + 1.67vw, 1.75rem); /* 14px → 28px (screen 360 → 1200 px) */
    --font-size-xl: clamp(0.875rem, 0.607rem + 1.19vw, 1.5rem); /* 14px → 24px (screen 360 → 1200 px) */
    --font-size-l: clamp(0.875rem, 0.768rem + 0.48vw, 1.125rem); /* 14px → 18px (screen 360 → 1200 px) */
    --font-size-m: clamp(0.75rem, 0.643rem + 0.48vw, 1rem);
    --font-size-s: 0.75rem;
    --orange: oklch(0.7 0.2285 44.5);
    --red: oklch(0.6353 0.2927 28.4);
    --green: oklch(0.43 0.1365 158.82);

    /* Override bootstrap vars */
    --bs-border-radius: 0.75rem;
}

body {
    background-color: #ecf0f4;
    margin: 0;
    padding: 0;
    height: 100vh;
    font-size: var(--font-size-m);
}
.ok { color: var(--green) }
.bad { color: var(--red) }
.warn { color: var(--orange) }

.app-container {
    display: flex;
    height: 100vh;
    flex-direction: column;
}

.main-content {
    flex: 1;
    display: flex;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0;
    transition: all var(--transition-speed);
    z-index: 1;
}

@media (min-width: 801px) {
    .app-container {
        flex-direction: row-reverse;
    }
    
    .main-content {
        margin-right: 0;
        overflow-x: visible;
        z-index: 2;
    }
}

.container {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    max-width: 960px;
    margin: 0 auto;
    padding: 0 15px;
}

.search-container {
    /* background: linear-gradient(135deg, #ffffff 0%, #f1f5fd 100%); */
    /* border-radius: 1rem; */
    /* box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); */
    /* padding: 2rem 1rem !important; */
    margin-top: var(--font-size-s);
    margin-bottom: var(--font-size-s);
    display: flex;
    justify-content: flex-start;
    gap: 1rem;
}

.search-box {
    border-radius: var(--bs-border-radius-lg);
    flex: 1 1 auto;
}
.search-box:has(#tickerInput:focus) {
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.5);
}

#tickerInput,
#tickerInputIcon {
    border: 1px solid #99b1ca;
    padding: var(--font-size-s) calc(var(--font-size-s) * 1.5);
}
#tickerInput {
    border-right: none;
    font-size: var(--font-size-l);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding-left: 0;
    transition: all 0.3s ease;
    height: auto;
    /* width: calc(var(--font-size-s) * 1.5 + 7ch); */
}

#tickerInput:focus {
    box-shadow: none;
}

/* Overriding Bootstrap's Input group */
.input-group-lg>.btn, .input-group-lg>.form-control, .input-group-lg>.form-select, .input-group-lg>.input-group-text {
    font-size: var(--font-size-m);
    padding: calc(var(--font-size-m) * 0.5) var(--font-size-m);
    margin-left: 0 !important;
}

.btn-primary {
    background-color: #ffffff;
    color: #43474f;
    border: 1px solid #99b1ca;
    font-weight: 500;
    padding: 0.25rem 0.8rem;
    border-radius: 1rem;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary:hover {
    background-color: #e9ecef;
    color: #495057;
    /* transform: translateY(-1px); */
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.btn-primary:active {
    transform: translateY(0);
    background-color: #e2e6ea;
}
.search-box .btn-primary {
border-left: 0;
}


.footer-controls .btn-outline-secondary {
    --bs-btn-bg: var(--bs-gray-300);
    --bs-btn-color: var(--bs-gray-700);
    --bs-btn-hover-bg: var(--bs-gray-400);
    --bs-btn-hover-color: var(--bs-gray-900);
    border: 0;
}
.footer-controls .btn-outline-danger {
    --bs-btn-bg: rgba(var(--bs-danger-rgb), 0.15);
    --bs-btn-color: var(--bs-danger);
    --bs-btn-hover-bg: var(--bs-danger);
    --bs-btn-hover-color: var(--bs-white);
    border: 0;
}



/* Stock info */
.stock-info {
    flex: 0 1 auto;
    display: flex;
    align-items: center;
    padding: 0.5rem 1.25rem; /* Horz padding same as #tickerInput */
    gap: 1rem;
    border-radius: 1rem;
    /* border: 1px dashed rgba(153, 177, 202, 0.5); */
    border: none;
    background: rgba(255, 255, 255, 0.5);
}

.stock-info > div {
    width: 8ch;
    text-align: center;
    white-space: nowrap;
    display: flex;
    flex-direction: column;
}
.stock-info-change {
    width: 9ch;
}
.stock-info-price {
    width: 8ch;
}
.stock-info-float,
.stock-info-volume {
    width: 10ch;
}
.stock-info .stock-info-label {
    font-size: 0.5rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: bold;
    color: gray;
}
.stock-info .value {
    font-size: 0.875rem; /* 0.875rem; */
    font-family: monospace;
}


/* News list */
.news-group-label {
    font-size: 1rem;
    margin: 1rem auto 0.5rem;
    text-align: center;
    /* text-shadow: 0 0 5px white; */
    width: fit-content;
    padding: 0.25rem 0.5rem;
    border-radius: 0.5rem;
}
.news-group-label:first-child {
    margin-top: 0;
}
.news-group-label.news-group-today {
    color: var(--green);
    background-color: hsla(152, 100%, 38%, 0.2);
}
.news-group-label.news-group-old {
    color: color-mix(in oklch, var(--orange), black 5%);
    background-color: hsla(28, 100%, 50%, 0.1);
}



.news-card {
    display: block;
    /* margin-bottom: var(--font-size-m); */
    margin-bottom: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    background: white;
    transition: all 0.2s;
    /* border: 1px solid #eee; */
    text-decoration: none !important;
    position: relative;
    z-index: 1;
}
.news-card:first-child,
.news-group-label + .news-card {
    /* border-radius: 0.75rem 0.75rem 0 0; */
    border-top-left-radius: 0.75rem;
    border-top-right-radius: 0.75rem;
}
.news-card:last-child,
.news-type-today-last {
    /* border-radius: 0 0 0.75rem 0.75rem; */
    border-bottom-left-radius: 0.75rem;
    border-bottom-right-radius: 0.75rem;
}

.news-card:hover {
    transform: scale(1.02);
    box-shadow: 0 2px 20px rgba(0,0,0,0.33), 0 0 3px rgba(0,0,0,0.1);
    /* box-shadow: none; */
    text-decoration: none !important;
    border-radius: 0.5rem;
    z-index: 2;
}

.news-card:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.news-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-top-left-radius: 1rem;
    border-top-right-radius: 1rem;
}

.news-content {
    padding: calc(var(--font-size-m) * 0.7) calc(var(--font-size-m) * 1.5);
    height: 100%;
    display: flex;
    flex-direction: column;
}
.news-card:first-child .news-content {
    padding-top: var(--font-size-m);
}
.news-card:last-child .news-content {
    padding-bottom: var(--font-size-m);
}

/* Copy button styles */
.copy-btn {
    opacity: 0.6;
    transition: opacity 0.2s ease, background-color 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
    /* margin-left: 0.5rem; */
    /* margin-right: -0.5rem; */
    padding: 0.5rem 0.5rem;
    border-radius: 0.5rem;
    border: 0;
    line-height: 1;
    height: 2rem;
    position: absolute;
    top: 0.33rem;
    right: 0.33rem;
}

.news-card:hover .copy-btn {
    opacity: 1;
}

.copy-btn:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.05);
    color: #222;
}

.copy-btn i {
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
}

/* Success state for copy button */
.copy-btn.btn-outline-success {
    color: #198754;
    border-color: #198754;
}

.news-title {
    font-size: var(--font-size-m);
    line-height: 1.25;
    margin-bottom: 0.125rem;
    color: #1a1a1a;
    font-weight: 600;
    transition: color 0.2s ease;
    padding-right: 2.5rem; /* Leave space for "Copy to Clipboard" button */
    /* display: flex; */
    /* justify-content: space-between; */
    /* align-items: flex-start; */
    gap: 0.5rem;
}

/* .news-card:hover .news-title {
    color: #005de9;
} */
/* Darken all other cards except currently hovering one */
#newsContainer:has(.news-card:hover) .news-card {
    background-color: #f8f9fa;
}
#newsContainer:has(.news-card:hover) .news-card:hover {
    background-color: #fff;
}
.news-card:hover .news-title {
    color: #000;
}

.news-meta {
    margin: 0;
    font-size: var(--font-size-s);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.news-date {
    color: #0d6efd;
    font-weight: 500;
}

.news-date .ago-time {
    color: #0d6efd;
}

.news-date .full-date {
    color: #495057;
}

.news-source {
    color: #6c757d;
    font-weight: 500;
}

.news-date-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.article-type {
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.article-type.news {
    color: #426eae;
}

.article-type.press-release {
    color: #2e7d32;
}



/* Styles for ago time display */
.ago-time.recent-ago {
    color: #0d6efd; /* Blue color for recent items */
    font-weight: 600;
}
.ago-time.old-ago {
    color: #1a1a1a; /* Black color for old items */
}
.news-type-old .old-ago {
    color: color-mix(in oklch, var(--orange), black 10%);
}


/* Highlighted keywords in titles */
.news-title .highlight {
    background-color: #ffacac;
    padding: 0.2em 0.3em;
    border-radius: 0.2em;
}
.news-title .highlight::selection {
    background-color: #ff9c9c;
}
.news-card:has(.highlight) {
    background-image:
        linear-gradient(hsla(354, 100%, 50%, 0.075)),
        linear-gradient(#fff);
    border-left: 2px solid var(--red);
}
.news-card:has(.highlight) .ago-time {
    color: color-mix(in oklch, var(--red), black 20%);
}
/* .news-card:has(.highlight):after {
    content: '';
    position: absolute;
    inset: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    background-color: hsla(354, 100%, 50%, 0.1);
    z-index: -1;
    transition: top 0.2s, bottom 0.2s, left 0.2s, right 0.2s, border-radius 0.2s;
}
.news-card:has(.highlight):hover:after {
    inset: 0;
    border-radius: 0.5rem;
} */
/* .news-card:has(.highlight) {
    border: 2px solid #ff6363;
}
*/
/* .news-card:has(.highlight) + .news-card:has(.highlight) {
    border-top: 2px solid #fff;
}
.news-card:has(.highlight) + .news-card:has(.highlight):hover {
    border-top: 0;
    margin-bottom: 2px;
} */


/* Sidebar Styles */
.sidebar {
    width: var(--sidebar-width);
    position: relative;
    overflow-x: hidden;
    overflow-y: auto;
    z-index: 1000;
    flex-shrink: 0;
    height: 100%;
}
@media (min-width: 801px) {
    .sidebar {
        z-index: 1;
    }
}

.sidebar-content {
    padding: 0.5rem 0.5rem 1rem;
}

.search-history-item.paused {
    opacity: 0.6;
}


/* Style for tickers with recent news (not older than 12 hours) */
.search-history-item.has-recent-news .ticker {
    color: #0056d7;
    font-weight: 600;
}

.search-history-item {
    padding: 0.5rem 1.25rem;
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s;
    position: relative;
}

.search-history-item:has(.badge-new) .time {
    display: none;
}
.search-history-item:hover {
    background-color: #f8f9fa;
}

.search-history-item .ticker {
    font-weight: 600;
    min-width: 38px;
    display: block;
}

.search-history-item .time {
    font-size: 0.8em;
    color: #6c757d;
    white-space: nowrap;
}

.badge-new {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    background-color: #0d6efd;
    color: white;
    border-radius: 10px;
    padding: 0.2em 0.6em;
    font-size: 0.7em;
    font-weight: 600;
}

/* Style for tickers with bad words */
.search-history-item.has-bad-words .ticker {
    color: #dc3545;
    font-weight: 600;
}
.search-history-item.has-bad-words .badge-new {
    background-color: #dc3545;
}


/* Sidebar articles */
.search-history_articles {
    display: none;
}
@media (min-width: 801px) {
    .search-history-item {
        padding: 0.33rem 1rem;
        flex-direction: column;
        align-items: flex-start;
        justify-content: flex-start;
        margin-bottom: 0.125rem;
    }

    .search-history-item:has(.badge-new) {
        background-color: #fff;
    }

    .search-history_ticker {
        display: flex;
        width: 100%;
        justify-content: space-between;
        align-items: center;
        gap: 0.5rem;
    }

    .search-history_articles {
        display: block;
        list-style: none;
        margin: 0;
        padding: 0;
    }
    .search-history_articles li {
        margin: 0 0 0.25rem;
        padding: 0;
        display: flex;
        gap: 0.5rem;
        font-size: 0.75rem; /* TODO: Should be responsive clamp */
        line-height: 1.2;
        color: #222;

        max-height: 3lh;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .search-history_articles li a {
        color: #222;
        text-decoration: none;
    }
    .search-history_articles time {
        font-size: 0.8em;
        color: #6c757d;
        white-space: nowrap;
    }
}


/* Notification dot for new articles */
.article-new::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 8px;
    width: 8px;
    height: 8px;
    background-color: #0d6efd;
    border-radius: 50%;
}

/* Notification dot for new articles */
.notification-dot {
    position: absolute;
    top: -7px;
    left: -7px;
    width: 16px;
    height: 16px;
    background-color: #0d6efd;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.9);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(0.9);
    }
}


/* Responsive adjustments */

@media (max-width: 800px) {
    .app-container {
        flex-direction: column;
    }

    .news-card {
        margin-bottom: calc(var(--font-size-m) * 0.6666);
    }

    .search-container {
        margin-top: 0.5rem;
        margin-bottom: 0.5rem;
    }
    
    .sidebar {
        position: relative;
        width: 100%;
        overflow-x: auto;
        height: auto;
        box-shadow: none;
        border: 0;
    }

    .sidebar-content {
        display: flex;
        padding: 0;
    }

    .search-history-item:has(.badge-new) .time {
        visibility: hidden;
        width: 1px;
    }
    .search-history-item {
        padding: 0.5rem 1rem;
        border-bottom: 0;
        margin-right: -0.5rem;
        margin-bottom: 0.5rem;
    }
    .badge-new {
        top: auto;
        right: auto;
        bottom: 0.5rem;
        left: 1rem;
    }
    
    .main-content {
        margin-right: 0;
        padding: 0;
    }
}