:root {
    --primary: #ff4d6d;
    --primary-hover: #ff758f;
    --primary-light: #fff0f3;
    --accent: #c9184a;
    --bg-gradient: linear-gradient(135deg, #fff0f3 0%, #ffccd5 100%);
    --card-bg: rgba(255, 255, 255, 0.8);
    --card-border: rgba(255, 255, 255, 0.6);
    --text-dark: #3a0ca3;
    --text-muted: #5c677d;
    --shadow-soft: 0 8px 32px 0 rgba(255, 77, 109, 0.1);
    --shadow-hover: 0 16px 36px 0 rgba(255, 77, 109, 0.25);
    --transition-speed: 0.3s;
}

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

body {
    font-family: 'Montserrat', sans-serif;
    background: var(--bg-gradient);
    min-height: 100vh;
    color: var(--text-dark);
    line-height: 1.6;
    overflow-x: hidden;
    position: relative;
}

/* Background floating bubbles */
.background-decor {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
}

.bubble {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,182,193,0.4) 0%, rgba(255,200,210,0.1) 100%);
    animation: float 20s infinite ease-in-out;
    will-change: transform;
    transform: translate3d(0, 0, 0);
}

.bubble-1 {
    width: 400px;
    height: 400px;
    top: -100px;
    left: -100px;
    animation-duration: 25s;
}

.bubble-2 {
    width: 300px;
    height: 300px;
    bottom: -50px;
    right: -50px;
    animation-delay: -5s;
    animation-duration: 20s;
}

.bubble-3 {
    width: 200px;
    height: 200px;
    top: 50%;
    left: 80%;
    animation-delay: -10s;
    animation-duration: 18s;
}

@keyframes float {
    0%, 100% {
        transform: translate3d(0, 0, 0) scale(1) rotate(0deg);
    }
    50% {
        transform: translate3d(0, -40px, 0) scale(1.05) rotate(15deg);
    }
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--card-border);
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(255, 77, 109, 0.05);
}

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

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

.logo h1 {
    font-family: 'Comfortaa', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(45deg, var(--accent), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.heart-icon {
    font-size: 2rem;
    display: inline-block;
    animation: pulse 1.5s infinite ease-in-out;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.stats-bar {
    display: flex;
    gap: 12px;
}

.stat-card {
    background: white;
    padding: 8px 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 77, 109, 0.15);
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.02);
}

.stat-num {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card.active-stat .stat-num {
    color: #4361ee;
}

.stat-card.used-stat .stat-num {
    color: #7209b7;
}

/* Toolbar (Filters & Actions) */
.toolbar {
    margin: 30px 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.filter-group {
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(5px);
    padding: 4px;
    border-radius: 14px;
    display: flex;
    gap: 4px;
}

.filter-btn {
    border: none;
    background: transparent;
    padding: 10px 18px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-dark);
    cursor: pointer;
    transition: all var(--transition-speed) ease;
}

.filter-btn:hover {
    background: rgba(255, 77, 109, 0.1);
}

.filter-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(255, 77, 109, 0.3);
}

.actions-group {
    display: flex;
    gap: 8px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--card-border);
    background: rgba(255, 255, 255, 0.6);
    padding: 10px 16px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-dark);
    cursor: pointer;
    transition: all var(--transition-speed) ease;
}

.action-btn svg {
    width: 15px;
    height: 15px;
}

.action-btn:hover {
    background: var(--primary-light);
    border-color: rgba(255, 77, 109, 0.3);
    color: var(--accent);
}

/* Grid layout for coupons */
.coupons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
    margin-bottom: 50px;
    min-height: 300px;
}

/* Coupon Card Styling */
.coupon-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-soft);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), 
                box-shadow 0.4s ease, 
                opacity 0.4s ease;
    position: relative;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.coupon-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: var(--shadow-hover);
    border-color: rgba(255, 77, 109, 0.3);
}

.coupon-img-container {
    position: relative;
    width: 100%;
    padding-top: 60%; /* Ratio based on landscape cropped bounds (approx 1.6:1) */
    overflow: hidden;
    cursor: pointer;
    background: #f7f7f7;
}

.coupon-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.coupon-card:hover .coupon-img {
    transform: scale(1.05);
}

.card-stamp {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-12deg);
    border: 4px dashed rgba(114, 9, 183, 0.7);
    color: rgba(114, 9, 183, 0.7);
    font-size: 1.2rem;
    font-weight: 800;
    padding: 6px 16px;
    border-radius: 8px;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition-speed) ease;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    z-index: 2;
    letter-spacing: 1.5px;
}

.coupon-card-footer {
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.5);
    border-top: 1px solid rgba(0,0,0,0.03);
    margin-top: auto;
}

.coupon-number {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
}

/* Custom Checkbox Toggle */
.status-checkbox-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.status-checkbox-wrapper input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.status-checkbox-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-right: 8px;
    transition: color var(--transition-speed) ease;
}

.checkbox-visual {
    width: 44px;
    height: 24px;
    background: #e2e8f0;
    border-radius: 12px;
    position: relative;
    transition: background-color var(--transition-speed) ease;
}

.checkbox-visual::after {
    content: '';
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 3px;
    left: 3px;
    transition: transform var(--transition-speed) cubic-bezier(0.2, 0.85, 0.32, 1.2);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.status-checkbox-wrapper input:checked + .checkbox-visual {
    background: var(--primary);
}

.status-checkbox-wrapper input:checked + .checkbox-visual::after {
    transform: translateX(20px);
}

/* Used State Styles */
.coupon-card.used {
    opacity: 0.75;
}

.coupon-card.used .coupon-img {
    filter: grayscale(80%) contrast(0.9);
}

.coupon-card.used .card-stamp {
    opacity: 1;
}

.coupon-card.used:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-soft);
}

/* Loading & Empty State */
.loading-state, .empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    background: var(--card-bg);
    border: 1px dashed var(--card-border);
    border-radius: 20px;
    box-shadow: var(--shadow-soft);
}

.empty-state p {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-top: 10px;
}

.empty-state-emoji {
    font-size: 3rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 77, 109, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s infinite linear;
}

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

/* Modal Lightbox */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    background: rgba(18, 0, 15, 0.85);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.show {
    display: flex;
    opacity: 1;
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 3rem;
    font-weight: 300;
    cursor: pointer;
    transition: color var(--transition-speed) ease;
    z-index: 1010;
}

.modal-close:hover {
    color: var(--primary-hover);
}

.modal-content {
    max-width: 90%;
    max-height: 85%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    position: relative;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.15);
}

.modal.show .modal-content {
    transform: scale(1);
}

.modal-image-wrapper {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    background: black;
}

.modal-content img {
    max-width: 100%;
    max-height: 70vh;
    display: block;
    object-fit: contain;
}

.stamp-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-12deg);
    border: 6px dashed rgba(255, 77, 109, 0.9);
    color: rgba(255, 77, 109, 0.9);
    font-size: 2.2rem;
    font-weight: 800;
    padding: 10px 30px;
    border-radius: 12px;
    pointer-events: none;
    opacity: 0;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 10px 25px rgba(0,0,0,0.25);
    z-index: 10;
    letter-spacing: 2px;
    transition: opacity var(--transition-speed) ease;
}

.modal.show.used .stamp-overlay {
    opacity: 1;
}

.modal-actions {
    width: 100%;
    display: flex;
    justify-content: center;
}

.toggle-btn-large {
    border: none;
    background: var(--primary);
    color: white;
    padding: 12px 30px;
    border-radius: 30px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(255, 77, 109, 0.4);
    transition: all var(--transition-speed) ease;
}

.toggle-btn-large:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 77, 109, 0.5);
}

.modal.show.used .toggle-btn-large {
    background: #6c757d;
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.4);
}

.modal.show.used .toggle-btn-large:hover {
    background: #5a6268;
}

/* Toast System */
.toast {
    position: fixed;
    bottom: -60px;
    left: 50%;
    transform: translateX(-50%);
    background: #2b2d42;
    color: white;
    padding: 12px 28px;
    border-radius: 30px;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
    transition: bottom 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 2000;
    pointer-events: none;
    letter-spacing: 0.5px;
}

.toast.show {
    bottom: 30px;
}

/* Footer */
footer {
    background: rgba(255, 255, 255, 0.3);
    padding: 25px 0;
    text-align: center;
    border-top: 1px solid var(--card-border);
    margin-top: auto;
}

footer p {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Responsiveness adjustments */
@media (max-width: 768px) {
    .header-container {
        flex-direction: column;
        text-align: center;
    }
    
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group {
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    .filter-btn {
        flex: 1 1 auto;
        text-align: center;
    }

    .actions-group {
        justify-content: center;
    }
    
    .modal-close {
        top: 10px;
        right: 15px;
        font-size: 2.5rem;
    }
}

/* iPhone & Small Mobile Device Optimizations */
@media (max-width: 480px) {
    body {
        padding-bottom: calc(20px + env(safe-area-inset-bottom));
    }

    header {
        padding-top: calc(10px + env(safe-area-inset-top));
        padding-bottom: 12px;
    }

    .logo h1 {
        font-size: 1.4rem;
    }

    .logo .heart-icon {
        font-size: 1.6rem;
    }

    .stats-bar {
        width: 100%;
        gap: 8px;
    }

    .stat-card {
        flex: 1;
        padding: 6px 8px;
    }

    .stat-num {
        font-size: 1.1rem;
    }

    .stat-label {
        font-size: 0.65rem;
    }

    .toolbar {
        margin-top: 15px;
        margin-bottom: 15px;
        gap: 10px;
    }

    .actions-group {
        width: 100%;
        gap: 8px;
    }

    .action-btn {
        flex: 1;
        justify-content: center;
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    .coupons-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    /* Modal iOS fixes */
    .modal-content {
        max-width: 95%;
        max-height: 90vh;
        gap: 15px;
    }

    .modal-content img {
        max-height: 55vh;
    }

    .stamp-overlay {
        font-size: 1.6rem;
        padding: 6px 16px;
        border-width: 4px;
    }

    .toggle-btn-large {
        width: 100%;
        padding: 10px 20px;
        font-size: 0.9rem;
    }

    .modal-close {
        top: calc(10px + env(safe-area-inset-top));
        right: 15px;
        font-size: 2.2rem;
    }
}
