@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap');

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow-x: hidden;
}

:root {
    /* Default Dark Theme */
    --bg-color: #0f0f13;
    --text-color: #ffffff;
    --primary-color: #007aff;
    --secondary-color: #5ac8fa;
    --glass-bg: rgba(28, 28, 30, 0.65);
    --glass-border: rgba(255, 255, 255, 0.1);
    --card-bg: rgba(44, 44, 46, 0.6);
    --success-color: #34c759;
    --danger-color: #ff3b30;
    --warning-color: #ffcc00;
    --nav-height: 80px; /* Increased for better touch area on mobile */
}

/* Telegram Theme */
[data-theme="telegram"] {
    --bg-color: var(--tg-theme-bg-color, #ffffff);
    --text-color: var(--tg-theme-text-color, #000000);
    --primary-color: var(--tg-theme-button-color, #3390ec);
    --secondary-color: var(--tg-theme-link-color, #3390ec);
    --glass-bg: var(--tg-theme-secondary-bg-color, #f1f1f1);
    --glass-border: rgba(0, 0, 0, 0.1);
    --card-bg: var(--tg-theme-bg-color, #ffffff);
    --success-color: #34c759;
    --danger-color: #ff3b30;
    --warning-color: #ffcc00;
}

/* Light Theme */
[data-theme="light"] {
    --bg-color: #f2f2f7;
    --text-color: #000000;
    --primary-color: #007aff;
    --secondary-color: #5ac8fa;
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(0, 0, 0, 0.1);
    --card-bg: #ffffff;
    --success-color: #34c759;
    --danger-color: #ff3b30;
    --warning-color: #ffcc00;
}

/* Particles */
.particles-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 300px;
    z-index: 0;
    pointer-events: none;
}

/* Utilities */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.full-width { width: 100%; }
.text-muted { color: rgba(255, 255, 255, 0.6); }
.text-gradient {
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Loader */
.loader-container {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-color);
    z-index: 9999;
}
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255,255,255,0.1);
    border-left-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}
@keyframes spin { 100% { transform: rotate(360deg); } }

/* Glassmorphism */
.glass-header {
    position: sticky;
    top: 0;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    padding: 15px 20px;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.glass-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--glass-border);
    height: var(--nav-height);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
    padding-bottom: 20px; /* Safe area for iPhone home bar */
}

.glass-card {
    background: var(--card-bg);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.2);
}

/* Header */
.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: #333;
}
.user-details h2 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}
.balance-badge {
    font-size: 13px;
    color: var(--success-color);
    font-weight: 500;
}

/* Navigation */
.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-color);
    opacity: 0.5;
    font-size: 10px;
    gap: 4px;
    transition: opacity 0.2s, color 0.2s;
}
.nav-item i {
    font-size: 20px;
    margin-bottom: 2px;
}
.nav-item.active {
    opacity: 1;
    color: var(--primary-color);
}

/* Pages */
.pages-container {
    padding: 20px;
    min-height: calc(100vh - var(--nav-height) - 70px);
    display: flex;
    flex-direction: column;
    max-width: 600px; /* Limit width on PC */
    margin: 0 auto; /* Center on PC */
}
.page {
    display: none;
    animation: fadeIn 0.3s ease;
    flex-grow: 1;
    flex-direction: column;
}
.page.active {
    display: flex;
}
.bottom-sheet-layout {
    margin-top: auto; /* Push to bottom */
    padding-bottom: 20px;
}

/* Buttons */
.btn-primary, .btn-secondary {
    border: none;
    border-radius: 12px;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
    text-align: center;
    text-decoration: none;
    display: inline-block;
}
.btn-primary {
    background: var(--primary-color);
    color: #ffffff; /* Always white for primary buttons usually, or use var if needed */
}
.btn-secondary {
    background: var(--input-bg);
    color: var(--text-color);
}
.btn-primary:active, .btn-secondary:active {
    transform: scale(0.96);
    opacity: 0.8;
}
.btn-icon {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 18px;
    cursor: pointer;
}
.floating-btn {
    position: fixed;
    bottom: calc(var(--nav-height) + 20px);
    right: 20px;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.4);
    z-index: 90;
}
.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

/* Keys List */
.key-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.key-info h4 {
    font-size: 15px;
    margin-bottom: 4px;
    color: var(--text-color);
}
.key-status {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--input-bg);
}
.status-active { color: var(--success-color); background: rgba(52, 199, 89, 0.15); }
.status-blocked { color: var(--danger-color); background: rgba(255, 59, 48, 0.15); }
.status-wait { color: var(--warning-color); background: rgba(255, 204, 0, 0.15); }

/* Balance */
.balance-card {
    text-align: center;
    padding: 30px 20px;
}
.balance-card h1 {
    font-size: 36px;
    margin: 10px 0;
}
.balance-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

/* Referral */
.ref-link-box {
    background: rgba(255, 255, 255, 0.1);
    padding: 12px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden; /* Prevent overflow */
}

.ref-link-box span {
    font-family: monospace;
    font-size: 13px;
    color: var(--tg-theme-link-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* Add ellipsis for long links */
    margin-right: 10px;
}

.status-badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-active {
    background: rgba(40, 167, 69, 0.2);
    color: #28a745;
}

.status-blocked {
    background: rgba(220, 53, 69, 0.2);
    color: #dc3545;
}

.service-item {
    margin-bottom: 10px;
    transition: transform 0.1s;
}

.service-item:active {
    transform: scale(0.98);
}

.service-name {
    font-size: 16px;
}

.price-tag {
    background: var(--tg-theme-button-color);
    color: var(--tg-theme-button-text-color);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: bold;
}

.service-details {
    display: flex;
    gap: 10px;
    margin-top: 5px;
    font-size: 11px;
    color: var(--tg-theme-hint-color);
}

.detail-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Support */
.faq-list {
    list-style: none;
}
.faq-list li {
    padding: 15px 0;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-size: 15px;
    color: var(--text-color);
}
.faq-list li:last-child {
    border-bottom: none;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    align-items: flex-end; /* Bottom sheet style */
}
.modal {
    width: 100%;
    background: #1c1c1e;
    border-radius: 20px 20px 0 0;
    padding: 20px;
    max-height: 85vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}
@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.close-btn {
    background: none;
    border: none;
    color: var(--text-color);
    opacity: 0.5;
    font-size: 24px;
    cursor: pointer;
}

/* Slider */
.subs-slider {
    display: flex;
    overflow-x: auto;
    gap: 15px;
    padding-bottom: 10px;
    margin-bottom: 5px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    cursor: grab; /* Mouse cursor for PC */
}
.subs-slider:active {
    cursor: grabbing;
}
.subs-slider::-webkit-scrollbar { display: none; }

/* iOS Dots */
.slider-dots {
    display: flex;
    justify-content: center;
    gap: 15px; /* Increased gap for arrows */
    margin-bottom: 20px;
    align-items: center;
}
.slider-arrow {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--primary-color);
    transition: transform 0.2s, background 0.2s;
}
.slider-arrow:active {
    transform: scale(0.9);
    background: var(--input-bg);
}
.slider-arrow.disabled {
    opacity: 0.3;
    pointer-events: none;
}

.sub-card-large {
    min-width: 85%;
    scroll-snap-align: center;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 20px;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.sub-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.sub-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 15px 0;
}

.stat-box {
    background: var(--input-bg);
    padding: 10px;
    border-radius: 10px;
    text-align: center;
}

.stat-box i {
    font-size: 20px;
    margin-bottom: 5px;
    color: var(--primary-color);
}

.expiry-block {
    background: var(--primary-color);
    color: #ffffff;
    padding: 10px;
    border-radius: 10px;
    text-align: center;
    margin-bottom: 15px;
    font-weight: bold;
}

.sub-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* Ref List */
.ref-item {
    display: flex;
    justify-content: space-between;
    padding: 12px;
    border-bottom: 1px solid var(--glass-border);
}

/* Glass Inputs */
.glass-input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 12px;
    color: var(--text-color);
    font-size: 16px;
    outline: none;
    width: 100%;
}
.glass-input:focus {
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.15);
}
.mb-10 { margin-bottom: 10px; }

/* Flex Utilities */
.d-flex { display: flex; }
.justify-content-between { justify-content: space-between; }
.align-items-center { align-items: center; }
