/* ===== Global styles and shared components ===== */

/* Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    -webkit-tap-highlight-color: transparent;
    background: #ffffff; /* Default background: white */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    color: #1f2937;
    overflow-x: hidden;
}

/* Container */
.app-container {
    max-width: 430px;
    margin: 0 auto;
    /* Mobile address bar/safe area: 100dvh is more accurate in modern browsers */
    min-height: 100vh;
    min-height: 100dvh;
    background: #ffffff;
    position: relative;
    /* Reserve space for fixed bottom nav + iPhone safe area */
    padding-bottom: 70px;
    padding-bottom: calc(70px + env(safe-area-inset-bottom));

    display: flex;
    flex-direction: column;
}


/* Page header (shared) */
.page-header {
    background: transparent;
    /* Notch safe area padding */
    padding: 8px 16px 16px;
    padding: calc(8px + env(safe-area-inset-top)) 16px 16px;

    position: relative;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 16px;
}


/* Search box */
.search-box {
    flex: 1;
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 20px;
    padding: 8px 14px;
    gap: 8px;
    transition: background 0.2s;
}

.search-box:active {
    background: rgba(0, 0, 0, 0.1);
}

.search-icon {
    font-size: 20px;
    opacity: 0.5;
}

.search-text {
    font-size: 14px;
    color: #6b7280;
}

/* Tabs */
.tab-bar {
    display: flex;
    gap: 20px;
}

.tab-item {
    background: none;
    border: none;
    font-size: 18px;
    font-weight: 700;
    color: #9ca3af;
    padding: 4px 0;
    cursor: pointer;
    position: relative;
    transition: all 0.3s;
    white-space: nowrap;
}

.tab-item.active {
    color: #1f2937;
    font-size: 20px;
}

.tab-item.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 3px;
    background: #8b5cf6;
    border-radius: 2px;
}

/* Content area */
.content-area {
    flex: 1;
    padding: 0 16px 20px;
}

/* Bottom navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    max-width: 430px;
    width: 100%;
    /* Bottom safe area: avoid iPhone home indicator overlap */
    height: 64px;
    height: calc(64px + env(safe-area-inset-bottom));
    padding-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);

    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    z-index: 1000;
}


.nav-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 100%;
    text-decoration: none;
    color: #9ca3af;
    transition: all 0.3s;
}

.nav-item .material-symbols-rounded {
    font-size: 28px;
}

.nav-item.active {
    color: #8b5cf6;
}

.nav-item.active .material-symbols-rounded {
    font-variation-settings: 'FILL' 1;
    transform: scale(1.1);
}

/* Badge */
.badge {
    position: absolute;
    top: 10px;
    right: 12px;
    background: #ef4444;
    color: #ffffff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    line-height: 1;
    border: 2px solid #ffffff;
}

/* ===== Top incoming message toast (shared) ===== */

.top-msg-toast {
    position: fixed;
    top: calc(10px + env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%) translateY(-10px);

    width: calc(100% - 24px);
    max-width: 410px;

    display: flex;
    align-items: center;
    gap: 10px;

    padding: 10px 12px;
    border-radius: 16px;

    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(17, 24, 39, 0.08);
    box-shadow: 0 10px 26px rgba(17, 24, 39, 0.18);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);

    opacity: 0;
    pointer-events: none;

    z-index: 2400;

    transition: transform 0.18s ease, opacity 0.18s ease;
}

.top-msg-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
    cursor: pointer;
}

.toast-avatar {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    object-fit: cover;
    flex-shrink: 0;
    background: rgba(17, 24, 39, 0.06);
}

.toast-body {
    flex: 1;
    min-width: 0;
}

.toast-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.toast-name {
    font-size: 14px;
    font-weight: 900;
    color: #111827;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.toast-gender {
    font-size: 16px;
}

.toast-online {
    font-size: 12px;
}

.toast-text {
    margin-top: 2px;
    font-size: 13px;
    color: #6b7280;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gender-female {
    font-size: 16px;
    color: #ff3d71;
    font-variation-settings: 'FILL' 1;
}

.gender-male {
    font-size: 16px;
    color: #3b82f6;
    font-variation-settings: 'FILL' 1;
}

.online-status {
    font-size: 12px;
    color: #22c55e;
    font-weight: 500;
}

.online-status.offline {
    color: #9ca3af;
}

/* Button defaults */
button {
    font-family: inherit;
    border: none;
    background: none;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

button:active {
    opacity: 0.7;
    transform: scale(0.95);
}

/* Image defaults */
img {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Scrollbar styles */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}


/* ===== Video call popup (shared) ===== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2600;
}

.call-modal {
    width: 85%;
    max-width: 320px;
    height: 480px;
    background: #000;
    border-radius: 32px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.modal-bg-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.modal-bg-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.8;
}

.modal-content {
    position: relative;
    z-index: 2;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 60px 20px 40px;
    background: linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, 0.4) 50%, rgba(0, 0, 0, 0.8) 100%);
    color: #ffffff;
}

.caller-avatar-wrapper {
    margin-bottom: 20px;
    position: relative;
}

.avatar-circle {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.4);
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    animation: avatar-pulse 2s infinite ease-in-out;
}

.avatar-circle::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border: 2px solid rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    animation: ripple-out 2s infinite ease-out;
}

@keyframes avatar-pulse {
    0%, 100% {
        transform: scale(1);
        border-color: rgba(255, 255, 255, 0.4);
    }
    50% {
        transform: scale(1.12);
        border-color: rgba(255, 255, 255, 0.7);
    }
}

@keyframes ripple-out {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

.avatar-circle img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #ffffff;
}

.caller-name {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.call-type {
    font-size: 15px;
    font-weight: 500;
    opacity: 0.9;
    margin-bottom: auto;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.call-actions {
    display: flex;
    gap: 40px;
    margin-bottom: 20px;
}

.call-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.call-btn:active {
    transform: scale(0.9);
}

.call-btn .material-symbols-rounded {
    font-size: 32px;
    color: #ffffff;
}

.call-btn.decline {
    background: #ff4b4b;
    box-shadow: 0 8px 20px rgba(255, 75, 75, 0.4);
}

.call-btn.accept {
    background: #22c55e;
    box-shadow: 0 8px 20px rgba(34, 197, 94, 0.4);
}


/* Insufficient balance alert (triggered on call accept) */

.alert-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.alert-modal {
    width: 280px;
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    text-align: center;
    animation: alert-pop 0.2s ease-out;
}

@keyframes alert-pop {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.alert-content {
    padding: 24px 20px;
}

.alert-title {
    font-size: 18px;
    font-weight: 600;
    color: #000;
    margin-bottom: 8px;
}

.alert-message {
    font-size: 14px;
    color: #999;
}

.alert-actions {
    display: flex;
    border-top: 1px solid #eee;
}

.alert-btn {
    flex: 1;
    padding: 12px 0;
    font-size: 17px;
    background: none;
    border: none;
    cursor: pointer;
}

.alert-btn.cancel {
    color: #000;
    border-right: 1px solid #eee;
}

.alert-btn.recharge {
    color: #007bff;
    font-weight: 500;
}

.alert-btn:active {
    background: #f9f9f9;
}

