/* --- Modern Secure P2P Chat Styles --- */
:root {
    --bg: #0f172a;           /* Deep Navy */
    --card: #1e293b;         /* Slate Blue */
    --primary: #3b82f6;      /* Modern Blue */
    --secondary: #10b981;    /* Emerald Green */
    --danger: #f43f5e;       /* Rose Red */
    --text: #f8fafc;         /* White */
    --text-muted: #94a3b8;   /* Slate Gray */
    --border: #334155;       /* Muted Border */
}

/* --- Global Reset --- */
* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    outline: none; 
    -webkit-tap-highlight-color: transparent; 
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    height: 100vh;
    display: flex;
    justify-content: center;
    overflow: hidden; /* App feel */
}

/* --- Main App Container --- */
#app-container {
    width: 100%;
    max-width: 500px;
    height: 100%;
    background: var(--card);
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.5);
}

/* --- Login / Entry Menu --- */
#menu {
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.card {
    background: rgba(255, 255, 255, 0.03);
    padding: 24px;
    border-radius: 20px;
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

h2 {
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 1.5rem;
    text-align: center;
}

h3 {
    font-size: 0.75rem;
    margin-bottom: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 700;
}

input {
    width: 100%;
    padding: 14px 18px;
    margin-bottom: 12px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: #0f172a;
    color: white;
    font-size: 16px;
    transition: border-color 0.2s;
}

input:focus {
    border-color: var(--primary);
}

button {
    padding: 14px;
    border-radius: 14px;
    border: none;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
}

.btn-primary { background: var(--primary); color: white; width: 100%; }
.btn-secondary { background: var(--secondary); color: white; width: 100%; }
button:active { transform: scale(0.96); opacity: 0.9; }

.divider {
    text-align: center;
    margin: 25px 0;
    position: relative;
}
.divider::before {
    content: ""; position: absolute; top: 50%; left: 0; width: 100%; height: 1px; background: var(--border);
}
.divider span {
    position: relative; background: var(--card); padding: 0 15px; color: var(--text-muted); font-size: 12px;
}

/* --- Chat Interface --- */
#chat {
    display: none; 
    flex-direction: column;
    height: 100%;
}

header {
    padding: 14px 20px;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

#roomTitle { font-weight: 700; font-size: 1.1rem; letter-spacing: -0.5px; }
#statusIndicator { color: var(--text-muted); font-size: 11px; margin-top: 2px; }

.btn-icon {
    background: rgba(255, 255, 255, 0.1);
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* --- User List Overlay --- */
#userListOverlay {
    position: absolute;
    top: 75px;
    right: 15px;
    background: #1e293b;
    border: 1px solid var(--border);
    padding: 18px;
    border-radius: 18px;
    z-index: 100;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.7);
    min-width: 240px; /* Slightly wider to fit call buttons */
}

.user-list-hidden { display: none; }

#activeUsers li {
    padding: 12px 0;
    color: var(--text);
    font-weight: 600;
    font-size: 14px;
    list-style: none;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Small Call Button in List */
.call-btn-small {
    background: var(--secondary);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    cursor: pointer;
}

.call-btn-small:hover {
    filter: brightness(1.1);
}

.btn-close-list {
    background: var(--border);
    color: white;
    width: 100%;
    margin-top: 12px;
    padding: 8px;
    font-size: 12px;
}

/* --- Call Overlay / Video Interface --- */
#callOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.98);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.video-container {
    position: relative;
    width: 90%;
    max-width: 500px;
    aspect-ratio: 3/4;
    background: #000;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

#remoteVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#localVideo {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 100px;
    height: 140px;
    object-fit: cover;
    border-radius: 12px;
    border: 2px solid var(--card);
    background: #111;
    z-index: 2001;
}

.call-controls {
    margin-top: 30px;
    display: flex;
    gap: 20px;
}

#endCallBtn {
    background: var(--danger);
    color: white;
    padding: 16px 40px;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 700;
    box-shadow: 0 8px 20px rgba(244, 63, 94, 0.3);
}

/* --- Message Bubbles --- */
#messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #0f172a;
    scroll-behavior: smooth;
}

.bubble {
    max-width: 80%;
    padding: 10px 16px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
    position: relative;
    animation: fadeIn 0.2s ease;
}

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

.sent {
    align-self: flex-end;
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.received {
    align-self: flex-start;
    background: var(--border);
    color: white;
    border-bottom-left-radius: 4px;
}

.author {
    display: block;
    font-size: 10px;
    font-weight: 800;
    margin-bottom: 4px;
    opacity: 0.6;
    text-transform: uppercase;
}

/* --- File Handling --- */
.file-link {
    display: block;
    margin-top: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    color: white;
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* --- Input Bar Area --- */
.input-area {
    padding: 12px 16px;
    background: var(--card);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.btn-attachment {
    background: #334155;
    color: white;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
}

#msg {
    flex: 1;
    background-color: #0e172a !important;
    color: white !important;
    border-radius: 24px; /* Matches the pill shape of modern apps */
    padding: 10px 16px;
    border: 1px solid #334155;
    resize: none;
    font-size: 16px;
    font-family: inherit;
    line-height: 1.4;
    overflow-y: hidden;
    height: 42px; /* Fixed initial height */
    min-height: 42px;
    display: block;
    outline: none;
    box-sizing: border-box;
}

#msg::placeholder {
    color: #757575 !important;
    opacity: 1; 
}

#sendBtn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}


/* Logo Styling */
.logo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 2rem 0;
    gap: 12px;
}

.logo-img {
    width: 64px; /* Adjust size as needed */
    height: 64px;
    object-fit: contain;
    border-radius: 12px; /* Optional: rounds the corners of your icon */
    filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.3)); /* Subtle blue glow */
}

.logo-text {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Optional: Add a subtle fade-in for the whole menu */
#menu {
    animation: fadeIn 0.5s ease-out;
}

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

#encryption-controls {
    display: none !important;
}

#encryptionIndicator {
    padding: 6px 12px;
    border-radius: 20px;
    background: rgba(255,255,255,0.08);
    width: fit-content;
}

#encryptionIndicator.encrypted {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

#encryptionIndicator.not-encrypted {
    background: rgba(234, 179, 8, 0.15);
    color: #eab308;
}

.pulse-icon {
    animation: pulse 2s infinite ease-in-out;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}


/* For nice vertical list */
#callUserList {
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.3) transparent;
}

#callUserList::-webkit-scrollbar {
    width: 4px;
}

#callUserList::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.4);
    border-radius: 20px;
}

/* === FULLSCREEN CHAT FIX === */

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* App container */
#app-container {
    height: 100dvh; /* modern mobile fix */
    width: 100%;
    display: flex;
    flex-direction: column;
}

/* CHAT SCREEN */
#chat {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: #0f172a;
    height: 100dvh;
    width: 100%;
    overflow: hidden;
}

/* HEADER */
#chat header {
    flex-shrink: 0;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #1e293b;
    z-index: 10;
}

/* MESSAGES AREA */
#messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;

    /* smooth scroll on iOS */
    -webkit-overflow-scrolling: touch;
}

/* INPUT AREA */
.input-area {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background: #0f172a;
    border-top: 1px solid #1e293b;

    /* iPhone safe area */
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
}

/* TEXTAREA FIX */
#msg {
    flex: 1;
    max-height: 120px;
    overflow-y: auto;
}

/* SEND BUTTON */
#sendBtn {
    flex-shrink: 0;
}

/* MOBILE IMPROVEMENTS */
@media (max-width: 768px) {
    #chat header {
        height: 56px;
        padding: 0 10px;
    }

    #messages {
        padding: 10px;
    }

    .input-area {
        padding: 8px;
    }

    #msg {
        font-size: 16px; /* prevent zoom on iOS */
    }
}


@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); border-color: rgba(239, 68, 68, 0.5); }
    70% { box-shadow: 0 0 0 15px rgba(239, 68, 68, 0); border-color: #ef4444; }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); border-color: rgba(148, 163, 184, 0.3); }
}

.new-message-alert {
    animation: pulse-red 1.5s infinite;
    background: rgba(239, 68, 68, 0.15) !important; /* Slight red tint */
}

/* Futuristic Container */
.progress-wrapper {
    width: 280px;
    padding: 15px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(0, 242, 254, 0.3);
    border-radius: 8px;
    backdrop-filter: blur(10px);
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
    color: #fff;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* File Name */
.file-name {
    font-size: 13px;
    color: #cfefff;
    text-shadow: 0 0 6px rgba(0, 242, 254, 0.4);
    margin-bottom: 12px;
    letter-spacing: 1px;
}

/* ==================== PROGRESS BAR BACKGROUND ==================== */
.progress-bar-bg {
    width: 100%;
    height: 12px;
    background: rgba(20, 20, 30, 0.6);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(0, 242, 254, 0.15);
    box-shadow: 
        inset 0 0 10px rgba(0, 0, 0, 0.6),
        0 0 8px rgba(0, 242, 254, 0.1);
    margin-bottom: 12px;
}

/* ==================== PROGRESS BAR (THE FILLING PART) ==================== */



/* ====================== FUTURISTIC PROGRESS UI ====================== */
.futuristic-progress {
    background: transparent !important;
    padding: 0 !important;
    box-shadow: none !important;
}

.futuristic-progress-wrapper {
    width: 100%;
    max-width: 340px;
    background: rgba(15, 23, 42, 0.96);
    border: 1px solid rgba(0, 242, 254, 0.5);
    border-radius: 16px;
    padding: 18px 20px;
    backdrop-filter: blur(16px);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.6),
        0 0 25px rgba(0, 242, 254, 0.25),
        inset 0 0 20px rgba(0, 242, 254, 0.08);
    position: relative;
    overflow: hidden;
}

/* Glowing animated border */
.futuristic-progress-wrapper::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 18px;
    background: linear-gradient(90deg, 
        transparent, 
        rgba(0, 242, 254, 0.7), 
        transparent);
    animation: borderGlow 2.8s linear infinite;
    z-index: -1;
    opacity: 0.7;
}

@keyframes borderGlow {
    0%   { transform: translateX(-120%); }
    100% { transform: translateX(120%); }
}

/* File Info */
.futuristic-file-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.upload-icon {
    font-size: 22px;
    color: #00f2fe;
    text-shadow: 0 0 12px #00f2fe;
    animation: uploadPulse 2s ease-in-out infinite;
}

.file-name {
    font-size: 14px;
    color: #cfefff;
    font-weight: 500;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Status Row */
.futuristic-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.futuristic-percent {
    font-family: 'Orbitron', monospace;
    font-size: 32px;
    font-weight: 700;
    color: #67e8f9;
    text-shadow: 
        0 0 12px #67e8f9,
        0 0 25px rgba(103, 232, 249, 0.8);
    letter-spacing: 3px;
    line-height: 1;
}

/* Cancel Button */
.futuristic-cancel-btn {
    background: rgba(255, 77, 77, 0.15);
    color: #ff4d4d;
    border: 1px solid rgba(255, 77, 77, 0.6);
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
}

.futuristic-cancel-btn:hover {
    background: rgba(255, 77, 77, 0.25);
    box-shadow: 0 0 15px rgba(255, 77, 77, 0.6);
    transform: translateY(-1px);
}

.futuristic-cancel-btn:active {
    transform: scale(0.95);
}

/* Pulse animation for upload icon */
@keyframes uploadPulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}




.switch { position: relative; display: inline-block; width: 34px; 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: #334155; transition: .4s; border-radius: 20px; }
.slider:before { position: absolute; content: ""; height: 14px; width: 14px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: #10b981; }
input:checked + .slider:before { transform: translateX(14px); }

/* --- Scrollbar --- */
#messages::-webkit-scrollbar { width: 4px; }
#messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }