:root {
    --primary: #ee4d2d;
    --primary-hover: #f05d40;
    --bg-color: #f6f6f6;
    --text-main: #333;
    --text-muted: #888;
    --white: #ffffff;
    --success: #28a745;
    --error: #dc3545;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding: 40px 20px;
}

.container {
    background: var(--white);
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
    width: 100%;
    max-width: 500px;
    text-align: center;
    transition: all 0.3s ease;
}

h1 {
    color: var(--primary);
    margin-bottom: 15px;
    font-size: 26px;
    font-weight: 700;
}

p {
    color: var(--text-muted);
    margin-bottom: 30px;
    font-size: 15px;
    line-height: 1.5;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
    text-align: left;
}

.hidden {
    display: none !important;
}

label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
}

.input-with-button {
    position: relative;
    display: flex;
    align-items: center;
}

input {
    width: 100%;
    padding: 15px 120px 15px 15px; /* Added right padding for both buttons */
    border: 2px solid #eee;
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.3s ease;
    outline: none;
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(238, 77, 45, 0.1);
}

.clear-btn {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: #999;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, transform 0.2s;
    border-radius: 50%;
    width: 40px;
    height: 40px;
}

.clear-btn:hover {
    color: var(--error);
    background-color: rgba(220, 53, 69, 0.1);
}

.paste-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background-color: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
    width: auto;
    height: auto;
}

.paste-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 2px 8px rgba(238, 77, 45, 0.3);
}

.paste-btn:active {
    transform: translateY(-50%) scale(0.95);
    box-shadow: none;
}

input::placeholder {
    color: #bbb;
}

.error-message {
    color: var(--error);
    font-size: 13px;
    margin-top: -8px;
    display: none;
    font-weight: 500;
}

.error-message.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.button,
button {
    width: 100%;
    padding: 16px;
    background-color: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    text-decoration: none;
}

.button:not(.action-btn):hover,
button:not(.action-btn):hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(238, 77, 45, 0.2);
}

.button:active,
button:active {
    transform: translateY(1px);
    box-shadow: none;
}

.button:disabled,
button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.result-box {
    margin-top: 25px;
    padding: 20px;
    background-color: #fef1ee;
    border: 2px dashed rgba(238, 77, 45, 0.3);
    border-radius: 8px;
    display: none;
    flex-direction: column;
    gap: 15px;
}

.result-box.active {
    display: flex;
    animation: slideDown 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.result-title {
    font-size: 13px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.result-link {
    font-size: 15px;
    word-break: break-all;
    color: var(--primary);
    font-weight: 500;
    background: rgba(255,255,255,0.7);
    padding: 12px;
    border-radius: 6px;
    user-select: all;
}

.copy-btn {
    background-color: var(--white);
    color: var(--primary);
    border: 2px solid var(--primary);
    padding: 12px;
    font-size: 14px;
    box-shadow: none;
}

.copy-btn:hover {
    background-color: #fff4f2;
    transform: none;
    box-shadow: none;
}

.copy-btn.copied {
    background-color: var(--success);
    color: var(--white);
    border-color: var(--success);
}

.loader {
    display: none;
    border: 3px solid rgba(255,255,255,0.3);
    border-top: 3px solid var(--white);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 0.8s linear infinite;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}


.result-group {
    position: relative;
}

.result-copy-icon {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    color: var(--primary);
    width: 24px;
    height: 24px;
}

.copy-floating-text {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #28a745;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 10;
}

.copy-floating-text::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 5px 5px 0 5px;
    border-style: solid;
    border-color: #28a745 transparent transparent transparent;
}

.copy-floating-text.show {
    opacity: 1;
}

/* Scraped Products Section */
.scraped-deals-section {
    width: 100%;
    max-width: 1200px;
    margin-top: 40px;
    text-align: left;
}

.scraped-deals-section h2 {
    color: var(--primary);
    font-size: 24px;
    font-weight: 700;
    margin: 0;
}

.deals-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 25px;
    gap: 15px;
}

/* Time Status and Countdown */
.time-status-container {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.time-badge {
    display: flex;
    align-items: center;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 3px 10px rgba(0,0,0,0.03);
}

.time-date {
    background: var(--primary);
    color: white;
    padding: 8px 12px;
}

.time-frame {
    padding: 8px 12px;
    border-right: 1px solid #ddd;
    color: #444;
}

.time-state {
    padding: 8px 12px;
    color: var(--success);
    font-weight: 700;
}
.time-state.active {
    color: #28a745;
    animation: pulse-green 1.5s infinite;
}
.time-state.ended {
    color: #888;
}

.disabled-block {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

@keyframes pulse-green {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.countdown-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff3cd;
    color: #856404;
    padding: 8px 16px;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid #ffeeba;
    animation: pulse 2s infinite;
}

.countdown-timer {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(255, 193, 7, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 193, 7, 0); }
}

/* Controls: Search and Filter */
.deals-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.search-container {
    flex: 1;
    min-width: 250px;
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 15px;
    width: 18px;
    height: 18px;
    color: #999;
}

.search-container input {
    width: 100%;
    padding: 12px 15px 12px 45px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
    background: white;
}

.search-container input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(238, 77, 45, 0.1);
}

.filter-container select {
    padding: 12px 35px 12px 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    background-color: white;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23999%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 15px top 50%;
    background-size: 12px auto;
    transition: all 0.3s ease;
}

.filter-container select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(238, 77, 45, 0.1);
}

.products-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.product-card {
    background: var(--white);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.06);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: var(--text-main);
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

.product-image {
    position: relative;
    width: 100%;
    padding-top: 100%; /* 1:1 Aspect Ratio */
    background: #f9f9f9;
}

.product-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.percent-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(238, 77, 45, 0.9);
    color: white;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 4px;
}

.product-info {
    padding: 12px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.product-name {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: #333;
}

.price-container {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-top: auto;
}

.current-price {
    color: var(--primary);
    font-weight: 700;
    font-size: 16px;
}

.original-price {
    color: var(--text-muted);
    font-size: 12px;
    text-decoration: line-through;
}

.amount-info {
    padding: 0 12px 12px;
    font-size: 12px;
    color: #888;
}