/* Coupons page styles - Modern Design matching products.html */

/* Top bar section */
.coupons-top-bar {
    background: white;
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 10px rgb(0 0 0 / 5%);
    border: 1px solid #7e7e7e3d;
}

@media (max-width: 767.98px) {
    .coupons-top-bar {
        padding: 1rem;
        margin-bottom: 1rem;
    }
}


/* Coupon count styling */
.coupon-count {
    font-weight: 600;
    color: var(--bs-primary);
}

/* Sort selector styling */
.sort-selector .form-select {
    border-radius: 0.375rem;
    border: 1px solid #dee2e6;
    font-size: 0.875rem;
}

.sort-selector .form-select:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.25);
}

/* Active filters styling */
.active-filters {
    margin-bottom: 0;
}

.active-filters .badge {
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.active-filters .btn-outline-secondary {
    border-radius: 0.375rem;
    font-size: 0.8rem;
    padding: 0.375rem 0.75rem;
}

/* Merchant Filter Dropdown */
.merchant-filter-dropdown {
    flex-shrink: 0;
}

.merchant-filter-dropdown .btn {
    white-space: nowrap;
}

.merchant-filter-dropdown .dropdown-menu {
    min-width: 250px;
}

.merchant-filter-dropdown .dropdown-item {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
}

.merchant-filter-dropdown .dropdown-item:hover {
    background-color: #f8f9fa;
}

.merchant-filter-dropdown .dropdown-item.active {
    background-color: var(--bs-primary);
    color: white;
}

.merchant-filter-dropdown .dropdown-item.active:hover {
    background-color: var(--bs-primary);
    opacity: 0.9;
}

.merchant-filter-dropdown .dropdown-item img {
    border-radius: 4px;
}

/* Merchant search input in dropdown */
#merchantSearchInput {
    border-radius: 0.375rem;
    border: 1px solid #dee2e6;
    font-size: 0.875rem;
}

#merchantSearchInput:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.25);
}

@media (max-width: 575.98px) {
    .merchant-filter-dropdown .btn {
        font-size: 0.875rem;
        padding: 0.375rem 0.75rem;
    }
    
    .merchant-filter-dropdown .dropdown-menu {
        min-width: 200px;
    }
}

/* Coupon card enhancements - Clean Design */
.coupon-card {
    height: 100%;
    border: 1px solid rgb(0 0 0 / 6%) !important;
    border-radius: 0rem;
    overflow: hidden;
    background: #f9f9f9;
    display: flex;
    flex-direction: row;
    align-items: stretch;
}

.coupon-card:hover {
    border-color: rgba(37, 99, 235, 0.3);
}

.coupon-card .card-body {
    padding: 1rem;
    background: white;
}

@media (max-width: 575.98px) {
    .coupon-card .card-body {
        padding: 0.75rem;
    }
}

/* Coupon logo container - Clean Design */
.coupon-logo-container {
    flex: 0 0 160px;
    width: 160px;
    border-radius: 1rem 0 0 1rem;
    padding: 1rem;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.merchant-logo-wrapper {
    position: relative;
    z-index: 1;
}

.merchant-logo-wrapper img {
    position: relative;
    z-index: 1;
}

.placeholder-logo {
    width: 100%;
    height: 180px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e9ecef;
    color: #6c757d;
}

/* Desktop Action Buttons Overlay */
.desktop-action-overlay {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    opacity: 1;
    transform: translateX(0);
    transition: all 0.3s ease;
}

/* Dedicated desktop share button */
.desktop-share-btn {
    border: none;
    padding: 0.5rem;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    backdrop-filter: blur(10px);
    background: rgb(108 117 125 / 34%);
    color: white;
    cursor: pointer;
}

.desktop-share-btn:hover {
    background: #6c757d;
    color: white;
    border: 2px solid #6c757d;
}

/* Dedicated desktop copy button */
.desktop-copy-btn {
    border: none;
    padding: 0.5rem;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    backdrop-filter: blur(10px);
    background: rgb(13 110 253 / 34%);
    color: white;
    cursor: pointer;
}

.desktop-copy-btn:hover {
    background: #0d6efd;
    color: white;
    border: 2px solid #0d6efd;
}

/* Coupon title container - Modern Typography */
.coupon-title-container {
    position: relative;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.coupon-title-link {
    font-size: 0.875rem;
    line-height: 1.4;
    font-weight: 600;
    color: #1a202c;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    position: relative;
    z-index: 1;
    flex-grow: 1;
}

/* Mobile title expansion - Enhanced visibility */
@media (max-width: 767.98px) {
    .coupon-title-link {
        -webkit-line-clamp: 1;
        line-clamp: 1;
        max-height: 1.4em;
        font-size: 0.8rem;
        font-weight: 700;
    }
    
    /* Allow expansion when toggle is active */
    .coupon-title-link.expanded {
        -webkit-line-clamp: unset !important;
        line-clamp: unset !important;
        max-height: none !important;
        display: block !important;
    }
}

/* Coupon title toggle button */
.title-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.coupon-title-toggle {
    border: none;
    background: rgba(13, 110, 253, 0.1);
    color: #0d6efd;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    line-height: 1;
    min-width: 24px;
    height: 24px;
}

.coupon-title-toggle:hover {
    background: rgba(13, 110, 253, 0.2);
}

/* Mobile action buttons */
.mobile-action-buttons {
    display: flex;
    gap: 0.25rem;
}

@media (min-width: 768px) {
    .mobile-action-buttons {
        display: none !important;
    }
}

/* Coupon merchant header (mobile only) */
.merchant-name-header {
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 0.5rem;
}

/* Coupon description */
.coupon-description {
    font-size: 0.85rem;
    line-height: 1.4;
    color: #6c757d;
}

/* Coupon meta info */
.coupon-meta {
    font-size: 0.85rem;
}

.coupon-meta small {
    display: flex;
    align-items: center;
    color: #6c757d;
}

/* Coupon code display */
.coupon-code-display {
    margin-top: auto;
}

.coupon-code-display input {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 0.9rem;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
}

.coupon-code-display .btn {
    border-color: #dee2e6;
}

/* Coupon content (body) */
.coupon-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.coupon-main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

/* Coupon footer section */
.coupon-footer {
    margin-top: auto;
    padding-top: 0.5rem;
}

/* Discount info container */
.new-container {
    padding: 0.5rem;
    background: linear-gradient(135deg, #61bc98 0%, #3cb587 100%);
    border-radius: 0.375rem;
    border: 1px solid #bae6fd;
}

.coupon-discount-info {
    padding: 0.75rem;
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border: 1px solid #6ee7b7;
}

/* Coupon discount badge */
.coupon-discount-badge {
    font-size: 1rem;
    font-weight: 700;
    color: #ff6600;
    margin-bottom: 0;
    line-height: 1.5;
}

/* Coupon actions */
.coupon-actions {
    display: grid;
    gap: 0.5rem;
}

/* Coupon actions column (list view) */
.coupon-actions-column {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 0.875rem;
    background: #f8f9fa;
    border-left: 1px solid #e9ecef;
    flex-shrink: 0;
    min-width: 140px;
    width: 140px;
}

/* List view action column button */
.coupon-col-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.45rem 0.75rem;
    border-radius: 0.375rem;
    white-space: nowrap;
    width: 100%;
}

.coupon-col-btn i {
    font-size: 0.85rem;
    flex-shrink: 0;
}

/* Reveal coupon code button — used in both grid and list views */
.coupon-reveal-btn {
    background: linear-gradient(135deg, #3cb587 0%, #20c997 100%);
    color: #fff;
    border: none;
    font-weight: 700;
    letter-spacing: 0.01em;
    border-radius: 0.375rem;
    box-shadow: 0 2px 6px rgba(25, 135, 84, 0.25);
}

.coupon-reveal-btn:hover,
.coupon-reveal-btn:focus {
    background: linear-gradient(135deg, #157347 0%, #17a589 100%);
    color: #fff;
    box-shadow: 0 3px 8px rgba(25, 135, 84, 0.3);
}

/* Grid-inline variant (full width) */
.coupon-actions .coupon-reveal-btn {
    font-size: 0.875rem;
    padding: 0.45rem 1rem;
}

/* "Vai all'offerta" button — orange/amber gradient */
.coupon-offer-btn {
    background: linear-gradient(135deg, #05294c 0%, #0d6efd 100%);
    color: #fff;
    border: none;
    font-weight: 700;
    letter-spacing: 0.01em;
    border-radius: 0.375rem;
    box-shadow: 0 2px 6px #0d6efd4f;
    text-decoration: none;
}

.coupon-offer-btn:hover,
.coupon-offer-btn:focus {
    background: linear-gradient(135deg, #05294c 0%, #0d6efd 100%);
    color: #fff;
    box-shadow: 0 2px 6px #0d6efd4f;
}

/* Grid-inline variant */
.coupon-actions .coupon-offer-btn {
    font-size: 0.875rem;
    padding: 0.45rem 1rem;
}

/* Grid view - hide action column */
.grid-view .coupon-actions-column {
    display: none !important;
}

/* List view - show action column, hide inline actions */
.list-view .coupon-item {
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100% !important;
}

.list-view .coupon-actions-column {
    display: flex !important;
}

.list-view .coupon-actions {
    display: none !important;
}

/* View toggle buttons */
.view-toggle-group {
    display: none; /* hidden on mobile */
}

@media (min-width: 768px) {
    .view-toggle-group {
        display: flex;
    }
}

.view-toggle-group .btn {
    font-size: 0.8rem;
    padding: 0.35rem 0.6rem;
    border-color: #dee2e6;
    color: #6c757d;
    transition: all 0.15s ease;
}

.view-toggle-group .btn.active,
.view-toggle-group .btn[aria-pressed="true"] {
    background-color: var(--bs-primary, #0d6efd);
    border-color: var(--bs-primary, #0d6efd);
    color: #fff;
    box-shadow: 0 1px 4px rgba(13,110,253,0.25);
}

.view-toggle-group .btn:not(.active):hover {
    background-color: #f0f4ff;
    border-color: #b6c8fd;
    color: #0d6efd;
}

/* List view on mobile: hide action column, restore inline actions */
@media (max-width: 767.98px) {
    .list-view .coupon-actions-column {
        display: none !important;
    }

    .list-view .coupon-actions {
        display: grid !important;
    }
}

/* Spinner overlay */
.spinner-overlay {
    background: rgba(255, 255, 255, 0.9);
    z-index: 9999;
}

/* Amazon offer card */
.amazon-offer-card {
    background: linear-gradient(135deg, #fff7ed 0%, #fed7aa 100%);
    border: 2px solid #fb923c;
}

/* ===== GRID VIEW — VERTICAL CARD (sm and up) ===== */
@media (min-width: 576px) {
    /* Vertical card: logo header on top, content below */
    .coupon-card {
        flex-direction: column !important;
        height: 100%;
        border-radius: 0.625rem !important;
        border: 1px solid #e5e7eb !important;
        box-shadow: 0 1px 4px rgba(0,0,0,0.06) !important;
        transition: box-shadow 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
        background: #fff;
    }

    .coupon-card:hover {
        box-shadow: 0 6px 20px rgba(0,0,0,0.10) !important;
        border-color: rgba(79,70,229,0.35) !important;
        transform: translateY(-2px);
    }

    /* Logo area — full width header */
    .coupon-logo-container {
        width: 100% !important;
        flex: none !important;
        height: 150px !important;
        padding: 1.25rem !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: #f8f9fa !important;
        border-radius: 0.625rem 0.625rem 0 0 !important;
        border-bottom: 1px solid #f0f0f0 !important;
        border-right: none !important;
    }

    .coupon-logo-container .merchant-logo-wrapper {
        height: 110px !important;
        width: 100% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .coupon-logo-container .merchant-logo-wrapper img {
        max-height: 100px !important;
        max-width: 80% !important;
        object-fit: contain !important;
    }

    .coupon-logo-container .placeholder-logo {
        height: 110px !important;
        width: 100% !important;
        background: linear-gradient(135deg, #f0f4ff 0%, #e8edf5 100%) !important;
    }

    /* Content area fills remaining height */
    .coupon-content {
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        padding: 0.875rem !important;
    }

    /* Show merchant name (logo is now above, not beside) */
    .merchant-name-header {
        display: block !important;
    }

    .desktop-action-overlay {
        display: none !important;
    }
}

/* ===== LIST VIEW — restore horizontal card at md+ ===== */
@media (min-width: 768px) {
    .list-view .coupon-card {
        flex-direction: row !important;
        height: auto;
        transform: none !important;
    }

    .list-view .coupon-card:hover {
        transform: none !important;
    }

    .list-view .coupon-logo-container {
        width: 140px !important;
        flex: 0 0 140px !important;
        height: auto !important;
        border-radius: 0.625rem 0 0 0.625rem !important;
        border-bottom: none !important;
        border-right: 1px solid #f0f0f0 !important;
    }

    .list-view .coupon-logo-container .merchant-logo-wrapper {
        height: 140px !important;
    }

    .list-view .coupon-logo-container .merchant-logo-wrapper img {
        max-height: 110px !important;
        max-width: 110px !important;
    }

    .list-view .coupon-logo-container .placeholder-logo {
        height: 140px !important;
    }

    .list-view .coupon-content {
        padding: 1rem !important;
    }
}

/* ===== MOBILE (xs <576px) — horizontal card ===== */
@media (max-width: 575.98px) {
    .coupon-logo-container {
        width: 110px;
        flex: 0 0 110px;
        padding: 0.75rem;
    }

    .merchant-logo-wrapper {
        height: 110px !important;
    }

    .merchant-logo-wrapper img {
        max-height: 90px !important;
        max-width: 90px !important;
    }

    .placeholder-logo {
        height: 110px !important;
        font-size: 0.78rem !important;
    }

    .placeholder-logo i {
        font-size: 1.75rem !important;
    }

    .desktop-action-overlay {
        display: none !important;
    }

    .coupon-title-link {
        font-size: 0.82rem;
        line-height: 1.4;
    }

    .coupon-meta small {
        font-size: 0.72rem;
    }

    .coupon-code-display input {
        font-size: 0.8rem;
    }

    .coupon-discount-badge {
        font-size: 0.9rem;
    }

    .coupon-actions .btn {
        font-size: 0.85rem;
        padding: 0.45rem 0.65rem;
    }
}

/* Responsive adjustments - Legacy (keeping for backward compatibility) */
@media (max-width: 575.98px) {
    .coupon-top-bar {
        padding: 0.75rem;
    }
}

/* Coupon title */
.coupon-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #212529;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

/* Coupon description */
.coupon-description {
    font-size: 0.875rem;
    color: #6c757d;
    line-height: 1.4;
}

/* Coupon code styling */
.coupon-code .input-group {
    max-width: 200px;
}

.coupon-code .form-control {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    text-align: center;
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    font-size: 0.9rem;
}

.coupon-code .btn {
    border-left: none;
}

.coupon-code .btn:hover {
    background-color: #0d6efd;
    border-color: #0d6efd;
}

/* Discount badge */
.discount-badge .badge {
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
}

/* Coupon details */
.coupon-details small {
    font-size: 0.8rem;
}

/* Coupon footer */
.coupon-card .card-footer {
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

/* Loading spinner */
.spinner-overlay {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(2px);
    z-index: 1050;
}

/* Pagination styling */
.pagination .page-link {
    color: var(--bs-primary);
    border-color: #dee2e6;
}

.pagination .page-link:hover {
    color: var(--bs-primary);
    background-color: #e9ecef;
    border-color: #adb5bd;
}

.pagination .page-item.active .page-link {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
}

/* Responsive adjustments */
@media (max-width: 767.98px) {
    /* No extra gap needed — Bootstrap g-3 handles gutters */

    .coupon-title {
        font-size: 1rem;
    }

    .coupon-code .input-group {
        max-width: 100%;
    }
}

/* Dark mode support (if needed) */
@media (prefers-color-scheme: dark) {
    .coupon-card {

        border-color: #4a5568;
    
    }

    .coupon-header {
        background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
        border-bottom-color: #4a5568;
    }

    .merchant-name {
        color: #a0aec0;
    }

    .coupon-title {
        color: #e2e8f0;
    }

    .coupon-description {
        color: #a0aec0;
    }

    .coupon-code .form-control {
        background: #1a202c;
        border-color: #4a5568;
        color: #e2e8f0;
    }

    .coupon-card .card-footer {
        background: #1a202c;
        border-top-color: #4a5568;
    }
}