:root {
    --bg-color: #f0fdf4;
    --card-bg: #ffffff;
    --card-border: rgba(22, 163, 74, 0.2);
    --text-primary: #14532d;
    --text-secondary: #4b5563;
    --accent-color: #16a34a;
    --accent-glow: rgba(22, 163, 74, 0.4);
    --success-color: #15803d;
    --error-color: #dc2626;

    --font-main: 'Outfit', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Background Effects */
.background-globes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.globe {
    position: absolute;
    border-radius: 50%;
    opacity: 0.15;
    filter: blur(80px);
}

.globe-1 {
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, var(--accent-color), transparent);
    top: -20%;
    left: -10%;
    animation: float 20s infinite alternate ease-in-out;
}

.globe-2 {
    width: 40vw;
    height: 40vw;
    background: radial-gradient(circle, #14b8a6, transparent);
    bottom: -10%;
    right: -10%;
    animation: float 25s infinite alternate-reverse ease-in-out;
}

@keyframes float {
    0% {
        transform: translate(0, 0);
    }

    100% {
        transform: translate(50px, 50px);
    }
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--card-border);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 1rem 0;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(to right, #16a34a, #14532d);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.controls {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-grow: 1;
    justify-content: center;
}

/* Toggle Switch Styles */
.toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    user-select: none;
}

.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    -webkit-transition: .4s;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    -webkit-transition: .4s;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--accent-color);
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--accent-color);
}

input:checked+.slider:before {
    transform: translateX(18px);
}

#searchInput {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 10px 16px;
    color: var(--text-primary);
    font-family: inherit;
    width: 300px;
    transition: all 0.3s ease;
}

#searchInput:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 15px var(--accent-glow);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--success-color);
    white-space: nowrap;
}

.dot {
    width: 8px;
    height: 8px;
    background-color: var(--success-color);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--success-color);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

/* Buttons */
.btn-primary {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-primary:hover {
    box-shadow: 0 0 15px var(--accent-glow);
    transform: translateY(-1px);
}

.btn-small {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--card-border);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
}

.btn-small:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
}

.user-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

#userNameDisplay {
    font-weight: 600;
    color: var(--text-primary);
}

/* Tabs */
.tabs {
    margin-top: 1.5rem;
    display: flex;
    gap: 20px;
    border-bottom: 2px solid var(--card-border);
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 1rem;
    padding: 10px 0;
    cursor: pointer;
    position: relative;
    transition: color 0.2s;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--accent-color);
    font-weight: 600;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent-color);
    box-shadow: 0 -2px 10px var(--accent-glow);
}

/* Main Grid */
main {
    padding-top: 2rem;
    padding-bottom: 2rem;
}

.view-section {
    display: none;
}

.view-section.active {
    display: block;
}

/* Main Grid Wrapper - Now Flex Column for Sections */
.deals-grid {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Day Section */
.day-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Inner Grid for Deals */
.day-deals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    transition: all 0.3s ease;
}

.day-deals-grid.collapsed {
    display: none;
}

/* Date Header */
.date-header {
    width: 100%;
    color: #4b5563;
    font-size: 1.2rem;
    font-weight: 700;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 0.5rem;
    display: flex;
    align-items: baseline;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    transition: color 0.2s;
}

.date-header:hover {
    color: var(--accent-color);
}

.date-header small {
    font-size: 0.85rem;
    font-weight: 400;
    font-style: italic;
    color: var(--text-secondary);
    pointer-events: none;
    /* Let clicks pass to header */
}

/* Toggle Icon */
.toggle-icon {
    font-size: 0.8rem;
    margin-left: auto;
    /* Push to right */
    transform: rotate(0deg);
    transition: transform 0.3s ease;
    color: var(--text-secondary);
}

.date-header.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

/* Deal Card */
.deal-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 16px;
    backdrop-filter: blur(10px);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.deal-card:hover {
    transform: translateY(-3px);
    background: #ffffff;
    box-shadow: 0 8px 20px -8px rgba(22, 163, 74, 0.2);
    border-color: var(--accent-color);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.channel-tag {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-color);
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.75rem;
}

.match-tag {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.75rem;
}

.deal-content {
    color: var(--text-primary);
    line-height: 1.5;
    font-size: 0.9rem;
    word-break: break-word;

    /* Truncation */
    display: -webkit-box;
    -webkit-line-clamp: 4;
    line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.deal-content a {
    color: #0ea5e9;
    text-decoration: none;
    transition: color 0.2s;
}

.deal-content a:hover {
    color: #0284c7;
    text-decoration: underline;
}

.card-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: auto;
    padding-top: 5px;
}

.time-ago {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Wishlist Manager */
.wishlist-manager {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
}

.wishlist-manager h3 {
    margin-bottom: 1rem;
    font-weight: 600;
}

.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 1.5rem;
}

#wishlistInput {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 10px 16px;
    color: var(--text-primary);
    font-family: inherit;
    flex-grow: 1;
}

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.tag {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid var(--card-border);
    padding: 6px 12px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.tag button {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
}

.tag button:hover {
    color: var(--error-color);
}

.section-title {
    margin-bottom: 1rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 200;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: #ffffff;
    padding: 2rem;
    border: 1px solid var(--card-border);
    width: 90%;
    max-width: 400px;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.modal-content h2 {
    text-align: center;
    margin-bottom: 10px;
}

.modal-content input {
    width: 100%;
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 12px;
    color: var(--text-primary);
    margin-bottom: 15px;
}

.toggle-link {
    text-align: center;
    font-size: 0.9rem;
    color: var(--accent-color);
    cursor: pointer;
    text-decoration: underline;
}

.error-msg {
    color: var(--error-color);
    font-size: 0.9rem;
    text-align: center;
    min-height: 20px;
}


/* Loading State */
.loading-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 50vh;
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* User Dropdown */
.user-menu-container {
    position: relative;
    display: flex;
    align-items: center;
}

.user-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background 0.2s;
}

.user-trigger:hover {
    background: rgba(0, 0, 0, 0.05);
}

.arrow-down {
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid var(--text-secondary);
    transition: transform 0.2s;
}

.user-menu-container.active .arrow-down {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: #ffffff;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    min-width: 150px;
    display: none;
    flex-direction: column;
    z-index: 1000;
    padding: 4px 0;
    overflow: hidden;
}

.user-menu-container.active .dropdown-menu {
    display: flex;
}

.dropdown-item {
    padding: 10px 16px;
    background: none;
    border: none;
    text-align: left;
    width: 100%;
    cursor: pointer;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--accent-color);
}