/* ============================================
   buyTI Storefront
   Brand colors: blue #4AADE0, dark #2D2D2D
   ============================================ */

/* --- CSS Variables --- */
:root {
    --brand-blue: #4AADE0;
    --brand-blue-dark: #3A8FC0;
    --brand-blue-light: #e8f4fb;
    --brand-dark: #2D2D2D;
    --brand-green: #00a650;
    --bg: #f4f6f8;
    --card-bg: #ffffff;
    --text: #2D2D2D;
    --text-light: #888888;
    --border: #e0e4e8;
    --price: #2D2D2D;
    --discount: #00a650;
    --navbar-bg: #ffffff;
    --navbar-text: #2D2D2D;
    --footer-bg: #2D2D2D;
    --footer-text: #f4f6f8;
}

[data-bs-theme="dark"] {
    --bg: #141820;
    --card-bg: #1c2230;
    --text: #e0e4e8;
    --text-light: #8890a0;
    --border: #2a3040;
    --price: #e0e4e8;
    --navbar-bg: #1c2230;
    --navbar-text: #e0e4e8;
    --footer-bg: #0e1118;
    --footer-text: #b0b8c8;
}

/* --- Global --- */
body {
    background-color: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

a {
    color: var(--brand-blue);
    text-decoration: none;
}

a:hover {
    color: var(--brand-blue-dark);
}

/* --- Navbar --- */
.navbar {
    background-color: var(--navbar-bg);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    padding: 0.5rem 0;
    z-index: 1000;
    border-bottom: 3px solid var(--brand-blue);
}

.navbar-logo {
    height: 32px;
    width: auto;
}

.navbar .navbar-brand {
    color: var(--navbar-text);
}

.navbar .nav-link {
    color: var(--navbar-text);
    opacity: 0.8;
    font-weight: 500;
}

.navbar .nav-link:hover {
    opacity: 1;
    color: var(--brand-blue);
}

.navbar-toggler {
    border-color: var(--border);
}

/* --- Search bar --- */
.search-form {
    max-width: 600px;
}

.search-input {
    border: 2px solid var(--border);
    border-right: none;
    border-radius: 4px 0 0 4px;
    padding: 0.5rem 1rem;
    background-color: var(--card-bg);
    color: var(--text);
}

.search-input:focus {
    border-color: var(--brand-blue);
    box-shadow: none;
    background-color: var(--card-bg);
    color: var(--text);
}

.btn-search {
    background-color: var(--brand-blue);
    color: white;
    border: 2px solid var(--brand-blue);
    border-radius: 0 4px 4px 0;
    padding: 0.5rem 1rem;
}

.btn-search:hover {
    background-color: var(--brand-blue-dark);
    border-color: var(--brand-blue-dark);
    color: white;
}

/* --- Theme toggle --- */
.theme-toggle {
    cursor: pointer;
    transition: transform 0.3s ease;
}

.theme-toggle:hover {
    transform: scale(1.1);
}

/* --- Filters bar --- */
.filters-bar {
    padding: 0.75rem 1rem;
    background-color: var(--card-bg);
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* --- Product Card --- */
.product-card {
    border: 1px solid var(--border);
    border-radius: 6px;
    background-color: var(--card-bg);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    overflow: hidden;
    position: relative;
}

.product-card:hover {
    box-shadow: 0 8px 24px rgba(74, 173, 224, 0.15);
    transform: translateY(-2px);
}

.card-img-top-wrapper {
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: #fafafa;
}

[data-bs-theme="dark"] .card-img-top-wrapper {
    background: #161c28;
}

.product-thumb {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.no-image-placeholder {
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.badge-sob-encomenda {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 2;
}

.product-title {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
    min-height: 2.6em;
}

.product-price {
    font-size: 1.35rem;
    font-weight: 400;
    color: var(--price);
    line-height: 1.2;
}

.original-price {
    font-size: 0.8rem;
    color: var(--text-light);
    text-decoration: line-through;
    display: block;
    margin-bottom: 2px;
}

.discount-badge {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--discount);
}

/* --- Product Detail --- */
.product-detail-title {
    font-size: 1.5rem;
    font-weight: 400;
    color: var(--text);
    line-height: 1.3;
}

.condition-badge {
    font-size: 0.85rem;
    color: var(--text-light);
    display: block;
    margin-bottom: 0.5rem;
}

.price-section {
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}

.original-price-detail {
    font-size: 1rem;
    color: var(--text-light);
    text-decoration: line-through;
}

.current-price-detail {
    font-size: 2.25rem;
    font-weight: 300;
    color: var(--price);
    line-height: 1.2;
}

.discount-badge-lg {
    font-size: 1rem;
    font-weight: 600;
    color: var(--discount);
}

.stock-info {
    font-size: 0.95rem;
}

/* --- WhatsApp Button --- */
.btn-whatsapp {
    background-color: #25d366;
    border-color: #25d366;
    color: white;
    font-weight: 600;
    font-size: 1.1rem;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.btn-whatsapp:hover {
    background-color: #1da851;
    border-color: #1da851;
    color: white;
}

/* --- Image Gallery --- */
.gallery-container {
    position: relative;
}

.thumbnails-column {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 500px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.thumbnail-item {
    width: 60px;
    height: 60px;
    border: 2px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    transition: border-color 0.2s ease;
    flex-shrink: 0;
    background-color: var(--card-bg);
}

.thumbnail-item:hover {
    border-color: var(--brand-blue);
}

.thumbnail-item.active {
    border-color: var(--brand-blue);
    border-width: 2px;
}

.thumbnail-item img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.main-image-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 350px;
    max-height: 500px;
    padding: 1rem;
    background: #fafafa;
    border-radius: 6px;
    border: 1px solid var(--border);
}

[data-bs-theme="dark"] .main-image-container {
    background: #161c28;
}

.main-product-image {
    max-width: 100%;
    max-height: 470px;
    object-fit: contain;
    transition: opacity 0.2s ease;
}

.no-image-placeholder-lg {
    text-align: center;
    padding: 3rem;
}

/* --- Product Info Box --- */
.product-info {
    background-color: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1.5rem;
}

/* --- Sections (Attributes, Description) --- */
.product-section {
    background-color: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1.5rem;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.attributes-table th {
    width: 35%;
    font-weight: 500;
    color: var(--text-light);
    background-color: transparent;
}

.attributes-table td {
    color: var(--text);
}

.product-description {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text);
}

/* --- Breadcrumb --- */
.breadcrumb {
    background: transparent;
    padding: 0;
    font-size: 0.85rem;
}

.breadcrumb-item a {
    color: var(--brand-blue);
}

.breadcrumb-item.active {
    color: var(--text-light);
}

/* --- Pagination --- */
.pagination .page-link {
    color: var(--brand-blue);
    border-color: var(--border);
    background-color: var(--card-bg);
}

.pagination .page-item.active .page-link {
    background-color: var(--brand-blue);
    border-color: var(--brand-blue);
    color: white;
}

.pagination .page-item.disabled .page-link {
    color: var(--text-light);
    background-color: var(--card-bg);
}

/* --- Footer --- */
.site-footer {
    background-color: var(--footer-bg);
    color: var(--footer-text);
    padding: 1.25rem 0;
    margin-top: 2rem;
}

.footer-link {
    color: var(--footer-text);
    opacity: 0.85;
}

.footer-link:hover {
    color: var(--brand-blue);
    opacity: 1;
}

.footer-company-info {
    color: var(--footer-text);
    opacity: 0.7;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .gallery-container {
        flex-direction: column-reverse;
    }

    .thumbnails-column {
        flex-direction: row;
        max-height: none;
        overflow-x: auto;
        margin-right: 0;
        margin-top: 0.75rem;
    }

    .thumbnail-item {
        width: 50px;
        height: 50px;
    }

    .main-image-container {
        min-height: 250px;
    }

    .main-product-image {
        max-height: 300px;
    }

    .current-price-detail {
        font-size: 1.75rem;
    }

    .product-detail-title {
        font-size: 1.2rem;
    }

    .search-form {
        width: 100%;
        max-width: none;
        margin: 0.5rem 0;
    }

    .product-price {
        font-size: 1.15rem;
    }

    .card-img-top-wrapper {
        height: 160px;
    }

    .navbar-logo {
        height: 26px;
    }
}

@media (max-width: 576px) {
    .card-img-top-wrapper {
        height: 140px;
        padding: 0.5rem;
    }

    .product-title {
        font-size: 0.8rem;
    }

    .product-price {
        font-size: 1rem;
    }

    .card-body {
        padding: 0.5rem;
    }
}

/* --- Dark mode overrides --- */
[data-bs-theme="dark"] .dropdown-menu {
    background-color: var(--card-bg);
    border-color: var(--border);
}

[data-bs-theme="dark"] .dropdown-item {
    color: var(--text);
}

[data-bs-theme="dark"] .dropdown-item:hover {
    background-color: rgba(74, 173, 224, 0.15);
}

[data-bs-theme="dark"] .table {
    color: var(--text);
}

[data-bs-theme="dark"] .btn-outline-secondary {
    color: var(--text);
    border-color: var(--border);
}

[data-bs-theme="dark"] .btn-outline-primary {
    color: var(--brand-blue);
    border-color: var(--brand-blue);
}

[data-bs-theme="dark"] .navbar-logo {
    filter: brightness(1.8);
}
