/* css/style.css */
:root {
    --bg-color: #f4f4f5;
    --card-bg: #ffffff;
    --text-main: #111827;
    --text-muted: #6b7280;
    --primary-blue: #2f80ed;
    --primary-blue-gradient: linear-gradient(135deg, #4492ef, #2f80ed);
    --secondary-bg: #e5e7eb;
    --nav-icon-color: #9ca3af;
    --nav-icon-active: #2f80ed;
    --border-color: #e5e7eb;
    --app-max-width: 480px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

input, textarea {
    -webkit-user-select: auto;
    -moz-user-select: auto;
    -ms-user-select: auto;
    user-select: auto;
}

body {
    background-color: #e5e5e5; /* Background behind the app container */
    display: flex;
    justify-content: center;
}

.app-container {
    width: 100%;
    max-width: var(--app-max-width);
    min-height: 100vh;
    background-color: var(--bg-color);
    position: relative;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

/* Utilities */
.text-center { text-align: center; }
.text-sm { font-size: 0.875rem; }
.text-xl { font-size: 1.25rem; }
.text-gray { color: var(--text-muted); }
.text-blue { color: var(--primary-blue); }
.text-red { color: #ef4444; }
.fw-400 { font-weight: 400; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mt-8 { margin-top: 3rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mb-5 { margin-bottom: 2rem; }
.pb-2 { padding-bottom: 0.5rem; }
.ms-2 { margin-left: 0.5rem; }
.ms-3 { margin-left: 1rem; }
.ms-auto { margin-left: auto; }
.d-flex { display: flex; }
.flex-row { flex-direction: row; }
.flex-column { flex-direction: column; }
.align-center { align-items: center; }
.align-start { align-items: flex-start; }
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.w-100 { width: 100%; }
.mb-3 { margin-bottom: 1rem; }
.px-3 { padding-left: 1rem; padding-right: 1rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.border-bottom { border-bottom: 1px solid var(--border-color); }
.bg-light-blue { background-color: #eff6ff; }
.bg-light-red { background-color: #fef2f2; }
.text-decoration-none { text-decoration: none; }

/* Top Bar */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    position: relative;
    z-index: 100;
}

.top-left {
    display: flex;
    align-items: center;
    background-color: var(--secondary-bg);
    padding: 4px 12px 4px 4px;
    border-radius: 24px;
    cursor: pointer;
}

.profile-pic {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 8px;
    object-fit: cover;
}

.balance-badge {
    display: flex;
    align-items: center;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-main);
}

.coin-icon {
    margin-right: 4px;
    font-size: 1rem;
}
.coin-icon.lg {
    font-size: 1.5rem;
}

.balance-amount {
    margin-right: 6px;
}

.top-right {
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background-color: var(--secondary-bg);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 1.1rem;
}

/* Dropdown */
.dropdown-menu {
    position: absolute;
    top: 60px;
    left: 16px;
    background-color: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    width: 220px;
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 1000;
}

.dropdown-menu.show {
    display: flex;
}

.dropdown-item {
    padding: 16px;
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--text-main);
    font-weight: 400;
    border-bottom: 1px solid var(--border-color);
}
.dropdown-item:last-child {
    border-bottom: none;
}
.dropdown-item i:first-child {
    width: 24px;
    font-size: 1.1rem;
    color: var(--text-main);
    text-align: center;
    margin-right: 12px;
}

/* Main Content & Tabs */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px 80px 20px;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}
.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Overlay Page (Top Up) */
.page-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    min-height: 100%;
    background-color: var(--bg-color);
    z-index: 50;
    padding: 20px 20px 80px 20px;
    overflow-y: auto;
    box-sizing: border-box;
}
.page-overlay.active {
    display: block;
}

/* Hero Section */
.hero-section {
    padding-top: 20px;
}
.hero-image {
    display: inline-flex;
    justify-content: center;
    align-items: center;
}
.hero-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-main);
    margin-top: 12px;
}
.hero-subtitle {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-top: 8px;
    line-height: 1.4;
}

/* Buttons */
.action-buttons {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}
.btn {
    flex: 1;
    padding: 14px;
    border-radius: 12px;
    border: none;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: opacity 0.2s;
    transform: translateZ(0); /* Fixes WebKit ghosting artifacts on layout shift */
}
.btn:active {
    opacity: 0.8;
}
.btn-primary {
    background: var(--primary-blue-gradient);
    color: white;
}
.shadow-blue {
    box-shadow: 0 4px 12px rgba(47, 128, 237, 0.4);
}
.btn-secondary {
    background-color: #e5eaf2;
    color: var(--primary-blue);
}
.btn-text {
    background: none;
    border: none;
    font-weight: 500;
    font-size: 1rem;
    cursor: pointer;
}

/* Promo Banner */
.promo-banner {
    background-color: #dbeafe;
    color: #1e40af;
    padding: 16px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 400;
    cursor: pointer;
}

/* Sections & Cards */
.section-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: block;
    text-transform: uppercase;
    font-weight: 400;
}
.card {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}
.card.p-0 {
    padding: 0;
}
.card.p-3 {
    padding: 16px;
}
.card-row {
    padding: 16px;
    display: flex;
    align-items: center;
}
.interactive-card {
    cursor: pointer;
    transition: background-color 0.2s;
}
.interactive-card:active {
    background-color: #f9fafb;
}

/* Stats */
.stat-card {
    text-align: center;
    padding: 24px 16px;
}
.stat-value {
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--text-main);
}
.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
    display: block;
}
.blur-bottom {
    opacity: 0.5;
    position: relative;
}
.blur-bottom::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0; height: 100%;
    background: linear-gradient(to top, var(--bg-color) 20%, transparent);
    pointer-events: none;
}

/* Inputs & Forms */
.clean-input {
    border: none;
    outline: none;
    font-size: 1.1rem;
    width: 100%;
    color: var(--text-main);
    background: transparent;
}
.preset-chips {
    display: flex;
    gap: 8px;
    justify-content: space-between;
}
.chip {
    flex: 1;
    padding: 8px 0;
    background-color: var(--card-bg);
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
}

/* Payment Options */
.payment-methods {
    overflow: hidden;
}
.payment-option {
    display: flex;
    align-items: center;
    padding: 16px;
    cursor: pointer;
}
.payment-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
}

/* Tooltip Styles */
.tooltip-wrapper:hover .tooltip-box { display: block; }
.tooltip-box {
    display: none; position: absolute; bottom: calc(100% + 10px); left: -20px; transform: none;
    background-color: #000; color: #fff; padding: 10px 14px; border-radius: 8px;
    font-size: 0.75rem; white-space: normal !important; width: 220px; text-align: left;
    z-index: 1001; line-height: 1.5; box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    box-sizing: border-box; word-wrap: break-word; text-transform: none !important; font-weight: 300 !important;
}
.tooltip-box::after {
    content: ""; position: absolute; top: 100%; left: 22px;
    border-width: 5px; border-style: solid; border-color: #000 transparent transparent transparent;
}
.tooltip-box.show { display: block; }

/* Custom Font classes */
.custom-radio {
    position: relative;
    width: 24px;
    height: 24px;
}
.custom-radio input {
    opacity: 0;
    width: 0;
    height: 0;
}
.radio-mark {
    position: absolute;
    top: 0; left: 0; width: 24px; height: 24px;
    border: 2px solid #d1d5db;
    border-radius: 50%;
    background-color: transparent;
    transition: all 0.2s;
}
.custom-radio input:checked ~ .radio-mark {
    border-color: var(--primary-blue);
    border-width: 7px;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    width: 100%;
    max-width: var(--app-max-width);
    display: flex;
    background-color: #f9fafb;
    border-top: 1px solid var(--border-color);
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 100;
}
.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 0 22px 0;
    border: none;
    background: none;
    color: var(--nav-icon-color);
    cursor: pointer;
    transition: color 0.2s;
}
.nav-item i {
    font-size: 1.15rem;
    margin-bottom: 4px;
}
.nav-item span {
    font-size: 0.65rem;
    font-weight: 400;
}
.nav-item.active {
    color: var(--nav-icon-active);
}
/* Form Controls */
.form-control-custom {
    width: 100%; padding: 14px 16px; border-radius: 12px;
    border: none; background-color: #fff; font-size: 0.95rem;
    color: #111; font-family: inherit; margin-top: 8px;
    box-sizing: border-box; outline: none;
}
.form-control-custom::placeholder { color: #9ca3af; }
textarea.form-control-custom { resize: vertical; min-height: 100px; }

/* Target Pills */
.target-pills { display: flex; gap: 8px; margin-top: 8px; }
.target-pill { 
    flex: 1; padding: 10px 0; border-radius: 20px; 
    text-align: center; font-size: 0.85rem; font-weight: 500;
    color: #6b7280; background-color: transparent; cursor: pointer;
    transition: all 0.2s; border: none; outline: none;
    display: flex; align-items: center; justify-content: center; gap: 6px;
}
.target-pill.active { background-color: var(--primary-blue); color: #fff; }

/* Badges & Buttons */
.ai-badge {
    background-color: #f3e8ff; color: #7e22ce; 
    font-size: 0.65rem; font-weight: 600; padding: 4px 8px;
    border-radius: 6px; display: inline-flex; align-items: center; gap: 4px;
}
.btn-upload {
    width: 100%; background-color: #dbeafe; color: var(--primary-blue);
    border: none; border-radius: 12px; padding: 14px 0;
    font-weight: 500; font-size: 0.95rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 8px;
}

/* Radio & Limit Options */
.status-radio-card {
    background-color: #fff; border-radius: 12px; padding: 16px;
    display: flex; flex-direction: column; gap: 16px; margin-top: 8px;
}
.status-option { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.status-option .radio-circle {
    width: 20px; height: 20px; border-radius: 50%; border: 2px solid #d1d5db;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.status-option.active .radio-circle { border-color: var(--primary-blue); }
.status-option.active .radio-circle::after {
    content: ""; width: 10px; height: 10px; border-radius: 50%;
    background-color: var(--primary-blue);
}
.limit-group { display: flex; gap: 4px; background-color: #fff; padding: 6px; border-radius: 12px; margin-top: 8px; }
.limit-btn {
    flex: 1; padding: 12px 0; text-align: center; font-weight: 500;
    color: #111; background-color: transparent; border: none; border-radius: 8px; cursor: pointer;
}
.limit-btn.active { background-color: var(--primary-blue); color: #fff; }
.percent-group { display: flex; gap: 8px; margin-top: 8px; }
.percent-btn {
    flex: 1; padding: 8px 0; background-color: #fff; border: none;
    border-radius: 8px; font-size: 0.8rem; font-weight: 500; color: #6b7280; cursor: pointer;
}

/* Preview Box */
.preview-box {
    background-color: #d1f2a5; /* Fallback color */
    background-image: url('../assets/bg-ad.jpeg');
    background-size: cover;
    background-position: center;
    border-radius: 12px; padding: 20px; margin-top: 8px;
    position: relative; overflow: hidden; display: flex; flex-direction: column;
}
/* A subtle pattern overlay for the preview box */
.preview-box::before {
    display: none;
}
.preview-ad {
    background-color: #f4f4f5; border-radius: 16px; border-bottom-left-radius: 4px;
    padding: 12px; position: relative; max-width: 85%; border-left: 3px solid var(--primary-blue);
    z-index: 1; margin-bottom: 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.preview-ad .ad-badge { color: var(--primary-blue); font-weight: 600; font-size: 0.9rem; }
.preview-ad .ad-whats-this {
    background-color: #93c5fd; color: #fff; font-size: 0.6rem; padding: 2px 6px; border-radius: 10px; margin-left: 6px; vertical-align: middle;
}
.preview-ad .ad-line { background-color: #cbd5e1; height: 8px; border-radius: 4px; margin-top: 8px; }
.preview-ad .ad-btn {
    border-top: 1px solid #d1d5db; margin-top: 12px; padding-top: 8px;
    color: var(--primary-blue); font-weight: 600; font-size: 0.85rem; text-align: center;
}
.preview-footer {
    background-color: #fff; margin: 0 -20px -20px -20px; padding: 12px 20px;
    display: flex; justify-content: space-between; align-items: center; z-index: 1; position: relative;
    color: #60a5fa; font-weight: 500; font-size: 0.9rem;
}
.preview-close { position: absolute; top: 12px; right: 12px; color: #111; opacity: 0.6; z-index: 2; }
.preview-more { position: absolute; top: 32px; right: 12px; color: #111; opacity: 0.6; z-index: 2; }

/* Custom Switch for profile picture */
.switch-wrapper {
    background-color: #fff; padding: 16px; border-radius: 12px; margin-top: 8px;
    display: flex; align-items: center; justify-content: flex-start; gap: 12px;
}
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc; transition: .4s; border-radius: 24px;
}
.slider:before {
    position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px;
    background-color: white; transition: .4s; border-radius: 50%;
}
input:checked + .slider { background-color: var(--primary-blue); }
input:checked + .slider:before { transform: translateX(20px); }

/* Shimmer Animation for New Ad button */
.btn-shimmer {
    position: relative;
    overflow: hidden;
}
.btn-shimmer::after {
    content: '';
    position: absolute;
    top: 0;
    left: -150%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.4) 50%, rgba(255,255,255,0) 100%);
    transform: skewX(-25deg);
    animation: shimmerEffect 3s infinite;
}
@keyframes shimmerEffect {
    0% { left: -150%; }
    15% { left: 150%; }
    100% { left: 150%; }
}

/* Ads Grid Mode Layout */
#ads-container.grid-mode {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 12px !important;
}
#ads-container.grid-mode .ad-item-card {
    margin-bottom: 0 !important;
}
#ads-container.grid-mode .ad-item-card .d-flex.flex-wrap {
    flex-direction: column;
    gap: 12px !important;
}
