/* File: static/css/style.css (FINAL CORRECTED VERSION - Restores All Original Styles) */

:root {
    --primary-color: #00234b;
    --secondary-color: #f4f7f9;
    --text-color: #333;
    --light-text-color: #ffffff;
    --card-bg: #ffffff;
    --card-shadow: 0 4px 20px rgba(0, 35, 75, 0.06);
    --card-hover-shadow: 0 7px 25px rgba(0, 35, 75, 0.1);
    --border-color: #eef;
    --accent-color: #0056b3;
    
    /* Theme Colors */
    --theme-blue-bg: #e6f7ff; --theme-blue-text: #096dd9;
    --theme-purple-bg: #f9f0ff; --theme-purple-text: #722ed1;
    --theme-green-bg: #f6ffed; --theme-green-text: #389e0d;
    --theme-orange-bg: #fff7e6; --theme-orange-text: #d46b08;
    --theme-red-bg: #fff1f0; --theme-red-text: #cf1322;
    --theme-teal-bg: #e6fffb; --theme-teal-text: #08979c;
    --theme-grey-bg: #fafafa; --theme-grey-text: #595959;
}

/* --- GLOBAL STYLES --- */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6; margin: 0; padding: 0; background-color: var(--secondary-color); color: var(--text-color);
}
.container { 
    max-width: 1200px; margin: 40px auto; padding: 0 20px;
}
.logout-link { padding: 6px 16px; font-size: 0.85em; display: inline-block; border-radius: 6px; text-decoration: none; font-weight: 600; text-align: center; box-sizing: border-box; border: 2px solid var(--border-color); background-color: transparent; color: #555; transition: all 0.2s ease-in-out; }
.logout-link:hover { background-color: #fff1f0; color: #cf1322; border-color: #ffa39e; }
footer { text-align: center; padding: 40px 20px; margin-top: 50px; color: #777; font-size: 0.9em; }

/* --- HEADER & NAVIGATION --- */
.page-header.with-logout { 
    position: relative; display: flex; justify-content: center; align-items: center; padding-top: 20px; margin-bottom: 25px; min-height: 45px; 
}
.page-header.with-logout h1 { margin: 0; font-size: 2.2rem; }
.user-menu { position: absolute; right: 0; top: 50%; transform: translateY(-50%); display: flex; align-items: center; gap: 15px; }
.tabs-nav { display: flex; justify-content: center; border-bottom: 2px solid var(--border-color); margin-bottom: 40px; }
.tabs-nav .tab-button { padding: 10px 25px; cursor: pointer; border: none; background: none; font-size: 1.1em; color: #555; }
.tabs-nav .tab-button.active { color: var(--light-text-color); background-color: var(--primary-color); font-weight: 600; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* --- SEARCH & MESSAGES --- */
.search-container { max-width: 800px; margin: 0 auto 30px auto; }
#search-input { width: 100%; padding: 12px 20px; font-size: 1.1rem; border: 1px solid #ddd; border-radius: 8px; box-sizing: border-box; transition: border-color 0.2s, box-shadow 0.2s; }
#search-input:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 4px rgba(0, 35, 75, 0.1); }
.no-results-message { text-align: center; padding: 40px 20px; font-style: italic; color: #777; font-size: 1.1rem; }

/* --- COMPANY CARD & MENU STYLES (CORRECTED & RESTORED) --- */
.company-list-section { margin-bottom: 40px; }
.company-list-section h2 { font-size: 1.5rem; color: var(--primary-color); border-bottom: 2px solid var(--border-color); padding-bottom: 10px; margin-bottom: 25px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 25px; list-style-type: none; padding: 0; }
.card { background: var(--card-bg); border-radius: 10px; box-shadow: var(--card-shadow); transition: transform 0.2s ease, box-shadow 0.2s ease; position: relative; overflow: visible; }
.card:hover { transform: translateY(-5px); box-shadow: var(--card-hover-shadow); }
.card a { display: block; text-decoration: none; color: inherit; padding: 25px; }
.card-title { font-size: 1.25em; color: var(--primary-color); margin: 0 0 10px 0; }
.card-description { font-size: 0.95em; color: #555; margin: 0; }

.card-menu { position: absolute; top: 15px; right: 15px; z-index: 5; }
.card-menu-button { background: #f0f2f5; border: none; border-radius: 50%; width: 32px; height: 32px; padding: 0; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background-color 0.2s, opacity 0.2s; opacity: 0; }
.card:hover .card-menu-button { opacity: 1; }
.card-menu-button:hover { background-color: #e4e6eb; }
.card-menu-button svg { width: 20px; height: 20px; color: #555; }
.card-dropdown-menu { display: none; position: absolute; right: 0; top: calc(100% + 5px); background-color: var(--card-bg); min-width: 180px; box-shadow: 0 8px 16px rgba(0,0,0,0.1); z-index: 10; border-radius: 8px; overflow: hidden; border: 1px solid #eee; padding: 5px 0; }
.card-menu.open .card-dropdown-menu { display: block; }
.card-menu-item { background: none; border: none; width: 100%; padding: 10px 15px; text-align: left; font-size: 0.9em; font-weight: 500; color: var(--text-color); cursor: pointer; }
.card-menu-item:hover { background-color: #f7f9fc; }
.card-menu-item.active { background-color: var(--theme-blue-bg); color: var(--theme-blue-text); font-weight: 600; }
.card-menu-item.active:before { content: '✔ '; }
.menu-divider { height: 1px; background-color: #eee; margin: 5px 0; }


/* --- VOTE WIDGET, INSIGHTS, TAGS --- */
.vote-widget { display: flex; align-items: center; border: 1px solid #d9d9d9; border-radius: 16px; overflow: hidden; background-color: #fff; flex-shrink: 0; }
.vote-btn { background: none; border: none; cursor: pointer; padding: 6px 10px; line-height: 1; font-size: 1.2em; color: #555; transition: background-color 0.2s; }
.vote-btn:hover { background-color: #f0f2f5; }
.vote-count { padding: 0 10px; font-weight: 600; font-size: 1em; border-left: 1px solid #d9d9d9; border-right: 1px solid #d9d9d9; }
.vote-widget.small .vote-btn { font-size: 1em; padding: 4px 8px; }
.vote-widget.small .vote-count { font-size: 0.9em; padding: 0 8px; }
.insights-list { list-style: none; padding: 0; max-width: 900px; margin: 0 auto; }
.insight-card { position: relative; background: var(--card-bg); padding: 30px; margin-bottom: 25px; border-radius: 12px; box-shadow: var(--card-shadow); transition: box-shadow 0.2s ease; }
.insight-card:hover { box-shadow: var(--card-hover-shadow); }
.insight-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; gap: 15px; }
.insight-company-name { color: var(--primary-color); font-size: 1.2rem; font-weight: 600; margin: 0; }
.insight-text { font-size: 1.15rem; line-height: 1.7; color: var(--text-color); margin: 0 0 25px 0; }
.insight-footer { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.tag { display: inline-block; padding: 6px 14px; border-radius: 6px; font-weight: 600; font-size: 0.85em; }
.theme-blue { background-color: var(--theme-blue-bg); color: var(--theme-blue-text); }
.theme-purple { background-color: var(--theme-purple-bg); color: var(--theme-purple-text); }
.theme-green { background-color: var(--theme-green-bg); color: var(--theme-green-text); }
.theme-orange { background-color: var(--theme-orange-bg); color: var(--theme-orange-text); }
.theme-red { background-color: var(--theme-red-bg); color: var(--theme-red-text); }
.theme-teal { background-color: var(--theme-teal-bg); color: var(--theme-teal-text); }
.theme-grey { background-color: var(--theme-grey-bg); color: var(--theme-grey-text); }

/* --- COMPANY REPORT PAGE --- */
.company-page-container { background-color: #fff; padding: 2rem 3rem; border: 1px solid var(--border-color); box-shadow: 0 4px 25px rgba(0,0,0,0.05); }
.header-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; }
.header-nav-right { display: flex; align-items: center; gap: 15px; }
.back-link { color: var(--accent-color); text-decoration: none; font-weight: 600; font-size: 0.95em; }
.company-header { display: flex; justify-content: center; align-items: center; gap: 20px; text-align: center; margin-bottom: 2rem; flex-wrap: wrap; }
.company-header h1 { font-family: Georgia, 'Times New Roman', Times, serif; font-size: 2.0rem; margin: 0; font-weight: normal; color: #111; }
.tabs { display: flex; flex-wrap: wrap; justify-content: center; border-bottom: 2px solid #e1e8ed; margin-bottom: 2.5rem; }
.tabs .tab-button { padding: 0.8rem 1.2rem; cursor: pointer; border: none; background: none; font-size: 0.9rem; color: #555; border-bottom: 3px solid transparent; margin: 0 5px -2px 5px; transition: color 0.2s, border-color 0.2s; }
.tabs .tab-button:hover { color: var(--primary-color); }
.tabs .tab-button.active { color: var(--primary-color); font-weight: 600; border-bottom-color: var(--primary-color); }
.tab-content .table-responsive { overflow-x: auto; margin: 1.5em 0; border: 1px solid var(--border-color); border-radius: 5px; }
.tab-content table { width: 100%; border-collapse: collapse; }
.tab-content th, .tab-content td { padding: 12px 15px; text-align: left; border-bottom: 1px solid var(--border-color); }
.tab-content th { background-color: #f8f9fa; font-weight: 600; }
.feedback-section { border-top: 2px solid #f0f2f5; margin-top: 3rem; padding-top: 1.5rem; }
.tab-content {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    /* Reduced from default (approx 16px) to ~15px */
    font-size: 0.95rem; 
    color: #334155; /* Slate grey for better readability */
    line-height: 1.6; /* Good breathing room */
}
.tab-content th:first-child {
    position: sticky;
    left: 0;
    z-index: 2; /* Higher than body, lower than dropdowns */
    background-color: #f8fafc; /* Must match header bg */
    border-right: 1px solid #e2e8f0;
    /* Shadow to indicate scroll */
    box-shadow: 4px 0 8px -4px rgba(0,0,0,0.1); 
}

/* Sticky Body Cell */
.tab-content td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background-color: #ffffff; /* Must be opaque white */
    border-right: 1px solid #e2e8f0;
    font-weight: 600; /* Highlight the row label */
    color: #1e293b;
    /* Shadow to indicate scroll */
    box-shadow: 4px 0 8px -4px rgba(0,0,0,0.1); 
}

/* Remove double borders on the first cell caused by sticky setup */
.tab-content th:first-child, .tab-content td:first-child {
    border-left: none; 
}


/* --- LEADERBOARD / SCREENER --- */
.screener-container { background-color: #ffffff; border: 1px solid #e9ecef; border-radius: 8px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04); padding: 1.5rem; }
.screener-header { display: flex; justify-content: space-between; align-items: flex-start; padding-bottom: 1.5rem; margin-bottom: 1rem; border-bottom: 1px solid #e9ecef; }
.disclaimer-text { flex-grow: 1; padding-right: 2rem; }
.disclaimer-text p { margin: 0; font-size: 0.85rem; line-height: 1.5; color: #6c757d; }
.disclaimer-text p strong { color: #495057; }
.screener-controls { flex-shrink: 0; }
.dropdown { position: relative; display: inline-block; }
.dropdown-button { background-color: #f8f9fa; color: #333; padding: 0.6rem 1rem; font-size: 0.9rem; border: 1px solid #dee2e6; border-radius: 4px; cursor: pointer; transition: background-color 0.2s; }
.dropdown-content { display: none; position: absolute; right: 0; background-color: #ffffff; min-width: 220px; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.1); z-index: 10; border: 1px solid #ddd; border-radius: 4px; padding: 0.75rem; max-height: 300px; overflow-y: auto; }
.dropdown-content.show { display: block; }
.dropdown-content label { display: block; padding: 0.4rem 0.5rem; cursor: pointer; border-radius: 3px; font-size: 0.9rem; }
.dropdown-content label input { margin-right: 0.5rem; }
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.screener-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.screener-table th { font-weight: 600; text-transform: uppercase; font-size: 0.75rem; color: #6c757d; padding: 1rem; text-align: left; border-bottom: 2px solid #dee2e6; background-color: #fff; cursor: pointer; user-select: none; white-space: nowrap; }
.screener-table td { border-bottom: 1px solid #e9ecef; padding: 1rem; color: #343a40; }
.screener-table th:first-child, .screener-table td:first-child { text-align: left; }
.screener-table th:nth-child(n+4), .screener-table td:nth-child(n+4) { text-align: right; }
.screener-table th:nth-child(3), .screener-table td:nth-child(3) { min-width: 250px; text-align: left; }
.screener-table tbody tr:nth-child(even) { background-color: #f8f9fa; }
.screener-table tbody tr:hover { background-color: #eef2ff; }
.screener-table a { color: var(--primary-color); text-decoration: none; font-weight: 500; }
.screener-table a:hover { text-decoration: underline; }
.screener-table .sort-indicator { display: inline-block; margin-left: 8px; color: #343a40; opacity: 0.6; width: 1em; }
.screener-table th[data-sort-order] .sort-indicator { opacity: 1; }
.header-unit { font-size: 0.85em; font-weight: 400; color: #868e96; text-transform: none; }
.screener-table th:first-child, .screener-table td:first-child { position: -webkit-sticky; position: sticky; left: 0; z-index: 2; box-shadow: 5px 0 5px -5px rgba(0, 0, 0, 0.1); }
.screener-table th:first-child { z-index: 3; }
.screener-table td:first-child { background-color: #ffffff; }
.screener-table tbody tr:nth-child(even) td:first-child { background-color: #f8f9fa; }
.screener-table tbody tr:hover td:first-child { background-color: #eef2ff; }

/* --- ADMIN & NEW FEATURE STYLES --- */
.admin-page { background-color: var(--card-bg); padding: 2rem 3rem; border-radius: 8px; box-shadow: var(--card-shadow); max-width: 900px; margin: 40px auto; }
.admin-page h2 { color: var(--primary-color); margin-top: 0; border-bottom: 2px solid var(--border-color); padding-bottom: 0.5rem; margin-bottom: 1rem; }
.admin-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.admin-table { width: 100%; border-collapse: collapse; margin-top: 1.5rem; }
.admin-table th, .admin-table td { padding: 12px 15px; border-bottom: 1px solid var(--border-color); text-align: left; }
.admin-table th { background-color: #f8f9fa; font-weight: 600; }
.role-tag { padding: 4px 10px; border-radius: 12px; font-size: 0.8em; font-weight: 700; text-transform: uppercase; }
.role-tag.role-admin { background-color: var(--theme-green-bg); color: var(--theme-green-text); }
.role-tag.role-client { background-color: var(--theme-blue-bg); color: var(--theme-blue-text); }
.action-cell { display: flex; gap: 10px; }
.action-btn { display: inline-block; text-decoration: none; padding: 6px 14px; border-radius: 5px; font-size: 0.85em; font-weight: 600; transition: background-color 0.2s; border: none; cursor: pointer; font-family: inherit; color: white; }
.action-btn.add { background-color: var(--theme-green-text); }
.action-btn.add:hover { background-color: #46a611; }
.action-btn.edit { background-color: var(--primary-color); }
.action-btn.edit:hover { background-color: var(--accent-color); }
.action-btn.delete { background-color: #f5222d; }
.action-btn.delete:hover { background-color: #cf1322; }
.action-btn.refresh { background-color: var(--theme-blue-text); }
.action-btn.refresh:hover { background-color: #1d39c4; }
.admin-link { color: var(--accent-color); text-decoration: none; font-weight: 600; font-size: 0.85em; padding: 6px 16px; border-radius: 6px; border: 2px solid transparent; transition: all 0.2s ease-in-out; }
.admin-link:hover { background-color: var(--theme-blue-bg); border-color: var(--theme-blue-text); color: var(--theme-blue-text); }
.admin-form { margin-top: 2rem; }
.form-section { margin-bottom: 2rem; }
.form-section label { display: block; font-weight: 600; margin-bottom: 0.5rem; color: var(--primary-color); }
.form-section input[type="text"], .form-section textarea { width: 100%; padding: 10px 14px; border: 1px solid #ccc; border-radius: 6px; box-sizing: border-box; font-size: 1rem; font-family: inherit; }
.form-section input:focus, .form-section textarea:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(0, 35, 75, 0.1); }
.radio-group label, .checkbox-group label { display: block; margin-bottom: 0.75rem; font-weight: normal; color: var(--text-color); }
.radio-group input, .checkbox-group input { margin-right: 8px; transform: translateY(1px); }
.submit-btn { display: inline-block; padding: 12px 25px; background: var(--theme-green-text); color: white; border: none; border-radius: 6px; font-size: 1rem; font-weight: 600; cursor: pointer; transition: background 0.2s; }
.submit-btn:hover { background: #46a611; }
.flash-messages { margin-bottom: 1.5rem; }
.flash { padding: 1rem; border-radius: 6px; font-weight: 500; border: 1px solid transparent; }
.flash.flash-success { background-color: var(--theme-green-bg); border-color: var(--theme-green-text); color: var(--theme-green-text); }
.flash.flash-error { background-color: var(--theme-red-bg); border-color: var(--theme-red-text); color: var(--theme-red-text); }
.company-page-container .flash-messages { margin-top: 0; margin-bottom: 1.5rem; }

/* --- RESPONSIVE ADJUSTMENTS --- */
@media (max-width: 768px) {
    body { padding: 0; }
    .container { margin: 20px auto; padding: 0 15px; }
    .page-header.with-logout h1 { font-size: 1.5rem; }
    .company-page-container { padding: 1.5rem; }
    .company-header h1 { font-size: 2rem; }
    .tabs-nav { overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; padding-bottom: 10px; margin-bottom: -10px; }
    .tabs-nav::-webkit-scrollbar { display: none; }
    .tabs-nav { -ms-overflow-style: none; scrollbar-width: none; }
    .tabs-nav .tab-button { flex-shrink: 0; }
}

/* Container for the buttons in the admin header */
.admin-header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Style for the new "Rebuild All" button */
.action-btn.rebuild-all {
    background-color: var(--theme-orange-text);
}
.action-btn.rebuild-all:hover {
    background-color: #ad5306; /* Darker orange */
}

/* The List */
.comments-list {
    list-style: none;
    padding: 0;
    margin: 0 0 20px 0;
}

/* Individual Comment Card */
.comments-list li {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between; /* Content left, Menu right */
    align-items: flex-start;
    position: relative; /* For dropdown positioning */
}

.comment-content {
    flex-grow: 1;
    padding-right: 15px;
    font-size: 0.95rem;
}

.comment-content strong {
    color: var(--primary-color);
    font-weight: 600;
    margin-right: 5px;
}

/* The Input Form - Wide & Modern */
.comment-form {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.comment-form input {
    flex-grow: 1; /* Takes all available width */
    padding: 12px 15px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.comment-form input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 35, 75, 0.1);
}

.comment-form button {
    padding: 0 25px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
}

.comment-form button:hover {
    background-color: #003c7a;
}

/* --- THREE-DOT MENU STYLES --- */
.comment-menu-wrapper {
    position: relative;
    flex-shrink: 0;
}

/* The 3-dot trigger button */
.menu-dots-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.4rem;
    color: #999;
    line-height: 1;
    padding: 0 5px;
    border-radius: 4px;
}

.menu-dots-btn:hover {
    color: #333;
    background-color: #e2e6ea;
}

/* The Dropdown Content */
.menu-dropdown {
    display: none; /* Hidden by default */
    position: absolute;
    right: 0;
    top: 100%;
    background-color: white;
    min-width: 120px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-radius: 6px;
    border: 1px solid #eee;
    z-index: 100;
    overflow: hidden;
}

.menu-dropdown.show {
    display: block;
}

.menu-dropdown button {
    display: block;
    width: 100%;
    padding: 10px 15px;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    color: #333;
}

.menu-dropdown button:hover {
    background-color: #f8f9fa;
}

.menu-dropdown button.delete-btn {
    color: #dc3545;
}
.menu-dropdown button.delete-btn:hover {
    background-color: #fff5f5;
}

/* --- LOGIN PAGE STYLES --- */

.login-container {
    background: #ffffff;
    /* Increased padding creates "breathing room" */
    padding: 40px 50px; 
    border-radius: 12px;
    /* Soft, diffused shadow looks more modern than a hard shadow */
    box-shadow: 0 10px 40px rgba(0, 35, 75, 0.08);
    width: 100%;
    max-width: 400px; /* Slightly narrower makes it look tighter/neater */
    position: relative;
    overflow: hidden; /* For the accent bar */
}

/* The Accent Bar: Adds a splash of brand color at the very top */
.login-accent-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: var(--primary-color); /* Your dark blue */
}

.login-header {
    text-align: center;
    margin-bottom: 35px;
}

.login-header h1 {
    /* FIX: Reduced font size from ~28px to 24px */
    font-size: 1.5rem; 
    font-weight: 700;
    color: var(--primary-color);
    margin: 0 0 8px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* New Subtitle to balance the header visually */
.login-subtitle {
    margin: 0;
    color: #888;
    font-size: 0.9rem;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #444;
    font-size: 0.9rem;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #dde1e7;
    border-radius: 8px; /* Softer corners */
    box-sizing: border-box;
    font-size: 1rem;
    transition: all 0.2s ease;
    background-color: #fafafa;
}

.form-group input:focus {
    outline: none;
    background-color: #fff;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(0, 35, 75, 0.05);
}

.login-btn {
    width: 100%;
    padding: 14px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    margin-top: 10px;
}

.login-btn:hover {
    background-color: #003c7a;
}

.login-btn:active {
    transform: scale(0.98);
}

.error-msg {
    color: #d93025;
    background-color: #ffe6e6;
    padding: 10px;
    border-radius: 6px;
    font-size: 0.9rem;
    text-align: center;
    margin-top: 20px;
}

.login-footer {
    margin-top: 30px;
    text-align: center;
    font-size: 0.75rem;
    color: #ccc;
}

/* --- MODERN DASHBOARD STYLES --- */

/* 1. Refined Search Bar */
.search-container {
    max-width: 600px; /* Not too wide */
    margin: 0 auto 40px auto;
    position: relative;
}

#search-input {
    width: 100%;
    padding: 15px 20px;
    padding-left: 20px;
    font-size: 1rem;
    border: 1px solid #e1e4e8;
    border-radius: 50px; /* Pill shape */
    background-color: #fff;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
    transition: all 0.2s ease;
}

#search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 4px 20px rgba(0, 35, 75, 0.1);
    transform: translateY(-1px);
}

/* 2. Modern Tabs (Segmented Control style) */
.tabs-nav {
    display: inline-flex;
    background: #e9ecef;
    padding: 5px;
    border-radius: 12px;
    border: none; /* Remove old border */
    margin-bottom: 40px;
    position: relative;
    left: 50%;
    transform: translateX(-50%); /* Center the tabs */
}

.tabs-nav .tab-button {
    padding: 10px 30px;
    border-radius: 8px;
    border: none;
    background: transparent;
    font-size: 0.95rem;
    font-weight: 500;
    color: #666;
    margin: 0;
    transition: all 0.2s ease;
}

.tabs-nav .tab-button:hover {
    color: #333;
}

.tabs-nav .tab-button.active {
    background-color: #fff;
    color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    font-weight: 600;
}

/* 3. The "Ultra-Compact" Tile Card */

.card-grid {
    display: grid;
    /* Reduced width to 210px to allow 5 cards per row on desktop */
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 16px; /* Tighter gap between cards */
}

.card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    transition: all 0.2s ease-in-out;
    position: relative;
    height: 100%;
    display: flex; 
    flex-direction: column;
}

.card:hover {
    transform: translateY(-2px); /* Subtle lift */
    box-shadow: 0 4px 12px rgba(0, 35, 75, 0.08);
    border-color: var(--primary-color);
}

.card-link {
    text-decoration: none;
    color: inherit;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.card-body {
    /* Reduced padding to 16px */
    padding: 16px; 
    display: flex;
    flex-direction: column;
    height: 100%;
    box-sizing: border-box;
}

/* 1. Top Section: Symbol Badge */
.card-top {
    margin-bottom: 10px; 
    display: flex;
    justify-content: flex-start;
}

.symbol-badge {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.65rem;
    font-weight: 700;
    color: #003c7a; 
    background-color: #f0f4f8; 
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid #e1e8f0;
}

/* 2. Middle Section: Title */
.card-title {
    font-size: 0.95rem; /* Slightly smaller for density */
    font-weight: 700;
    color: #1e293b;
    line-height: 1.35;
    margin: 0;
    
    /* Push footer down, but with less force than before */
    margin-bottom: 12px; 
    
    /* Clamp to 2 lines strictly to prevent uneven row heights */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    border: none !important;
    min-height: 2.7em; /* Ensures visual consistency even for 1-line titles */
}

/* 3. Bottom Section: Action Link */
.card-footer-action {
    margin-top: auto;
    display: flex;
    align-items: center;
    /* Removed the top border for a cleaner, tighter look */
    border-top: none; 
    padding-top: 0;
    width: 100%;
}

.view-link {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0.9;
}

.arrow {
    font-size: 0.9rem;
    line-height: 1;
    margin-bottom: 1px;
}

.card:hover .view-link {
    gap: 7px;
    opacity: 1;
    text-decoration: underline;
}

/* Menu Positioning */
.card-menu {
    top: 10px;
    right: 8px;
    z-index: 5;
}
.card-menu-button {
    color: #cbd5e0;
    padding: 2px; 
}
.card-menu-button:hover {
    color: #334155;
    background-color: #f1f5f9;
    border-radius: 4px;
}
/* Position the container relative so we can place the date absolutely */
.tab-pane {
    position: relative;
    padding-top: 0; /* Remove extra top padding */
}

/* --- UPDATED REPORT DATE BADGE (Floated Box) --- */

.report-meta {
    /* 1. FIX WRAPPING: Use float instead of absolute */
    float: right;
    clear: right; /* Prevents stacking issues */
    
    /* Spacing so text doesn't touch the box */
    margin-left: 20px; 
    margin-bottom: 10px;
    margin-top: 5px; /* Visual alignment with first line of text */

    /* 2. FIX THE BOX: Unified border and background */
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 6px; /* Soft corners */
    padding: 6px 12px;
    
    /* Subtle shadow to pop it off the page */
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.meta-label {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.5px;
    
    /* 3. FIX VISIBILITY: Darker color and Bold weight */
    font-weight: 700; 
    color: #64748b; /* Distinct Slate Grey */
}

.meta-date {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: #0f172a; /* Dark text for the actual date */
    
    /* Remove the inner box styling since we boxed the whole container */
    background: none;
    border: none;
    padding: 0;
}

/* Ensure the parent container handles the float correctly */
.tab-pane::after {
    content: "";
    display: table;
    clear: both;
}

/* --- REFINED DATE STYLE: The "Dateline" Header --- */

.report-meta {
    /* 1. Layout: Block element, not floating */
    display: flex;
    justify-content: flex-end; /* Align to the right */
    align-items: center;
    gap: 8px;
    
    /* 2. Spacing: Separation from the content */
    margin-bottom: 25px; 
    padding-bottom: 10px;
    
    /* 3. The Divider: Creates a clean header area */
    border-bottom: 1px solid #f1f5f9; 
}

.meta-label {
    /* Subtle Label */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    text-transform: uppercase;
    font-size: 0.65rem;
    letter-spacing: 1px;
    font-weight: 600;
    color: #94a3b8; /* Light Grey */
}

.meta-date {
    /* Distinct Date */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569; /* Slate Grey */
}

/* --- CLEAN DATELINE (Text Only) --- */

.report-meta {
    /* Layout: Occupies its own line above the text */
    display: block; 
    text-align: right; /* Aligns to the right edge */
    
    /* Spacing: Adds a little air before the header starts */
    margin-bottom: 10px; 
    padding-bottom: 5px;
    
    /* Optional: A very subtle separator line (like a letterhead) */
    border-bottom: 1px solid #f0f0f0; 
}

.meta-label {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.75rem;
    color: #999; /* Very light grey */
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 5px;
}

.meta-date {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: #555; /* Darker grey for readability */
}

/* Update tab-pane to ensure proper stacking */
.tab-pane {
    position: relative;
    padding-top: 10px;
}

/* --- FIXED COMMENT FORM STYLES --- */

.comment-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 25px;
    background: #f8fafc;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.comment-input-wrapper {
    width: 100%;
    display: flex; /* Ensures input can grow */
}

/* Force the input to take full width */
.comment-input-wrapper input[type="text"] {
    width: 100%; 
    flex-grow: 1;
    padding: 12px 15px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 1rem;
    background-color: #ffffff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.comment-input-wrapper input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 35, 75, 0.1);
}

/* Container for Checkbox (Left) and Button (Right) */
.comment-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 5px;
}

/* Style the "Make Public" toggle */
.privacy-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #64748b;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
}

.privacy-toggle input {
    accent-color: var(--primary-color); /* Color the checkbox */
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Style the Post Button */
.comment-form button {
    padding: 10px 24px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.comment-form button:hover {
    background-color: #003c7a;
}
/* File: static/css/style.css */

/* Update the user-menu to handle multiple buttons nicely */
.user-menu { 
    position: absolute; 
    right: 0; 
    top: 50%; 
    transform: translateY(-50%); 
    display: flex; 
    align-items: center; 
    gap: 12px; /* Add space between the three buttons */
}

/* Shared style for Admin Links */
.admin-link { 
    color: var(--accent-color); 
    text-decoration: none; 
    font-weight: 600; 
    font-size: 0.85em; 
    padding: 6px 12px; 
    border-radius: 6px; 
    border: 1px solid transparent; /* Invisible border for alignment */
    transition: all 0.2s ease-in-out; 
    background-color: #f0f4f8; /* Light background to distinguish from Logout */
}

.admin-link:hover { 
    background-color: #dbeafe; 
    color: var(--primary-color);
}

/* Specific style for Analytics to make it pop slightly */
.analytics-link {
    color: var(--theme-purple-text);
    background-color: var(--theme-purple-bg);
}
.analytics-link:hover {
    background-color: #ecdffc; /* Darker purple on hover */
}
/* Add to bottom of file */

/* Download Button */
.action-btn.download-btn {
    background-color: var(--theme-purple-text);
    color: white;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-right: 10px;
}
.action-btn.download-btn:hover { background-color: #531dab; }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal-overlay.show { display: flex; }

.modal-content {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    display: flex; flex-direction: column;
}

.modal-header { padding: 15px 20px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { margin: 0; color: var(--primary-color); }
.close-modal { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #888; }
.modal-body { padding: 20px; max-height: 60vh; overflow-y: auto; }
.checkbox-list { display: flex; flex-direction: column; gap: 8px; }
.checkbox-item { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 5px 0; }
.checkbox-item:hover { background-color: #f9f9f9; }
.modal-footer { padding: 15px 20px; border-top: 1px solid #eee; display: flex; justify-content: flex-end; gap: 10px; }
.btn-cancel { padding: 10px 20px; background: #f0f0f0; border: none; border-radius: 4px; cursor: pointer; }
.btn-confirm { padding: 10px 20px; background: var(--primary-color); color: white; border: none; border-radius: 4px; cursor: pointer; }
.btn-confirm:disabled { background: #ccc; cursor: not-allowed; }
.status-msg { margin-top: 10px; text-align: center; color: #666; font-size: 0.9em; }

/* --- MODAL IMPROVEMENTS --- */

.modal-content {
    background: white;
    border-radius: 12px; /* Softer corners */
    width: 90%;
    max-width: 480px; /* Slightly narrower for better focus */
    box-shadow: 0 10px 40px rgba(0,0,0,0.25);
    display: flex; 
    flex-direction: column;
    border: none;
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: #1e293b;
    font-size: 1.25rem;
    font-weight: 600;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: #94a3b8;
    line-height: 1;
    padding: 0;
    transition: color 0.2s;
}
.close-modal:hover { color: #333; }

.modal-body {
    padding: 20px 25px;
    max-height: 60vh;
    overflow-y: auto;
    color: #475569;
}

.modal-body p { margin-top: 0; margin-bottom: 15px; font-size: 0.95rem; }

/* Checkbox List Styling */
.checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 0; /* Remove gap, handle via padding */
}

/* Draggable Items */
.checkbox-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: 6px;
    transition: background 0.15s, transform 0.1s;
    border: 1px solid transparent;
    user-select: none;
    background: #fff;
}

.checkbox-item:hover {
    background-color: #f8fafc;
    border-color: #e2e8f0;
}

/* Drag Handle */
.drag-handle {
    cursor: grab;
    color: #cbd5e1;
    margin-right: 12px;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
}
.checkbox-item:hover .drag-handle { color: #94a3b8; }
.checkbox-item.dragging { opacity: 0.5; background: #f1f5f9; }

.checkbox-item input {
    width: 18px; 
    height: 18px; 
    margin-right: 12px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.checkbox-item span { font-size: 0.95rem; color: #334155; }

/* Separator */
.modal-hr {
    border: 0;
    border-top: 1px solid #e2e8f0;
    margin: 10px 0;
}

/* Modal Footer & Buttons */
.modal-footer {
    padding: 20px 25px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    gap: 15px; /* Consistent gap */
    background-color: #f8fafc;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
}

.btn-cancel, .btn-confirm {
    flex: 1; /* Both buttons take equal width */
    padding: 12px 0;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.btn-cancel {
    background-color: #fff;
    border-color: #cbd5e1;
    color: #64748b;
}
.btn-cancel:hover { background-color: #f1f5f9; color: #334155; }

.btn-confirm {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 2px 5px rgba(0, 35, 75, 0.2);
}
.btn-confirm:hover { background-color: #003c7a; transform: translateY(-1px); }
.btn-confirm:disabled { background-color: #94a3b8; cursor: not-allowed; transform: none; box-shadow: none; }

/* --- LOADING ANIMATION --- */
.loading-overlay {
    display: none; /* Hidden by default */
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255, 255, 255, 0.9);
    z-index: 10;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e2e8f0;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text { font-weight: 600; color: var(--primary-color); }