/* =========================================================================
   RiskWatch — Frontend Prototype
   Shared external stylesheet for all 5 pages
   ========================================================================= */

/* CSS Reset: clear default browser spacing and use border-box so that
   padding and border are included in an element's width (Box Model) */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* System font stack: each device uses its own built-in UI font
   (San Francisco on Mac/iPhone, Segoe UI on Windows, Roboto on Android),
   falling back to Arial if none of those exist */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #1f2937;
    background-color: #f6f8fb;
    line-height: 1.6;
}

a {
    color: #2a6f97;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

h1, h2, h3 {
    color: #1d3557;
}

ul {
    list-style: none;
}

/* -------------------------------------------------------------------------
   Navbar
   ------------------------------------------------------------------------- */
/* Using Flexbox to push the logo to one side and links to the other.
   A white bar with a thin border and soft shadow separates it from the page. */
.navbar {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    background-color: white;
    border-bottom: 1px solid #e5e9f0;
    box-shadow: 0 1px 6px rgba(16, 24, 40, 0.06);
    padding: 12px 6%;
    position: relative;
}

/* Logo mark and name side by side */
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #1d3557;
    font-size: 20px;
    font-weight: bold;
}

.logo:hover {
    text-decoration: none;
}

/* Small rounded square with an "R", used as a simple logo */
.logo-mark {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background-image: linear-gradient(135deg, #2a6f97, #1d3557);
    color: white;
    font-size: 16px;
}

.nav-links {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
}

/* Each link is a rounded "pill" so hover and active states have a shape */
.nav-links a {
    display: block;
    color: #4b5563;
    font-size: 15px;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 20px;
}

.nav-links a:hover {
    background-color: #f1f5f9;
    color: #1d3557;
    text-decoration: none;
}

/* Tinted pill marks the page the user is on right now */
.nav-links a.active {
    background-color: #e6f0f7;
    color: #2a6f97;
}

/* Hamburger button: hidden by default, only shown on small screens */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 28px;
    height: 20px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.nav-toggle .bar {
    width: 100%;
    height: 3px;
    border-radius: 2px;
    background-color: #1d3557;
}

/* -------------------------------------------------------------------------
   Page header (the title banner under the navbar on every page)
   ------------------------------------------------------------------------- */
.page-header {
    background-image: linear-gradient(135deg, #1d3557, #2a6f97);
    color: white;
    padding: 56px 6%;
    text-align: center;
}

/* Slightly tighter letter spacing makes big headings look cleaner */
.page-header h1 {
    color: white;
    font-size: 36px;
    letter-spacing: -0.5px;
    margin-bottom: 8px;
}

/* rgba(255, 255, 255, 0.85) = white at 85% opacity, so the tagline looks
   a little softer than the heading */
.tagline {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.85);
}

/* -------------------------------------------------------------------------
   Search form (home page banner)
   ------------------------------------------------------------------------- */
.search-form {
    max-width: 600px;
    margin: 24px auto 0 auto;
    text-align: left;
}

.search-form label {
    display: block;
    font-weight: bold;
    margin-bottom: 6px;
}

/* Input stretches to fill the row; the button keeps its own size */
.search-row {
    display: flex;
    flex-direction: row;
    gap: 10px;
}

.search-row input {
    flex: 1;
    font-family: inherit;
    font-size: 16px;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(16, 24, 40, 0.15);
}

.search-row input:focus {
    outline: 2px solid #a8dadc;
}

/* -------------------------------------------------------------------------
   Page sections
   ------------------------------------------------------------------------- */
/* max-width + margin: 0 auto keeps the content centered on wide screens */
.section {
    max-width: 1000px;
    margin: 0 auto;
    padding: 40px 6%;
}

.section h2 {
    font-size: 22px;
    letter-spacing: -0.3px;
    margin-bottom: 18px;
}

.section p {
    margin-bottom: 12px;
}

/* -------------------------------------------------------------------------
   Buttons (used on links and <button> elements alike)
   ------------------------------------------------------------------------- */
.btn {
    display: inline-block;
    padding: 10px 22px;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    background-color: #2a6f97;
    color: white;
}

.btn-primary:hover {
    background-color: #1d3557;
}

.btn-secondary {
    background-color: #eef2f7;
    color: #1d3557;
}

.btn-secondary:hover {
    background-color: #dfe6ef;
}

/* Red button for actions that take something away (Remove, Delete) */
.btn-danger {
    background-color: #fbe3e3;
    color: #a12622;
}

.btn-danger:hover {
    background-color: #f5c6c6;
}

/* -------------------------------------------------------------------------
   Company cards (home page)
   ------------------------------------------------------------------------- */
/* flex-wrap lets the cards drop to the next line instead of shrinking forever */
.card-row {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 20px;
}

.company-card {
    flex: 1 1 260px;
    padding: 22px;
}

/* Shared "card" look: white, rounded corners, light border, soft shadow.
   Grouping the selectors keeps every card on every page consistent. */
.company-card,
.result-item,
.report-item,
.compare-panel,
.form-panel,
.change-row,
.note-card,
.table-wrapper {
    background-color: white;
    border: 1px solid #e5e9f0;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.06);
}

.company-card h3 {
    font-size: 18px;
}

.card-meta {
    color: #5c6b7a;
    font-size: 14px;
}

/* -------------------------------------------------------------------------
   Search results (search.html)
   ------------------------------------------------------------------------- */
.result-count {
    color: #5c6b7a;
}

/* Details on the left, Open button on the right */
.result-item {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    margin-bottom: 12px;
}

.result-item h3 {
    font-size: 18px;
}

.result-item .card-meta {
    margin-bottom: 0;
}

/* -------------------------------------------------------------------------
   Company page (company.html)
   ------------------------------------------------------------------------- */
/* Space between the tagline and the Add to Watchlist button in the banner.
   Uses the id so the search buttons in other banners are not pushed down. */
#watchlist-btn {
    margin-top: 16px;
}

.watchlist-message {
    margin-top: 10px;
    min-height: 20px;
    font-size: 14px;
}

/* Report list takes about two thirds, compare panel one third */
.company-layout {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 30px;
}

.report-column {
    flex: 2;
}

.compare-panel {
    flex: 1;
}

/* Padding for the boxed forms (compare panel, add-note form) */
.compare-panel,
.form-panel {
    padding: 22px;
}

/* Smaller heading inside the panel */
.compare-panel h2 {
    font-size: 19px;
}

.report-item {
    padding: 14px 18px;
    margin-bottom: 12px;
}

/* Report details on the left, Read risks button on the right */
.report-row {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.report-row h3 {
    font-size: 17px;
}

.report-row .card-meta {
    margin-bottom: 0;
}

.risk-list {
    margin-top: 14px;
    border-top: 1px solid #e3e8ef;
    padding-top: 14px;
}

.risk-paragraph {
    border-left: 3px solid #c9d6e3;
    padding-left: 12px;
    margin-bottom: 14px;
}

.risk-paragraph h4 {
    color: #1d3557;
}

/* Used by main.js to hide anything (risk lists, buttons, whole sections).
   It comes after .btn and .company-layout on purpose: same specificity,
   so the later rule wins the cascade (no !important needed). */
.hidden {
    display: none;
}

/* -------------------------------------------------------------------------
   Forms (compare form, note forms)
   ------------------------------------------------------------------------- */
/* Label above its field, same pattern as the portfolio contact form */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.form-group label {
    font-weight: bold;
    color: #1d3557;
}

.form-group input,
.form-group select,
.form-group textarea {
    font-family: inherit;
    font-size: 15px;
    padding: 9px 12px;
    border: 1px solid #d0d7e2;
    border-radius: 8px;
    background-color: white;
    /* A dropdown is as wide as its longest option by default; this keeps
       long options (like change titles) from pushing past the screen edge */
    max-width: 100%;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #2a6f97;
}

.error-message {
    color: #b3261e;
    font-size: 14px;
    margin-top: 10px;
}

/* -------------------------------------------------------------------------
   Change badges and colors (shared by every page that shows changes)
   Green = new, red = removed, yellow = edited
   ------------------------------------------------------------------------- */
.badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.badge {
    font-size: 13px;
    font-weight: bold;
    padding: 3px 10px;
    border-radius: 12px;
}

.badge-new {
    background-color: #e3f4e1;
    color: #2e6b2f;
}

.badge-removed {
    background-color: #fbe3e3;
    color: #a12622;
}

.badge-edited {
    background-color: #fff4cc;
    color: #7a5b00;
}

.badge-unchanged {
    background-color: #e3e8ef;
    color: #45556a;
}

.badge-important {
    background-color: #1d3557;
    color: white;
}

/* -------------------------------------------------------------------------
   Compare page (compare.html)
   ------------------------------------------------------------------------- */
/* Company dropdown and its button sit on one line */
.picker-form {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 30px;
}

.picker-form .form-group {
    margin-bottom: 0;
}

/* Four count boxes that share the row evenly and wrap on small screens */
.summary-row {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 20px;
}

.summary-box {
    flex: 1 1 140px;
    text-align: center;
    font-weight: bold;
    padding: 16px;
    border-radius: 12px;
}

/* Overrides ".section p" spacing so the boxes line up */
.section .summary-box {
    margin-bottom: 0;
}

.summary-number {
    display: block;
    font-size: 30px;
}

.filter-row {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.filter-label {
    font-weight: bold;
    color: #1d3557;
}

.filter-btn {
    font-family: inherit;
    font-size: 15px;
    padding: 6px 16px;
    border: 1px solid #2a6f97;
    border-radius: 20px;
    background-color: white;
    color: #2a6f97;
    cursor: pointer;
}

.filter-btn:hover {
    background-color: #eef2f7;
}

/* The filter that is currently on */
.filter-btn.active-filter {
    background-color: #2a6f97;
    color: white;
}

/* One row per risk paragraph. The colored left border and the light
   background both come from the status class below. */
.change-row {
    border-left: 5px solid #c9d6e3;
    padding: 16px 20px;
    margin-bottom: 16px;
}

.change-new {
    border-left-color: #2e7d32;
    background-color: #f3fbf2;
}

.change-removed {
    border-left-color: #c62828;
    background-color: #fdf3f3;
}

.change-edited {
    border-left-color: #d4a017;
    background-color: #fffbea;
}

/* Badge, then the title (which takes the extra space), then "+ Note" */
.change-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.change-header h3 {
    flex: 1;
    font-size: 17px;
}

.note-btn {
    padding: 6px 14px;
    font-size: 14px;
}

/* Older report on the left, newer report on the right */
.change-sides {
    display: flex;
    flex-direction: row;
    gap: 20px;
}

.change-side {
    flex: 1;
}

.side-label {
    font-size: 13px;
    font-weight: bold;
    color: #5c6b7a;
}

.section .side-label {
    margin-bottom: 4px;
}

.empty-side {
    font-style: italic;
    color: #7a8794;
}

.note-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    background-color: white;
    border: 1px dashed #c9d6e3;
    border-radius: 8px;
    padding: 8px 12px;
    margin-top: 10px;
}

.section .note-item p {
    margin-bottom: 0;
}

.note-form {
    margin-top: 14px;
    max-width: 500px;
}

/* -------------------------------------------------------------------------
   Watchlist & Notes page (watchlist.html)
   ------------------------------------------------------------------------- */
/* Only the table scrolls sideways if it is too wide, not the whole page.
   The wrapper also carries the card look (rounded corners), because a
   table with border-collapse can't round its own corners. */
.table-wrapper {
    overflow-x: auto;
}

.watchlist-table {
    width: 100%;
    border-collapse: collapse;
}

.watchlist-table th,
.watchlist-table td {
    text-align: left;
    padding: 12px 14px;
    border-bottom: 1px solid #e3e8ef;
}

.watchlist-table th {
    background-color: #f6f8fb;
    color: #4b5563;
    font-size: 13px;
}

/* The badges already have a bottom margin for cards; not needed in a cell */
.watchlist-table .badges {
    margin-bottom: 0;
}

.table-actions,
.note-actions {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
}

.table-actions .btn,
.note-actions .btn {
    padding: 6px 14px;
    font-size: 14px;
}

.empty-message {
    font-style: italic;
    color: #5c6b7a;
}

.form-panel {
    max-width: 600px;
    margin-bottom: 30px;
}

.form-panel h3 {
    margin-bottom: 12px;
}

.note-card {
    padding: 16px 20px;
    margin-bottom: 14px;
}

/* Status badge, then the title (which takes the extra space), then Important */
.note-card-header {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.note-card-header h3 {
    flex: 1;
    font-size: 16px;
}

.note-edit-form {
    max-width: 600px;
}

/* -------------------------------------------------------------------------
   Footer
   ------------------------------------------------------------------------- */
/* Light footer with a thin top border, matching the white navbar */
.site-footer {
    background-color: white;
    border-top: 1px solid #e5e9f0;
    color: #4b5563;
    font-size: 14px;
    text-align: center;
    padding: 24px 6%;
    margin-top: 40px;
}

.footer-note {
    font-size: 13px;
    color: #6b7280;
}

/* -------------------------------------------------------------------------
   Responsive design
   ------------------------------------------------------------------------- */
@media (max-width: 700px) {
    .nav-toggle {
        display: flex;
    }

    .nav-links {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background-color: white;
        border-bottom: 1px solid #e5e9f0;
        box-shadow: 0 8px 16px rgba(16, 24, 40, 0.08);
        padding: 10px 6%;
        gap: 4px;
        align-items: stretch;
        z-index: 10;
    }

    /* main.js toggles this class on click to show/hide the mobile menu */
    .nav-links.show {
        display: flex;
    }

    .page-header h1 {
        font-size: 28px;
    }

    /* Stack the result details above the button on narrow screens */
    .result-item,
    .report-row {
        flex-direction: column;
        align-items: flex-start;
    }

    /* Compare panel drops below the report list; align-items: stretch
       makes both columns full width again */
    .company-layout {
        flex-direction: column;
        align-items: stretch;
    }

    /* Older and newer text stack instead of squeezing side by side */
    .change-sides {
        flex-direction: column;
        gap: 10px;
    }

    .change-header {
        flex-wrap: wrap;
    }

    /* Tighter table cells so all four columns fit on a phone */
    .watchlist-table th,
    .watchlist-table td {
        padding: 8px;
        font-size: 14px;
    }
}
