/* ===== CSS RESET & VARIABLES ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #5d0527;
    --secondary: #FFD700;
    --bg: #1a1a2e;
    --surface: #16213e;
    --text: #ffffff;
    --text-muted: #a0a0b0;
    --success: #00b894;
    --error: #e74c3c;
    --radius-card: 12px;
    --radius-btn: 8px;
    --radius-input: 8px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --transition: 0.2s ease;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--secondary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

img {
    max-width: 100%;
    display: block;
}

ul, ol {
    list-style: none;
}

input, button, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

/* ===== LAYOUT ===== */
.page-wrapper {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 16px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
    padding: 20px 0;
}

/* ===== HEADER / BRANDING ===== */
.brand-header {
    text-align: center;
    padding: 32px 0 16px;
}

.brand-logo {
    width: 80px;
    height: 80px;
    margin: 0 auto 12px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    color: var(--secondary);
    border: 3px solid var(--secondary);
}

img.brand-logo {
    display: block;
    object-fit: cover;
    background: none;
}

.brand-title {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--secondary);
}

.brand-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ===== TABS ===== */
.tabs {
    display: flex;
    border-radius: var(--radius-btn);
    overflow: hidden;
    background: rgba(255, 255, 255, 0.05);
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    padding: 12px 16px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    min-height: 44px;
}

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

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ===== FORMS ===== */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 500;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-input);
    color: var(--text);
    font-size: 1rem;
    transition: var(--transition);
    min-height: 44px;
}

.form-input:focus {
    outline: none;
    border-color: var(--secondary);
    background: rgba(255, 255, 255, 0.12);
}

.form-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.phone-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.phone-prefix {
    padding: 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-input);
    color: var(--text-muted);
    font-size: 0.95rem;
    white-space: nowrap;
    min-height: 44px;
    display: flex;
    align-items: center;
}

.phone-input-wrapper .form-input {
    flex: 1;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-btn);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    min-height: 44px;
    text-align: center;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: #7a0a35;
}

.btn-secondary {
    background: transparent;
    color: var(--secondary);
    border: 2px solid var(--secondary);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 215, 0, 0.1);
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-success:hover:not(:disabled) {
    background: #00a884;
}

.btn-gold {
    background: var(--secondary);
    color: #1a1a2e;
    font-weight: 700;
}

.btn-gold:hover:not(:disabled) {
    background: #e6c200;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
    width: auto;
    min-height: 36px;
}

.btn-link {
    background: none;
    border: none;
    color: var(--secondary);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 4px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

/* ===== CARDS ===== */
.card {
    background: var(--surface);
    border-radius: var(--radius-card);
    padding: 20px;
    margin-bottom: 16px;
}

.card-header {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 12px;
}

/* ===== PLAN CARDS ===== */
.plans-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.plan-card {
    background: var(--surface);
    border-radius: var(--radius-card);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid rgba(255, 255, 255, 0.06);
    position: relative;
}

.plan-card:hover {
    border-color: var(--secondary);
    transform: translateY(-1px);
}

.plan-card.popular {
    border-color: var(--secondary);
}

.plan-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(93, 5, 39, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.plan-info {
    flex: 1;
    min-width: 0;
}

.plan-name {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 2px;
}

.plan-duration {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.plan-price {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--secondary);
    white-space: nowrap;
}

.plan-price-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
}

.badge {
    position: absolute;
    top: -8px;
    right: 12px;
    background: var(--secondary);
    color: var(--bg);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 10px;
    text-transform: uppercase;
}

/* ===== VOUCHER CODE DISPLAY ===== */
.voucher-display {
    font-family: 'Courier New', monospace;
    font-size: 1.8rem;
    letter-spacing: 3px;
    font-weight: bold;
    color: #FFD700;
    background: rgba(255, 215, 0, 0.1);
    padding: 16px 24px;
    border-radius: 12px;
    border: 2px dashed #FFD700;
    text-align: center;
    word-break: break-all;
}

/* ===== LOADING SPINNER ===== */
.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-left-color: var(--secondary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

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

.loading-section {
    text-align: center;
    padding: 40px 0;
}

.loading-section .spinner {
    margin-bottom: 20px;
}

.loading-text {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 8px;
}

/* ===== MESSAGES ===== */
.msg {
    padding: 12px 16px;
    border-radius: var(--radius-btn);
    font-size: 0.9rem;
    margin-bottom: 16px;
    display: none;
}

.msg.show {
    display: block;
}

.msg-error {
    background: rgba(231, 76, 60, 0.15);
    color: var(--error);
    border: 1px solid rgba(231, 76, 60, 0.3);
}

.msg-success {
    background: rgba(0, 184, 148, 0.15);
    color: var(--success);
    border: 1px solid rgba(0, 184, 148, 0.3);
}

.msg-info {
    background: rgba(255, 215, 0, 0.1);
    color: var(--secondary);
    border: 1px solid rgba(255, 215, 0, 0.2);
}

/* ===== PROGRESS BAR ===== */
.progress-bar-wrapper {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin: 12px 0;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--secondary));
    border-radius: 4px;
    transition: width 1s linear;
    width: 100%;
}

.progress-bar.low {
    background: linear-gradient(90deg, var(--error), #ff6b6b);
}

/* ===== COUNTDOWN ===== */
.countdown {
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
    font-family: 'Courier New', monospace;
    letter-spacing: 2px;
    color: var(--text);
    margin: 8px 0;
}

.countdown.warning {
    color: var(--error);
}

/* ===== DIVIDER ===== */
.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 24px 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
}

.divider-line {
    width: 100%;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 24px 0;
}

/* ===== TABLES ===== */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 12px 0;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    min-width: 400px;
}

.table th {
    background: rgba(255, 255, 255, 0.05);
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.table td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text);
}

.table tr:last-child td {
    border-bottom: none;
}

/* ===== FOOTER ===== */
.page-footer {
    text-align: center;
    padding: 20px 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.page-footer p {
    margin-bottom: 4px;
}

/* ===== BACK BUTTON ===== */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 8px 0;
    min-height: 44px;
    cursor: pointer;
    background: none;
    border: none;
    font-family: var(--font);
}

.back-link:hover {
    color: var(--text);
    text-decoration: none;
}

/* ===== SECTION HEADERS ===== */
.section-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.section-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}

/* ===== CONNECTED PAGE ===== */
.connected-icon {
    font-size: 3rem;
    text-align: center;
    margin-bottom: 8px;
}

.session-card {
    background: var(--surface);
    border-radius: var(--radius-card);
    padding: 24px 20px;
    text-align: center;
    margin-bottom: 16px;
}

.session-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.session-info {
    font-size: 0.95rem;
    margin-top: 12px;
}

.session-info span {
    color: var(--text-muted);
}

/* ===== WHATSAPP SECTION ===== */
.whatsapp-section {
    background: var(--surface);
    border-radius: var(--radius-card);
    padding: 20px;
    text-align: center;
    margin-bottom: 16px;
}

.whatsapp-section h3 {
    font-size: 1rem;
    margin-bottom: 12px;
}

.whatsapp-section .menu-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 12px;
}

.btn-whatsapp {
    background: #25D366;
    color: #fff;
    font-weight: 600;
}

.btn-whatsapp:hover:not(:disabled) {
    background: #20bd5a;
}

/* ===== PROMO SECTION ===== */
.promo-section {
    background: var(--surface);
    border-radius: var(--radius-card);
    padding: 20px;
    text-align: center;
    margin-bottom: 16px;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.promo-section strong {
    color: var(--secondary);
}

/* ===== EXPIRED STATE ===== */
.expired-section {
    text-align: center;
    padding: 32px 0;
}

.expired-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

.expired-section h2 {
    font-size: 1.2rem;
    margin-bottom: 16px;
    color: var(--error);
}

/* ===== ADMIN PAGE ===== */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    flex-wrap: wrap;
    gap: 8px;
}

.admin-header h1 {
    font-size: 1.1rem;
    color: var(--secondary);
    letter-spacing: 1px;
}

.admin-greeting {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.admin-logout {
    font-size: 0.85rem;
    color: var(--error);
    cursor: pointer;
    background: none;
    border: none;
    font-family: var(--font);
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.revenue-cards {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
}

.revenue-card {
    background: var(--surface);
    border-radius: var(--radius-card);
    padding: 12px;
    text-align: center;
}

.revenue-card .label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.revenue-card .amount {
    font-size: 1rem;
    font-weight: 700;
    color: var(--secondary);
}

.stats-row {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.stat-item {
    flex: 1;
    background: var(--surface);
    border-radius: var(--radius-card);
    padding: 12px;
    text-align: center;
}

.stat-item .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
}

.stat-item .stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.admin-section-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.admin-form-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    margin-bottom: 12px;
}

.admin-form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

.admin-form-row .btn {
    width: auto;
    flex-shrink: 0;
    padding: 12px 20px;
}

.admin-result {
    padding: 12px;
    background: rgba(0, 184, 148, 0.1);
    border-radius: var(--radius-btn);
    font-size: 0.85rem;
    margin-top: 8px;
    display: none;
}

.admin-result.show {
    display: block;
}

.admin-refresh-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 12px;
}

.form-select {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-input);
    color: var(--text);
    font-size: 1rem;
    min-height: 44px;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%23a0a0b0' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

.form-select:focus {
    outline: none;
    border-color: var(--secondary);
}

.form-select option {
    background: var(--surface);
    color: var(--text);
}

/* ===== PAYMENT PAGE ===== */
.plan-summary {
    background: var(--surface);
    border-radius: var(--radius-card);
    padding: 16px 20px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.plan-summary-name {
    font-weight: 600;
    font-size: 1rem;
}

.plan-summary-duration {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.plan-summary-price {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--secondary);
}

.payment-note {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 12px;
}

.payment-success {
    text-align: center;
    padding: 20px 0;
}

.payment-success .check-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

.payment-success h2 {
    color: var(--success);
    margin-bottom: 16px;
}

.payment-success .voucher-display {
    margin: 20px 0;
}

.payment-success .voucher-info {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.btn-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}

/* ===== UTILITY CLASSES ===== */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-muted);
}

.text-gold {
    color: var(--secondary);
}

.text-success {
    color: var(--success);
}

.text-error {
    color: var(--error);
}

.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }

.copy-feedback {
    font-size: 0.8rem;
    color: var(--success);
    opacity: 0;
    transition: opacity 0.3s;
}

.copy-feedback.show {
    opacity: 1;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 380px) {
    .revenue-cards {
        grid-template-columns: 1fr;
    }

    .revenue-card .amount {
        font-size: 0.9rem;
    }

    .plan-summary {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .countdown {
        font-size: 2rem;
    }

    .voucher-display {
        font-size: 1.4rem;
        padding: 12px 16px;
    }
}

/* ===== MIKROTIK SYNC ===== */
.mikrotik-sync-bar {
    background: rgba(255, 165, 0, 0.1);
    border: 1px solid rgba(255, 165, 0, 0.3);
    border-radius: 8px;
    padding: 12px 16px;
    margin: 12px 0;
}
.sync-warning {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
}
.sync-icon {
    font-size: 1.2rem;
    color: #f39c12;
}
#sync-msg {
    color: #f39c12;
    font-size: 0.9rem;
    flex: 1;
}
.btn-sync {
    background: rgba(255, 165, 0, 0.15);
    border: 1px solid rgba(255, 165, 0, 0.4);
    color: #f39c12;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    transition: background 0.2s;
}
.btn-sync:hover {
    background: rgba(255, 165, 0, 0.25);
}
.btn-sync:disabled {
    opacity: 0.5;
    cursor: default;
}
