/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --bg-color: #f6f8fb;
    --card-bg: #ffffff;
    --primary: #8b5cf6;
    /* Use a vivid purple/violet like screenshot user sent earlier or kept similar */
    --primary-hover: #7c3aed;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;

    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(229, 231, 235, 0.5);

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    --radius-lg: 16px;
    --radius-md: 8px;
    --radius-full: 9999px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Layout */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    margin-bottom: 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(to bottom, var(--bg-color) 80%, rgba(246, 248, 251, 0));
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-title {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fff 0%, #aaa 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--card-bg);
    padding: 6px 12px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

.user-profile:hover {
    border-color: var(--text-muted);
}

.avatar {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
}

/* Toolbar & Filters */
.toolbar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    overflow-x: auto;
    padding-bottom: 4px;
    align-items: center;
}

.search-bar {
    flex: 1;
    position: relative;
    max-width: 400px;
}

.search-bar input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.chip {
    padding: 8px 16px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    user-select: none;
}

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 1200px;
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    gap: 40px;
    padding: 10px 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.bottom-nav .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    gap: 4px;
    cursor: center;
    padding: 5px 20px;
    border-radius: 12px;
    transition: all 0.2s;
}

.bottom-nav .nav-item ion-icon {
    font-size: 24px;
}

.bottom-nav .nav-item.active {
    color: var(--primary);
}

/* Coupon Cards - Colourful */
.coupon-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 0;
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: transform 0.2s;
    position: relative;
}

.coupon-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Hero Image Layout */
.card-image-container {
    height: 160px;
    width: 100%;
    position: relative;
    overflow: hidden;
}

.card-hero-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Top crop with 6% offset matching Android */
    object-position: 50% 6%;
}

.card-gradient-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0) 100%);
    pointer-events: none;
}

.card-header-content-overlay {
    position: absolute;
    bottom: 10px;
    left: 10px;
    right: 10px;
    color: white;
    z-index: 10;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.card-header-content-overlay .card-title {
    color: white;
    font-size: 1.1rem;
    margin-bottom: 2px;
}

.card-header-content-overlay .card-date {
    color: rgba(255, 255, 255, 0.9);
}

.card-header-bg {
    padding: 10px;
    /* Default pastel color, will be overridden by JS randomizer or category */
    background: #FFD1DC;
    color: #333;
    /* Dark text on pastel */
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.card-header-bg.blue {
    background: #D1E8FF;
}

.card-header-bg.green {
    background: #D1FFD6;
}

.card-header-bg.yellow {
    background: #FFFAD1;
}

.card-header-bg.purple {
    background: #E8D1FF;
}

.card-logo {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    margin-right: 12px;
}

.card-title-area {
    flex: 1;
}

.card-title {
    font-weight: 600;
    font-size: 1rem;
    line-height: 1.2;
    margin-bottom: 4px;
    color: #000;
}

.card-date {
    font-size: 0.8rem;
    color: #444;
    display: flex;
    align-items: center;
    gap: 4px;
}

.card-body {
    padding: 15px;
}

.code-block {
    background: transparent;
    border: 2px dashed #E0E7FF;
    border-radius: 12px;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.code-block:hover {
    background: rgba(139, 92, 246, 0.05);
    /* very light primary */
    border-color: var(--primary);
    transform: translateY(-1px);
}

.coupon-code {
    font-family: 'Courier New', monospace;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 1px;
    color: #000000;
}

.codes-container {
    padding: 4px 0;
}

.codes-container .code-block {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.codes-container .code-block:active {
    transform: scale(0.98);
}

.card-description {
    font-size: 0.85rem;
    color: #000000;
    line-height: 1.4;
    margin-bottom: 10px;
    white-space: pre-wrap;
    display: -webkit-box;
    -webkit-line-clamp: 5;
    line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-actions-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

/* Toggles */
.switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}

.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: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    -webkit-transition: .4s;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--primary);
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--primary);
}

input:checked+.slider:before {
    -webkit-transform: translateX(16px);
    -ms-transform: translateX(16px);
    transform: translateX(16px);
}

/* Hidden utility */
.hidden {
    display: none !important;
}

/* Filters */
.filters-container {
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 5px;
}

.filters-container::-webkit-scrollbar {
    display: none;
}



.chip:hover {
    border-color: var(--text-muted);
    color: var(--text-main);
}

.chip.active {
    background: rgba(88, 166, 255, 0.15);
    border-color: var(--primary);
    color: var(--primary);
}

/* Grid */
.coupon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95);
    transition: transform 0.2s ease;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-overlay.open .modal {
    transform: scale(1);
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mod.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #000000;
    margin-bottom: 6px;
    padding: 20px;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
}

.modal-body {
    padding: 20px;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px;
}

.close-btn:hover {
    color: var(--text-main);
    background: rgba(0, 0, 0, 0.05);
    border-radius: 50%;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    background: #0d1117;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: #fff;
    font-family: inherit;
    font-size: 0.95rem;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
}

.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: #0d1117;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-block {
    width: 100%;
}

/* Utility */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mb-4 {
    margin-bottom: 1rem;
}

/* Loading Spinner */
.loader-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-color);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(88, 166, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 16px;
}

/* Detail Modal Text */
.detail-condition {
    white-space: pre-wrap;
    display: block;
    line-height: 1.5;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.tag {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    font-size: 0.75rem;
    margin-right: 4px;
    color: var(--text-muted);
}

.tag-expired {
    background: rgba(218, 54, 51, 0.15);
    color: #ff7b72;
}

.tag-used {
    background: rgba(35, 134, 54, 0.15);
    color: #3fb950;
}

/* Category Selection List */
.category-item {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
    font-weight: 500;
}

.category-item:hover {
    background: var(--bg-color);
}

.category-item.active {
    color: var(--primary);
    background: var(--bg-color);
}

.category-item:last-child {
    border-bottom: none;
}

/* Icon Buttons & Tooltips */
.icon-btn {
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: transparent;
}

.icon-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
    /* Light hover for light cards */
    transform: scale(1.15);
}

/* Dark mode adjustment if needed, but cards have specific colors. 
   For dark theme broadly: */
@media (prefers-color-scheme: dark) {
    .icon-btn:hover {
        background-color: rgba(255, 255, 255, 0.1);
    }
}

/* Custom Tooltip using data-title */
.icon-btn[data-title]:hover::after {
    content: attr(data-title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    white-space: nowrap;
    pointer-events: none;
    z-index: 100;
    opacity: 0;
    animation: tooltip-fade 0.2s forwards;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    font-weight: 500;
}

/* Arrow for tooltip */
.icon-btn[data-title]:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-3px);
    border-width: 5px;
    border-style: solid;
    border-color: rgba(0, 0, 0, 0.85) transparent transparent transparent;
    opacity: 0;
    animation: tooltip-fade 0.2s forwards;
}

@keyframes tooltip-fade {
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}


/* Toast Notification */
.toast-container {
    position: fixed;
    bottom: 80px;
    /* Above bottom nav */
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 2000;
    pointer-events: none;
}

.toast {
    background: rgba(30, 30, 30, 0.95);
    color: #fff;
    padding: 12px 24px;
    border-radius: 50px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--danger);
}

/* Share Sheet (Bottom Sheet) */
.share-sheet-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1500;
    display: flex;
    align-items: flex-end;
    /* Bottom sheet */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.share-sheet-overlay.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.share-sheet {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    background: var(--card-bg);
    border-radius: 24px 24px 0 0;
    padding: 0;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.1);
}

.share-sheet-overlay.open .share-sheet {
    transform: translateY(0);
}

/* Drag Handle */
.share-sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--border-color);
    border-radius: var(--radius-full);
    margin: 12px auto;
}

.share-sheet-header {
    padding: 0 20px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.share-sheet-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.share-sheet-body {
    flex: 1;
    overflow-y: auto;
    padding: 15px 20px;
}

.share-sheet-search {
    margin-bottom: 20px;
}

.share-user-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.share-user-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.share-user-item:hover {
    background: var(--bg-color);
}

.share-user-avatar {
    width: 44px;
    height: 44px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}

.share-user-info {
    flex: 1;
}

.share-user-name {
    font-weight: 500;
    font-size: 0.95rem;
}

.share-user-id {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Custom Checkbox */
.share-checkbox {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: transparent;
}

.share-user-item.selected .share-checkbox {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.share-sheet-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.share-send-btn {
    width: 100%;
    height: 50px;
    border-radius: var(--radius-full);
    font-size: 1rem;
    background: var(--primary);
    color: white;
}

.share-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}