/* app/static/css/main.css */

/* Global Styles */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #333;
    background-color: #f8f9fa;
    padding-top: 56px; /* Add padding to account for fixed navbar */
}

/* Make navbar fixed at top */
.navbar {
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1030; /* Ensure navbar stays on top of other content */
}

/* Navbar */
.navbar-brand {
    font-weight: 700;
}

.profile-pic-small {
    width: 25px;
    height: 25px;
    object-fit: cover;
}

/* Section Titles */
.section-title {
    font-weight: 600;
    color: #333;
    position: relative;
}

/* Cards */
.card {
    border-radius: 0.5rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    border: none;
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
}

/* Listing Cards */
.listing-thumbnail {
    height: 200px;
    object-fit: cover;
}

/* Listing View */
.listing-image {
    max-height: 500px;
    object-fit: contain;
}

.carousel-item {
    background-color: #f0f0f0;
}

.thumbnail-nav {
    cursor: pointer;
    transition: opacity 0.2s;
}

.thumbnail-nav:hover {
    opacity: 0.7;
}

/* Feature Icons */
.feature-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Footer */
.footer {
    margin-top: 3rem;
}

/* Social Icons */
.social-icons a {
    font-size: 1.2rem;
    margin-right: 0.5rem;
    transition: color 0.2s;
}

.social-icons a:hover {
    color: rgba(255, 255, 255, 0.7) !important;
}

/* Rating Stars */
.rating {
    color: #ffc107;
}

/* Helper Classes */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Form Styling */
.form-control:focus,
.form-select:focus {
    border-color: #6c757d;
    box-shadow: 0 0 0 0.2rem rgba(33, 37, 41, 0.25);
}

/* Buttons */
.btn {
    border-radius: 0.25rem;
    padding: 0.375rem 0.75rem;
    transition: all 0.2s;
}

.btn-primary {
    background-color: #212529;
    border-color: #212529;
}

.btn-primary:hover {
    background-color: #343a40;
    border-color: #343a40;
}

.btn-success {
    background-color: #198754;
    border-color: #198754;
}

.btn-success:hover {
    background-color: #157347;
    border-color: #146c43;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .listing-thumbnail {
        height: 150px;
    }

    .listing-image {
        max-height: 300px;
    }
}

/* Search Form */
.search-form .form-control,
.search-form .form-select {
    margin-bottom: 0.5rem;
}

/* Message Conversation */
.message-bubble {
    border-radius: 1rem;
    padding: 0.75rem;
    margin-bottom: 1rem;
    max-width: 75%;
}

.message-sender {
    background-color: #212529;
    color: white;
    margin-left: auto;
}

.message-recipient {
    background-color: #f0f0f0;
    color: #333;
}

/* Secondary info (timestamp, read receipts) should read clearly below the
 * message itself; <small> alone left it nearly the same size as the text. */
.message-bubble .message-content {
    font-size: .95rem;
    line-height: 1.35;
}

.message-bubble small {
    font-size: .7rem;
    line-height: 1.2;
}

/* Helper utilities */
.nl2br {
    white-space: pre-line;
}

/* Pagination */
.pagination .page-item.active .page-link {
    background-color: #212529;
    border-color: #212529;
}

.pagination .page-link {
    color: #212529;
}

/* Small/Recent listings */
.small-listing-thumbnail {
    height: 100px;
    object-fit: cover;
}

.small-listing .card-body {
    min-height: auto;
}

/* Cookie Consent Styles */
.cookie-consent-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: rgba(33, 37, 41, 0.95);
    color: #fff;
    padding: 1rem;
    z-index: 1100; /* Higher z-index to ensure it's above dimmed content */
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
    transform: translateY(100%);
    transition: transform 0.3s ease-in-out;
}

.cookie-consent-banner.show {
    transform: translateY(0);
}

/* Dimming effect for page content */
main.container {
    transition: opacity 0.3s ease, pointer-events 0.3s ease;
}

.cookie-consent-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.cookie-text {
    flex: 1 1 500px;
}

.cookie-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .cookie-consent-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .cookie-buttons {
        width: 100%;
        justify-content: space-between;
    }
}

/* AI Chat Widget Styles */
.ai-chat-container {
    position: fixed;
    bottom: 30px;
    left: 30px;  /* Changed from right: 30px to left: 30px */
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: flex-start;  /* Changed from flex-end to flex-start */
}

.ai-chat-toggle {
    border-radius: 30px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    padding: 10px 20px;
    transition: transform 0.2s;
}

.ai-chat-toggle:hover {
    transform: translateY(-3px);
}

.ai-chat-widget {
    position: absolute;
    bottom: 70px;
    left: 0;  /* Changed from right: 0 to left: 0 */
    width: 350px;
    height: 500px;
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
}

.ai-chat-widget.hidden {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}

.ai-chat-header {
    background-color: #212529;
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-message {
    padding: 10px 15px;
    border-radius: 18px;
    max-width: 80%;
    word-break: break-word;
}

.user-message {
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.assistant-message {
    background-color: #f8f9fa;
    border-left: 3px solid #212529;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.ai-chat-input {
    display: flex;
    padding: 10px;
    border-top: 1px solid #e9ecef;
}

.ai-chat-input input {
    flex: 1;
    border-radius: 20px;
    padding-left: 15px;
}

.ai-chat-input button {
    margin-left: 10px;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Animation for messages */
@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message {
    animation: messageSlideIn 0.3s ease forwards;
}

/* Loading indicator when waiting for AI response */
.typing-indicator {
    display: flex;
    align-items: center;
    margin: 10px 0;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background-color: #212529;
    border-radius: 50%;
    margin: 0 2px;
    opacity: 0.6;
    animation: typingAnimation 1.5s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.5s;
}

.typing-dot:nth-child(3) {
    animation-delay: 1s;
}

@keyframes typingAnimation {
    0% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
    100% {
        transform: translateY(0);
    }
}

/* Add responsive adjustments */
@media (max-width: 576px) {
    .ai-chat-widget {
        width: 300px;
        left: 10px;  /* Changed from right: 10px to left: 10px */
        bottom: 60px;
    }

    .ai-chat-toggle {
        left: 10px;  /* Changed from right: 10px to left: 10px */
        bottom: 10px;
    }
}

/* AI Chat Widget Styles - Extensions */
#prompt-counter {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

.text-warning {
    color: #ffc107 !important;
}

.text-danger {
    color: #dc3545 !important;
}

.chat-message.text-center {
    text-align: center;
}

.chat-message button {
    display: inline-block;
    transition: all 0.2s ease;
}

.chat-message button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.ai-chat-header {
    position: relative;
}

.ai-chat-widget.limit-reached .ai-chat-input {
    opacity: 0.5;
    pointer-events: none;
}

.limit-notification {
    background-color: rgba(220, 53, 69, 0.1);
    border-left: 3px solid #dc3545;
    padding: 10px 15px;
    margin: 10px 0;
    font-size: 0.9rem;
}

/* Guest prompt */
.assistant-message .guest-prompt {
    margin-top: 10px;
    padding: 8px;
    background-color: rgba(33, 37, 41, 0.1);
    border-radius: 8px;
    font-size: 0.85rem;
}

.assistant-message .guest-prompt a {
    font-weight: bold;
}

/* Favorite Button Styles */
.favorite-button-container {
    display: inline-block;
}

#favoriteBtn {
    border-radius: 50%;
    width: 36px;
    height: 36px;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: #dc3545;  /* Bootstrap's danger color */
    background-color: transparent;
    border: 1px solid #dc3545;
}

#favoriteBtn:hover {
    background-color: rgba(220, 53, 69, 0.1);
}

#favoriteBtn.favorited,
#favoriteBtn:active {
    background-color: #dc3545;
    color: white;
}

/* For the larger favorite button */
#favoriteBtnLarge {
    transition: all 0.2s ease;
}

/* Toast Notification Styles */
.toast {
    background-color: rgba(255, 255, 255, 0.95);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    border: none;
    border-radius: 0.5rem;
}

.toast-header {
    background-color: rgba(248, 249, 250, 0.85);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

/* Favorites Page Styles */
.listing-thumbnail {
    height: 200px;
    object-fit: cover;
}

.remove-favorite-btn {
    transition: all 0.2s ease;
    opacity: 0.8;
}

.remove-favorite-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.favorite-item {
    transition: opacity 0.3s ease;
}

/* Heart animation for favoriting */
@keyframes heartBeat {
    0% {
        transform: scale(1);
    }
    14% {
        transform: scale(1.3);
    }
    28% {
        transform: scale(1);
    }
    42% {
        transform: scale(1.3);
    }
    70% {
        transform: scale(1);
    }
}

.favorite-btn:active i {
    animation: heartBeat 1s;
}

/* Dropdown setup */
.dropdown-submenu {
  position: absolute;
  left: 100%;
  top: 0;
  display: none;
  min-width: 10rem;
  padding: 0.5rem 0;
  margin: 0;
  font-size: 1rem;
  color: #212529;
  text-align: left;
  list-style: none;
  background-color: #fff;
  background-clip: padding-box;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 0.25rem;
}

.dropend {
  position: relative;
}

.dropend .dropdown-toggle::after {
  display: inline-block;
  margin-left: 0.255em;
  vertical-align: 0.255em;
  content: "";
  border-top: 0.3em solid transparent;
  border-right: 0;
  border-bottom: 0.3em solid transparent;
  border-left: 0.3em solid;
}

.dropdown-submenu.show {
  display: block;
}

/* Optional: Add some hover effects for better UX */
.dropend:hover > .dropdown-toggle {
  background-color: #f8f9fa;
}

/* Add transition for smooth navbar hiding/showing */
.navbar {
  transition: transform 0.3s ease;
}

/* Class to hide navbar when scrolling down */
.navbar-hidden {
  transform: translateY(-100%);
}

/* Mobile session upload */
.photo-upload-options {
    margin-bottom: 20px;
}
.or-divider {
    text-align: center;
    margin: 15px 0;
    position: relative;
}
.or-divider::before,
.or-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 45%;
    height: 1px;
    background-color: #dee2e6;
}
.or-divider::before {
    left: 0;
}
.or-divider::after {
    right: 0;
}
.or-divider span {
    display: inline-block;
    background-color: #fff;
    padding: 0 10px;
    position: relative;
    color: #6c757d;
}
#qrCodeContainer {
    background-color: #f8f9fa;
}

html {
  scroll-behavior: smooth;
}

/* AI Chat Disclaimer */
.ai-disclaimer {
    font-size: 0.75rem;
    border-top: 1px solid rgba(0,0,0,0.1);
    max-height: 60px;
    overflow-y: auto;
}

.app-store-badge {
    height: 40px; /* Base height for the Apple badge */
    width: auto;  /* Maintain aspect ratio */
    opacity: 0.7;
    cursor: pointer;
}

/* Target the Google Play badge to adjust its height for desktop */
.app-store-badge[alt="Get it on Google Play"] {
    height: 59.5px; /* Increased height to compensate for whitespace */
}

/* --- MOBILE FIX --- */
/* On screens smaller than 576px, apply this style */
@media (max-width: 575.98px) {
    .app-store-badge[alt="Get it on Google Play"] {
        /* Slightly reduce height on mobile for a better visual match */
        height: 54px;
        width: auto;
    }
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    /* Hide search suggestions on mobile */
    .search-suggestions {
        display: none !important;
    }
    
    /* Placeholder styling for mobile - JavaScript handles the content */
    .compact-search-input::placeholder {
        font-size: 14px;
        opacity: 0.7;
    }
    
    /* Improve category card tap targets for mobile */
    .category-card {
        min-height: 80px;
        touch-action: manipulation;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
    
    .category-card .card-body {
        padding: 1rem;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        min-height: 60px;
    }
    
    /* Ensure category links are fully tappable */
    .category-nav a {
        display: block;
        width: 100%;
        height: 100%;
        text-decoration: none;
        touch-action: manipulation;
    }
    
    /* Mobile dropdown fixes */
    .dropdown-submenu {
        position: static !important;
        left: auto !important;
        top: auto !important;
        box-shadow: none !important;
        border: none !important;
        background-color: rgba(0, 0, 0, 0.05) !important;
        border-radius: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        min-width: auto !important;
    }
    
    .dropdown-submenu .dropdown-item {
        padding-left: 2rem !important;
        border-left: 3px solid var(--theme-orange) !important;
        margin-left: 1rem !important;
        font-size: 0.9rem !important;
    }
    
    /* Improve dropdown toggle visibility on mobile */
    .navbar .dropdown-item.dropdown-toggle {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        touch-action: manipulation !important;
        -webkit-touch-callout: none !important;
        -webkit-user-select: none !important;
        user-select: none !important;
        font-weight: 500 !important;
    }
    
    .navbar .dropdown-item.dropdown-toggle::after {
        margin-left: auto !important;
        border-left: 0.3em solid !important;
        border-right: 0 !important;
        border-top: 0.3em solid transparent !important;
        border-bottom: 0.3em solid transparent !important;
        transform: rotate(0deg) !important;
        transition: transform 0.3s ease !important;
    }
    
    /* Rotate arrow when submenu is open */
    .navbar .dropdown-item.dropdown-toggle[aria-expanded="true"]::after {
        transform: rotate(90deg) !important;
    }
    
    /* Improve carousel navigation for mobile */
    .carousel-nav-btn {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
        touch-action: manipulation;
    }
    
    /* Better spacing for mobile */
    .section-title {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }
    
    /* Compact search bar adjustments for mobile */
    .compact-search-wrapper {
        margin-bottom: 1rem;
    }
    
    .compact-search-input {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 12px 70px 12px 15px;
        border-radius: 25px;
    }
    
    .search-options-dropdown .search-mode-btn {
        width: 45px !important;
        height: 45px !important;
        font-size: 18px !important;
    }
    
    /* Hide carousel controls on very small screens */
    .carousel-control-prev,
    .carousel-control-next {
        width: 8%;
    }
}

@media (max-width: 576px) {
    /* Even more compact on small phones */
    .compact-search-input::placeholder {
        font-size: 13px;
    }
    
    .category-card .card-body {
        padding: 0.75rem;
    }
    
    .category-card i {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
    }
    
    .category-card h3 {
        font-size: 0.85rem;
        line-height: 1.2;
        text-align: center;
    }
    
    /* Ultra-compact buttons for small screens */
    .kudo-btn,
    .favorite-btn,
    .flag-btn {
        padding: 0.2rem 0.4rem !important;
        font-size: 0.75rem !important;
        min-width: 40px !important;
    }
    
    .kudo-btn span,
    .favorite-btn span,
    .flag-btn span {
        display: none !important; /* Hide text on very small screens */
    }
    
    .dropdown .btn {
        min-width: 80px !important;
        padding: 0.2rem 0.4rem !important;
        font-size: 0.75rem !important;
    }
    
    /* NOTE: a `.col-md-4 .d-flex { flex-direction: column !important }` rule
       used to live here, labelled "search page button fixes" but scoped to
       nothing - it stacked every flex row inside any col-md-4 sidebar on every
       page under 576px (profile stats, the listing price breakdown, seller
       info). The search page carries its own scoped copy in its <style> block,
       so this global one was redundant as well as harmful. */

    .btn-group {
        justify-content: center !important;
        width: 100% !important;
    }
    
    .dropdown {
        width: 100% !important;
    }
    
    .dropdown .btn {
        width: 100% !important;
        justify-content: space-between !important;
    }
    
    /* Make search input group more mobile-friendly */
    .input-group {
        margin-bottom: 0.5rem !important;
    }
    
    .input-group .btn {
        min-width: 50px !important;
        padding: 0.375rem 0.75rem !important;
    }
    
    /* Stack price range cards vertically on small screens */
    .quick-browse .row {
        margin: 0;
    }
    
    .quick-browse .col-lg-3 {
        padding: 0.25rem;
    }
    
    /* Mobile button fixes for search.html */
    .d-flex.gap-2 {
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }
    
    .btn-group {
        flex: 0 0 auto !important;
        width: auto !important;
        min-width: fit-content !important;
    }
    
    .btn-group .btn {
        flex: 0 0 auto !important;
        min-width: 44px !important;
        padding: 0.375rem 0.5rem !important;
    }
    
    .dropdown .btn {
        min-width: 100px !important;
        text-overflow: ellipsis !important;
        overflow: hidden !important;
        white-space: nowrap !important;
    }
    
    /* Mobile fixes for listing view buttons */
    .kudo-button-container,
    .favorite-button-container,
    .flag-button-container {
        flex: 0 0 auto !important;
        margin-right: 0.5rem !important;
    }
    
    .kudo-btn,
    .favorite-btn,
    .flag-btn {
        min-width: 44px !important;
        padding: 0.25rem 0.5rem !important;
        font-size: 0.8rem !important;
        white-space: nowrap !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .kudo-btn i,
    .favorite-btn i,
    .flag-btn i {
        margin-right: 0.25rem !important;
        font-size: 0.75rem !important;
    }
    
    /* Share dropdown button mobile fix */
    .dropdown-toggle {
        min-width: 44px !important;
        padding: 0.25rem 0.5rem !important;
    }
    
    /* Ensure action buttons container doesn't overflow */
    .d-flex.align-items-center {
        flex-wrap: wrap !important;
        gap: 0.25rem !important;
    }
}
