/* Global Styles */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap');

body {
  margin: 0;
  min-height: 100vh;
  /* Using width instead of min-width to avoid overflow issues with some viewport sizes */
  width: 100vw;
  display: flex;
  flex-direction: column;
  justify-content: flex-start; /* Aligns content to the top */
  align-items: center;
  font-family: 'DM Sans', sans-serif;
  color: #ffffff;
  overflow-x: hidden; /* Prevent horizontal scrollbar from gradient animation */
  position: relative; /* Needed for z-indexing context */
  letter-spacing: -0.02em;
}

/* Animated Gradient Background - apply to body */
body.gradient-background {
  background: linear-gradient(295deg,#001028,#003852,#012b50);
/*   background: linear-gradient(295deg,#001028,#003852,#012b50);  */
  background-size: 180% 180%;
  animation: gradient-animation 20s ease infinite;
}

@keyframes gradient-animation {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Home page specific background image */
body.home-background::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('/static/AIGIRL.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0.10;
    z-index: -1; /* Place it behind the content */
}


/* Make sure content is above the background image pseudo-element */
.container, h1, .login-container {
    z-index: 2;
}

/* Vexel-inspired styles */
.container {
  width: 80%; /* Adjusted from 90% to match guided_learning/results */
  max-width: 900px; /* Adjusted to match results */
  padding: 40px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 15px;
  margin: 20px auto;
}

.container-full-width {
    width: calc(100% - 20px);
    margin: 20px 10px;
    padding: 40px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 15px;
    box-sizing: border-box;
}

.light-theme {
    background-color: #fff;
    color: #333;
}

.light-theme h1, .light-theme h2, .light-theme h3, .light-theme p {
    color: #333;
}

.light-theme a {
    color: #007bff;
}

h1, h2, h3 {
  color: #ffffff;
  text-align: center;
  font-weight: 400;
  margin-bottom: 20px;
  letter-spacing: 0.01em;
}

button, .button, input[type="submit"] {
  background-color: transparent;
  color: white;
  border: 1px solid white;
  padding: 12px 24px;
  font-size: 1.1em;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.3s ease;
  text-decoration: none; /* For <a> tags styled as buttons */
  display: inline-block; /* For <a> tags */
}

button:hover:not(:disabled), .button:hover, input[type="submit"]:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Styles from guided_learning.html & results.html */
textarea {
    width: 100%;
    box-sizing: border-box; /* Include padding and border in the element's total width and height */
    margin-bottom: 20px;
    padding: 10px;
    font-size: 1em;
    background-color: rgba(0, 0, 0, 0.2);
    color: white;
    border: 1px solid rgba(102, 153, 204, 0.5);
    border-radius: 5px;
    min-height: 250px;
    resize: vertical;
}

/* Dark-transparent treatment for tables/results */
.result-section {
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.2);
    padding: 20px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

h2 {
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 5px;
}

.content {
    background-color: transparent;
    padding: 15px;
    border-radius: 5px;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

a {
    color: #ffffff;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}


/* Login form styles from index.html */
.login-container {
    position: absolute;
    top: 50px;
    right: 50px;
    display: flex;
    align-items: center;
}

.login-button {
    padding: 10px 20px;
    font-size: 1.2em;
}

.login-form {
    display: none;
    margin-right: 10px;
}

.login-form input[type="text"], .login-form input[type="password"] {
    padding: 10px;
    font-size: 1em;
    margin-right: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    background-color: rgba(255, 255, 255, 0.9);
}

.show-form .login-button {
    display: none;
}

.show-form .login-form {
    display: flex;
}

/* Custom Tooltip */
.custom-tooltip {
    position: absolute;
    display: none;
    background-color: #336699;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #003366;
    z-index: 1000;
    pointer-events: none;
    font-size: 0.9em;
    white-space: nowrap; /* Prevent title from wrapping */
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

/* Flash Messages */
.flashes {
    list-style-type: none;
    padding: 0;
    margin: 0 0 20px 0;
}
.flash {
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 5px;
}
.flash.success {
    background-color: rgba(0, 255, 0, 0.1);
    border: 1px solid rgba(0, 255, 0, 0.2);
    color: white;
}
.flash.warning {
    background-color: rgba(255, 255, 0, 0.1);
    border: 1px solid rgba(255, 255, 0, 0.2);
    color: white;
}
.flash.error {
    background-color: rgba(255, 0, 0, 0.1);
    border: 1px solid rgba(255, 0, 0, 0.2);
    color: white;
}

/* Status Message Box */
.status-message {
    background-color: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 15px;
    border-radius: 5px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Spinner/Progress */
.progress-container {
    display: none;
    text-align: center;
    margin: 0 10px;
}
.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
    margin: auto;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Special Buttons */
button.clear-session {
    border-color: #CC6666;
}
button.clear-session:hover:not(:disabled) {
    background-color: rgba(255, 0, 0, 0.1);
    border-color: #ff4d4d;
}
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Responsive Styles */
@media (max-width: 600px) {
    body {
        justify-content: flex-start; /* Align content to the top on small screens */
        padding-top: 5vh;
    }
    #agent-arbitrage-h1 {
        font-size: 10vw;
        max-width: 90vw;
        padding: 10px;
    }
    .login-container {
        top: 10px;
        right: 10px;
        flex-direction: column;
        gap: 10px;
        position: static; /* Let it flow with the content */
        margin-top: 20px;
    }
    .login-button, .login-form button {
        width: 200px;
    }
    .login-form {
        margin-right: 0;
        flex-direction: column;
        gap: 10px;
    }
    .login-form input {
        width: 200px;
        font-size: 0.9em;
        margin-right: 0;
    }
    .container {
        width: 95%;
        padding: 20px;
    }
}

/* --- New Header Styles (Absolute Centering) --- */
.main-header {
    position: relative;
    width: 100%;
    /* The padding sets the height and pushes down the .container */
    padding: 47.5px 0;
    box-sizing: border-box;
}

.header-brand {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: 40px;
    display: flex;
    align-items: center;
    z-index: 10;
}

.main-header nav.main-nav {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    white-space: nowrap;
}

.header-logout {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: 40px;
    z-index: 10;
}


.header-logo img {
    height: 25px;
    margin-right: 15px;
}

.header-wordmark {
    font-family: 'Saira', sans-serif;
    font-weight: 400;
    text-transform: uppercase;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.6) 0%,
        rgba(255, 255, 255, 0.6) 40%,
        rgba(255, 255, 255, 1.0) 50%,
        rgba(255, 255, 255, 0.6) 60%,
        rgba(255, 255, 255, 0.6) 100%
    );
    background-size: 200% 100%;
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    animation: shine-slow 12s linear infinite;
    font-size: 20px;
    line-height: 1;
    white-space: nowrap;
}

/* Deals Dashboard Table Styles */
#deals-table {
    width: 100%;
    border-spacing: 0; /* Set spacing to 0 */
    border-collapse: separate; /* Use separate model for manual control */
    font-family: 'Roboto', sans-serif;
}

#deals-table th, #deals-table td {
    padding: 8px;
    text-align: left;
    /* Set border on bottom and right of each cell */
    border-bottom: 1px solid rgba(102, 153, 204, 0.4);
    border-right: 1px solid rgba(102, 153, 204, 0.4);
    border-top: 0;
    border-left: 0;
}

/* Add top border to all header cells */
#deals-table th {
    border-top: 1px solid rgba(102, 153, 204, 0.4);
}

/* Add left border to the first cell of each row */
#deals-table tr > th:first-child,
#deals-table tr > td:first-child {
    border-left: 1px solid rgba(102, 153, 204, 0.4);
}

#deals-table th {
    background-color: rgba(0, 0, 0, 0.2);
    color: white;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}

#deals-table .group-header th {
    background-color: #26567e;
    color: #75afd1;
    font-size: 110%;
    border-top: 1px solid #6194c3;
    border-left: 1px solid #6194c3;
    border-right: 1px solid #6194c3;
    border-bottom: 1px solid #6194c3;
    height: 44px !important;
    padding: 0 8px !important;
    box-sizing: border-box !important;
}

#deals-table td {
    font-size: 14px;
    font-weight: 300;
}

.deal-row:hover td {
    background-color: rgba(102, 153, 204, 0.15);
}

#deals-table th {
    cursor: default; /* Remove pointer cursor from headers */
}

#deals-table .sort-arrows-row {
    height: 18px;
    max-height: 18px;
}

#deals-table .sort-arrows-row td {
    background-color: #011b2a;
    height: 18px !important;
    max-height: 18px !important;
    padding: 0 8px !important;
    line-height: 18px;
    border-right: none !important;
    border-left: none !important;
    /* The bottom border is inherited from the default td style, which is correct */
}

/* Add ONLY the outer borders back to the row */
#deals-table .sort-arrows-row > td:first-child {
    border-left: 1px solid rgba(102, 153, 204, 0.4) !important;
}
#deals-table .sort-arrows-row > td:last-child {
    border-right: 1px solid rgba(102, 153, 204, 0.4) !important;
}

.sort-arrows-container {
    display: flex;
    align-items: center;
    height: 18px;
}

.sort-arrow {
    width: 24px;
    height: 13px;
    cursor: pointer;
    margin-right: 2px;
}

.buy-now-link {
    display: block;
    text-align: center;
    text-decoration: none;
    font-size: 1.2em;
    color: rgba(102, 153, 204, 0.8); 
    text-shadow: 0 0 2px rgba(102, 153, 204, 0.5);
}

.buy-now-link:hover, .best-price-link:hover {
    text-decoration: none;
}

.trust-suffix, .time-suffix {
    font-size: 90%;
    vertical-align: baseline;
    color: rgba(102, 153, 204, 0.9);
}

.pagination-controls {
    margin-top: 20px;
    text-align: center;
}
.pagination-controls button {
    padding: 8px 16px;
    margin: 0 5px;
}
.title-cell, .seller-cell, .genre-cell {
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.season-detail-cell {
    max-width: 175px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* New Dashboard Layout Styles */
.dashboard-content-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center; /* Center the content horizontally */
    width: 100%;
}

.deal-counter-container {
    width: 100%;
    max-width: 1800px; /* Match table width */
    text-align: left;
    margin-top: 10px; /* Reduced top margin to match bottom margin */
    margin-bottom: 10px;
    padding-left: 10px; /* Align with table padding */
}

#deal-counter {
    font-size: 16px; /* Match header font size */
    font-weight: bold; /* Match header font weight */
    color: #c5c5c5; /* Match header font color */
}

.table-container {
    width: auto; /* Allow table to define its own width */
    max-width: 100%; /* Prevent overflow on small screens */
    overflow-x: auto; /* Add horizontal scroll if needed */
}

/* New Filter Styles */
.filters-container {
    width: 100%;
    margin-bottom: 40px; /* Padding between filters and table */
    display: flex;
    justify-content: center; /* Center the filter form */
}

#filter-form {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    width: 100%;
    max-width: 1800px; /* Match a reasonable max table width */
    gap: 20px;
}

.filter-group-left {
    display: flex;
    align-items: flex-end;
    gap: 20px;
    flex-wrap: wrap;
}

.filter-item {
    display: flex;
    flex-direction: column;
}

.filter-item label {
    margin-bottom: 8px;
    font-size: 14px;
    height: 1.2em; /* Give label a fixed height */
    display: flex;
    align-items: flex-end; /* Align text to the bottom of the label box */
}

.filter-item .slider-container, .filter-item .styled-text-field {
    height: 30px; /* Ensure all input containers have same height */
    display: flex;
    align-items: center; /* Vertically center the slider/input within the container */
}

.filter-item label {
    margin-bottom: 8px;
    font-size: 14px;
}

.styled-text-field {
    width: 200px;
    height: 30px;
    padding: 0 10px;
    background-color: rgba(0, 0, 0, 0.2);
    color: white;
    border: 1px solid rgba(102, 153, 204, 0.5);
    border-radius: 5px;
    font-size: 1em;
    box-sizing: border-box;
}

.slider-container {
    width: 200px;
}

#sales-rank-value, #profit-margin-value {
    padding-left: 20px;
    color: rgba(102, 153, 204, 0.9);
}

.slider {
  -webkit-appearance: none;
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.3);
  outline: none;
  opacity: 0.7;
  transition: opacity .2s;
  border-radius: 4px;
  border: 1px solid rgba(102, 153, 204, 0.5);
}

.slider:hover {
  opacity: 1;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: #336699;
  cursor: pointer;
  border-radius: 50%;
  border: 1px solid #003366;
}

.slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: #336699;
  cursor: pointer;
  border-radius: 50%;
  border: 1px solid #003366;
}

.filter-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    /* margin-left: auto; is no longer needed */
}

.filter-buttons button {
    padding: 6px 12px;
    font-size: 1em;
}

/* --- Video Background Styles --- */
#background-video {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    z-index: -2;
    object-fit: cover;
    opacity: 0.10;
}

/* Hide the original background image on home page to prefer video */
body.home-background::before {
    background-image: none !important;
}

@keyframes shine-slow {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.main-header nav.main-nav a {
    display: inline-block;
    margin: 0 15px; /* 30px space */
}

/* --- Index Page Brand Styles --- */
.index-brand {
    position: absolute;
    top: 50px;
    left: 50px;
    display: flex;
    align-items: center;
}

.index-logo {
    height: 64px;
    margin-right: 26px; /* Moved closer */
}

.index-wordmark {
    font-family: 'Saira', sans-serif;
    font-weight: 400;
    text-transform: uppercase;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.6) 0%, /* Lighter color treatment */
        rgba(255, 255, 255, 0.6) 40%,
        rgba(255, 255, 255, 1.0) 50%,
        rgba(255, 255, 255, 0.6) 60%,
        rgba(255, 255, 255, 0.6) 100%
    );
    background-size: 200% 100%;
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    animation: shine-slow 12s linear infinite;
    font-size: 45px; /* New size */
    line-height: 1;
    white-space: nowrap;
}
