@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --bg-color: #0f172a;
    --text-color: #f8fafc;
    --primary-color: #38bdf8;
    --secondary-color: #818cf8;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --accent-gradient: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    background-image:
        radial-gradient(at 0% 0%, rgba(56, 189, 248, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(129, 140, 248, 0.15) 0px, transparent 50%);
    background-attachment: fixed;
    overflow-x: hidden;
}

/* Header */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    background: rgba(15, 23, 42, 0.8);
    border-bottom: 1px solid var(--glass-border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    font-weight: 700;
    font-size: 1.5rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}

/* Layout */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 2rem;
}

/* Logout Button */
.logout-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    color: #cbd5e1;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    font-weight: 500;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.3);
}

.logout-text {
    display: inline-block;
}

@media (max-width: 600px) {
    .logout-text {
        display: none;
    }

    .logout-btn {
        padding: 0.5rem;
    }
}

/* Filters Sidebar */
.filters {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
    position: sticky;
    top: 6rem;
    height: fit-content;
    max-height: calc(100vh - 8rem);
    overflow-y: auto;
    backdrop-filter: blur(8px);
    transition: transform 0.3s ease;
}

.filter-group {
    margin-bottom: 1.5rem;
}

.filter-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #94a3b8;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

select,
input[type="number"],
.filter-btn {
    width: 100%;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    color: var(--text-color);
    padding: 0.75rem;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    transition: all 0.2s;
    appearance: none;
    /* Remove default arrow */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
}

/* For multi-select simulation or custom UI, we stick to native select for now but styled nicely */
select[multiple] {
    height: 120px;
    background-image: none;
    padding: 0.5rem;
}

select[multiple] option {
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
}

select[multiple] option:checked {
    background: rgba(56, 189, 248, 0.3);
}

select:focus,
input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

/* Custom Dropdown Styling */
.custom-dropdown {
    position: relative;
    width: 100%;
}

.dropdown-trigger {
    width: 100%;
    padding: 10px;
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: #cbd5e1;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.dropdown-trigger:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(56, 189, 248, 0.3);
}

.dropdown-trigger::after {
    content: '▼';
    font-size: 0.7em;
    color: #94a3b8;
    transition: transform 0.2s;
}

.custom-dropdown.open .dropdown-trigger::after {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-height: 250px;
    overflow-y: auto;
    background: #0f172a;
    /* Solid-ish background for readability overlay */
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    margin-top: 5px;
    padding: 0.5rem;
    z-index: 100;
    display: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.custom-dropdown.open .dropdown-menu {
    display: block;
}

.dropdown-item {
    padding: 0.6rem 0.8rem;
    cursor: pointer;
    border-radius: 6px;
    color: #94a3b8;
    transition: all 0.1s;
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #f1f5f9;
}

.dropdown-item.selected {
    background: rgba(56, 189, 248, 0.2);
    color: var(--primary-color);
    font-weight: 500;
}

.dropdown-item.select-all {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 5px;
    padding-bottom: 8px;
    color: #e2e8f0;
}


/* Dual Range Slider */
.range-slider {
    position: relative;
    width: 100%;
    height: 40px;
    /* Space for thumbs */
}

.range-slider input[type="range"] {
    position: absolute;
    width: 100%;
    pointer-events: none;
    /* Allow click through to second slider */
    background: none;
    /* Override default */
    -webkit-appearance: none;
    z-index: 2;
}

/* Make thumb clickable */
.range-slider input[type="range"]::-webkit-slider-thumb {
    pointer-events: all;
    z-index: 3;
    position: relative;
}

/* Track back */
.range-track {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    z-index: 1;
}

/* Fix z-indexing for overlapping thumbs */
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 18px;
    width: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    margin-top: -7px;
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.4);
    border: 2px solid #fff;
}

/* Remove default track on inputs so they don't block visual track */
input[type=range]::-webkit-slider-runnable-track {
    background: transparent;
    height: 4px;
}

.reset-btn {
    width: 100%;
    padding: 0.75rem;
    background: transparent;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: #94a3b8;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 1rem;
}

.reset-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #cbd5e1;
    border-color: rgba(255, 255, 255, 0.2);
}

.apply-btn {
    width: 100%;
    padding: 0.75rem;
    background: var(--accent-gradient);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    margin-top: 0.5rem;
    /* Reduced margin since Reset is above or below */
}

.apply-btn:hover {
    opacity: 0.9;
}

/* Mobile Toggle */
.filter-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.5rem;
    cursor: pointer;
}

/* Announcements Grid */
.announcements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

/* Card */
.card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    box-shadow: var(--card-shadow);
    backdrop-filter: blur(4px);
    border-radius: 16px;
    overflow: hidden;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    position: relative;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
    border-color: rgba(56, 189, 248, 0.3);
}

.card-header {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.company-name {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.date-badge {
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    color: #cbd5e1;
    align-self: flex-start;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.summary-section {
    flex-grow: 1;
    margin-bottom: 1rem;
}

.card-summary {
    font-size: 0.95rem;
    /* Increased size */
    color: #e2e8f0;
    /* Brighter color */
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    /* More lines */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: auto;
}

.tag {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--glass-border);
}

.tag.impact-High {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    color: #fca5a5;
}

.tag.impact-Medium {
    background: rgba(234, 179, 8, 0.2);
    border-color: rgba(234, 179, 8, 0.4);
    color: #fde047;
}

.tag.impact-Low {
    background: rgba(34, 197, 94, 0.2);
    border-color: rgba(34, 197, 94, 0.4);
    color: #86efac;
}

.confidence-tag {
    background: rgba(129, 140, 248, 0.2);
    border-color: rgba(129, 140, 248, 0.4);
    color: #c7d2fe;
}

/* Card Actions */
.card-actions {
    display: flex;
    gap: 5px;
    /* No absolute positioning needed */
}

.action-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.imp-btn.active {
    color: #fbbf24;
}

.read-btn.active {
    color: #fbbf24;
    /* Yellow for read tick */
}

.read-btn {
    font-size: 1rem;
}

.card.read {
    opacity: 0.7;
    background: rgba(30, 41, 59, 0.4);
    /* Darker/Dimmed */
    border-color: rgba(255, 255, 255, 0.05);
}

.card.read:hover {
    opacity: 0.95;
    background: var(--glass-bg);
    border-color: var(--glass-border);
}

/* Modal & Others */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: #1e293b;
    border: 1px solid var(--glass-border);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 20px;
    padding: 2rem;
    position: relative;
    transform: scale(0.95);
    transition: transform 0.3s;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

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

.close-btn {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.close-btn:hover {
    color: white;
}

.modal-header {
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 1rem;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.modal-meta {
    display: flex;
    gap: 1.5rem;
    color: #94a3b8;
    font-size: 0.9rem;
}

.modal-body h3 {
    font-size: 1.1rem;
    margin: 1.5rem 0 0.75rem 0;
    color: var(--secondary-color);
}

.modal-body p {
    line-height: 1.7;
    color: #e2e8f0;
    margin-bottom: 1rem;
}

/* Loading */
.loading {
    display: none;
    justify-content: center;
    padding: 3rem;
    grid-column: 1 / -1;
}

.loading.active {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive */
@media (max-width: 900px) {
    .container {
        grid-template-columns: 1fr;
    }

    .filters {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        max-height: 80vh;
        border-radius: 20px 20px 0 0;
        transform: translateY(100%);
        z-index: 90;
        margin: 0;
        background: #0f172a;
        /* Solid bg on mobile for legibility */
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    .filters.open {
        transform: translateY(0);
    }

    .filter-toggle {
        display: block;
    }

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

/* Pagination & Total Count */
.total-count-display {
    grid-column: 1 / -1;
    margin-bottom: 1rem;
    font-size: 1rem;
    color: #94a3b8;
    text-align: right;
    font-weight: 500;
}

.pagination-controls {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    margin-top: 2rem;
    padding-bottom: 2rem;
}

.page-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-color);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
    background: rgba(56, 189, 248, 0.2);
    border-color: var(--primary-color);
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-info {
    color: #cbd5e1;
    font-variant-numeric: tabular-nums;
}

/* Card Footer & Question Pill */
.card-footer {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.question-pill {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--secondary-color);
    background: rgba(129, 140, 248, 0.1);
    padding: 0.3rem 0.8rem;
    border-radius: 99px;
    border: 1px solid rgba(129, 140, 248, 0.2);
    text-transform: capitalize;
    letter-spacing: 0.02em;
}