/* Global Styles */
/*
 * FlipCheck dark theme variables.  These values define the core
 * colours used throughout the application.  A deep, near‐black
 * background provides contrast against the vibrant accent colours
 * used for calls to action and verdicts.  Cards and surfaces are
 * rendered with subtle translucency (glassmorphism) and soft
 * borders to evoke a premium feel.  If you wish to adjust the
 * palette later, update these variables rather than hard‑coding
 * colours throughout the stylesheet.
 */
:root {
    /* Base colours */
    --bg: #0d1521;               /* overall application background */
    --surface: #131c2b;          /* surfaces such as cards and form fields */
    --card-bg: rgba(255, 255, 255, 0.05); /* frosted glass cards */
    --border-color: rgba(255, 255, 255, 0.15);
    --text: #f5f5f5;             /* primary text colour */
    --text-muted: #a3b1c6;       /* secondary text colour */

    /* Brand and verdict colours */
    --primary: #00c853;          /* FlipCheck green */
    --primary-dark: #00a54f;     /* darker variant used on hover */
    --accent: #00bcd4;           /* electric blue for informational accents */
    --buy-colour: #00c853;       /* reuse primary for buy verdict */
    --offer-colour: #ffb300;     /* amber for offer verdict */
    --skip-colour: #e53935;      /* red for skip verdict */
    --deep-colour: #8e24aa;      /* purple for deep AI sections */
    --quick-colour: #00acc1;     /* cyan for quick scan */
    --standard-colour: #00c853;  /* green for standard scan */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: 16px;
}

header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(19, 28, 43, 0.9);
    backdrop-filter: blur(8px);
    color: var(--text);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 900px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Auth header area: credit display and logout */
/* Auth header: email and credits display */
#authHeader {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
}

/* Credits pill styling */
#creditDisplay {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.6rem;
    border-radius: 9999px;
    background: var(--surface);
    border: 1px solid var(--primary);
    color: var(--primary);
    font-weight: 600;
}

#creditDisplay::before {
    content: '⚡';
    margin-right: 0.25rem;
}

#userEmailDisplay {
    color: var(--text-muted);
}

/* Hide logout button via class instead of inline style */
#logoutButton.hidden {
    display: none;
}

/* Auth forms */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 400px;
}
.auth-form input {
    padding: 0.6rem;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 1rem;
}
/* Status message styling (used for auth errors and credits info).  JS
   will assign colour classes (.error, .warning, .info) as needed. */
.status-message {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
}
.status-message.error {
    color: var(--skip-colour);
}
.status-message.warning {
    color: var(--offer-colour);
}
.status-message.info {
    color: var(--accent);
}

main {
    flex: 1;
    max-width: 900px;
    margin: 0 auto;
    padding: 1rem;
}

/* Global message container near the top of the page */
#globalMessageContainer {
    margin: 0 auto 1rem;
    max-width: 900px;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(4px);
}
#globalMessage {
    color: var(--skip-colour);
    font-size: 0.9rem;
    font-weight: 500;
}

/* Interactive FlipCheck logo styling.  The logo acts as a button to return home. */
.logo {
    cursor: pointer;
    user-select: none;
    color: var(--primary);
    text-shadow: 0 0 8px rgba(0, 200, 83, 0.5);
    transition: text-shadow 0.2s ease;
}
.logo:hover {
    text-shadow: 0 0 12px rgba(0, 200, 83, 0.8);
}

/* Home page */
.home-content {
    text-align: center;
    margin-top: 3rem;
    color: var(--text);
}
.home-title {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
    color: var(--primary);
    text-shadow: 0 0 10px rgba(0, 200, 83, 0.5);
}
.tagline {
    font-size: 1.1rem;
    margin-bottom: 2.5rem;
    color: var(--text-muted);
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}
.home-buttons {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    max-width: 420px;
    margin: 0 auto;
}
.big-btn {
    width: 100%;
    padding: 1rem 1.5rem;
    font-size: 1rem;
    border-radius: 8px;
    font-weight: 600;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

/* Step indicator */
.step-indicator {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Tabs for Add Deal */
/* Tabs for Add Deal */
.tab-container {
    display: flex;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}
.tab-btn {
    flex: 1;
    padding: 0.75rem;
    text-align: center;
    cursor: pointer;
    background-color: var(--surface);
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 0.95rem;
    transition: background-color 0.2s ease;
    color: var(--text-muted);
}
.tab-btn.active {
    background-color: var(--card-bg);
    border-bottom-color: var(--primary);
    font-weight: 600;
    color: var(--primary);
}
.tab-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Image preview container */
/* Image preview */
.image-preview {
    margin-top: 1rem;
    text-align: center;
}
.image-preview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}
.image-preview p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

/* Upload options: display camera and gallery buttons side-by-side */
.upload-options {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}
.upload-options .primary-btn.small {
    flex: 1;
    padding: 0.45rem 0.75rem;
    font-size: 0.9rem;
    line-height: 1.2;
}

/* Navigation buttons (generic) */
.navigation-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 1.5rem;
    gap: 0.5rem;
}

/* Toggle cards for buy/sell methods */
/* Toggle cards (buy/sell method selection) */
.toggle-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.toggle-card {
    flex: 1;
    padding: 0.75rem;
    background-color: var(--surface);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-muted);
}
.toggle-card h4 {
    margin-bottom: 0.25rem;
    font-size: 1rem;
    color: var(--primary);
}
.toggle-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
}
.toggle-card.active {
    border-color: var(--primary);
    background-color: rgba(0, 200, 83, 0.1);
    color: var(--primary);
}
.toggle-card:hover {
    border-color: var(--primary);
}

/* Preset buttons */
.preset-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

/* Loading overlay styles */
/* Loading overlay styles */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(6px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 2rem;
    text-align: center;
    font-size: 1rem;
    color: var(--text);
}

.loader {
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.preset-btn {
    flex: 1;
    padding: 0.6rem;
    border: 1px solid var(--primary);
    border-radius: 6px;
    background-color: #fff;
    color: var(--primary);
    cursor: pointer;
    font-size: 0.85rem;
    text-align: center;
    transition: background-color 0.2s ease;
}
.preset-btn:hover {
    background-color: #f1f8e9;
}

/* Cost fields layout */
.cost-fields {
    margin-top: 1rem;
}

/* Scan type cards */
/* Scan card group */
.scan-card-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}
/* Base styling for each scan card.  Cards use surface colours and
   highlight the selection with bright backgrounds and border colours. */
.scan-card {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--surface);
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-muted);
    min-width: 160px;
}
.scan-card h4 {
    margin-bottom: 0.25rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
}
.scan-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
}
/* Colour variants for each scan card using data attributes */
.scan-card[data-scan="quick"] {
    border-color: var(--quick-colour);
}
.scan-card[data-scan="quick"].selected {
    background-color: rgba(0, 172, 193, 0.2);
    border-color: var(--quick-colour);
    color: var(--quick-colour);
}
.scan-card[data-scan="standard"] {
    border-color: var(--standard-colour);
}
.scan-card[data-scan="standard"].selected {
    background-color: rgba(0, 200, 83, 0.2);
    border-color: var(--standard-colour);
    color: var(--standard-colour);
}
.scan-card[data-scan="deep"] {
    border-color: var(--deep-colour);
}
.scan-card[data-scan="deep"].selected {
    background-color: rgba(142, 36, 170, 0.25);
    border-color: var(--deep-colour);
    color: var(--deep-colour);
}
.scan-card:hover {
    border-color: var(--primary);
    background-color: rgba(255, 255, 255, 0.05);
}

/* Result actions */
.result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: space-between;
    margin-top: 1.5rem;
}
.result-actions button {
    flex: 1;
    min-width: 120px;
}

/* Listing page styling */
#listingPage .card {
    background-color: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

/* Mobile responsiveness for new elements */
@media (max-width: 600px) {
    .home-buttons {
        max-width: 100%;
    }
    .toggle-group, .scan-card-group {
        flex-direction: column;
    }
    .navigation-buttons {
        flex-direction: column;
    }
    .navigation-buttons button {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    .result-actions button {
        width: 100%;
    }
}

footer {
    background-color: var(--primary-dark);
    color: #fff;
    text-align: center;
    padding: 0.5rem 0;
}

/* Page handling */
.page {
    display: none;
}

.page.active {
    display: block;
}

.hidden {
    display: none;
}

/* Typography */
h1 {
    font-size: 2rem;
    margin: 0;
}

h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

p {
    margin-bottom: 1rem;
}

/* Buttons */
/* Base button styling.  Buttons use gradients and subtle shadows
   to stand out against the dark background.  Primary buttons use the
   brand colour; secondary buttons are outlined and invert on hover. */
.primary-btn, .secondary-btn {
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    border-radius: 8px;
    cursor: pointer;
    margin: 0.25rem 0.5rem;
    font-weight: 600;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    user-select: none;
}

.primary-btn {
    background-image: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.primary-btn:hover {
    background-image: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}

.primary-btn:disabled {
    background-image: none;
    background-color: #3c4b5c;
    color: #7c8ca3;
    cursor: not-allowed;
    box-shadow: none;
}

.secondary-btn {
    background-color: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.secondary-btn:hover {
    background-color: rgba(0, 200, 83, 0.1);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}

.secondary-btn:disabled {
    border-color: #3c4b5c;
    color: #7c8ca3;
    cursor: not-allowed;
    background-color: transparent;
    box-shadow: none;
}

.btn-group {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    margin-top: 1rem;
}

/* Forms */
.input-group {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
}

.input-group label {
    margin-bottom: 0.25rem;
    font-weight: 500;
}

/* Inputs and textareas use surface colours and light borders */
.input-group input,
.input-group select,
.input-group textarea {
    padding: 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background-color: var(--surface);
    color: var(--text);
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.input-group input::placeholder,
.input-group textarea::placeholder {
    color: var(--text-muted);
}

.input-group input:focus,
.input-group textarea:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(0, 200, 83, 0.2);
}

.input-group textarea {
    resize: vertical;
    min-height: 80px;
}

.secondary-links {
    margin-top: 1.5rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
}

/* Result cards for the result page.  Cards have a translucent dark
   surface, soft borders, and a subtle shadow.  The left border
   colour is set via verdict classes (see summary-* classes below). */
.result-card {
    background-color: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
    transition: border-left 0.3s ease, background-color 0.3s ease;
    color: var(--text);
}

.result-card h3 {
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary);
}

.result-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    color: var(--text);
}

/* Scan type buttons */
.scan-options {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}
.scan-btn {
    flex: 1;
    padding: 0.6rem 0.8rem;
    border: 2px solid var(--primary);
    border-radius: 6px;
    background-color: #fff;
    color: var(--primary);
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}
.scan-btn:hover {
    background-color: #f1f8e9;
}
.scan-btn.selected {
    background-color: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.scan-description {
    font-size: 0.85rem;
    color: #555;
    margin-top: 0.5rem;
    margin-bottom: 1rem;
}

/* Result cards sections */
#resultPage .result-card {
    margin-bottom: 1rem;
}
#resultPage .result-card h3 {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}
#resultPage .result-card p, #resultPage .result-card ul {
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
    line-height: 1.4;
}
#resultPage .result-card ul {
    padding-left: 1.25rem;
}

/* Colour-coded summary card borders based on verdict */
/* Colour-coded summary card borders and background tints.  Each verdict
   class also lightly tints the card background to hint at the outcome. */
.summary-buy {
    border-left: 6px solid var(--buy-colour);
    background-color: rgba(0, 200, 83, 0.15);
}
.summary-offer {
    border-left: 6px solid var(--offer-colour);
    background-color: rgba(255, 179, 0, 0.15);
}
.summary-skip {
    border-left: 6px solid var(--skip-colour);
    background-color: rgba(229, 57, 53, 0.15);
}
.summary-unknown {
    border-left: 6px solid var(--border-color);
    background-color: rgba(255, 255, 255, 0.05);
}

/* Copy button style */
/* Inline copy buttons used inside result sections */
.copy-btn {
    display: inline-block;
    margin-left: 0.5rem;
    font-size: 0.8rem;
    color: var(--accent);
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
    transition: color 0.2s ease;
}
.copy-btn:hover {
    color: var(--primary);
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Hide modals when they have the hidden class */
.modal.hidden {
    display: none;
}

/* Modal content with dark theme */
.modal-content {
    background-color: var(--surface);
    padding: 1.5rem;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    color: var(--text);
    white-space: pre-wrap;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}

/* Saved Deals */
#savedDealsContainer {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Saved deal card styling */
.saved-card {
    background-color: var(--surface);
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.saved-card button {
    margin-left: 0.5rem;
}

@media (max-width: 600px) {
    header .container, main, footer .container {
        padding: 0 1rem;
    }
    .btn-group {
        flex-direction: column;
        align-items: stretch;
    }
    .primary-btn, .secondary-btn {
        width: 100%;
        margin: 0.25rem 0;
    }
}