/* 
  Premium Dark Mode P2P File Share CSS 
  Viewport and Gestures fully locked down 
*/

:root {
    --bg-dark: #f0f2f5;
    --bg-surface: #ffffff;
    --bg-surface-elevated: #e4e6eb;
    --primary-color: #0f3870; /* Shkar Deep Blue */
    --primary-hover: #0c2d5a;
    --text-primary: #1c1e21;
    --text-secondary: #65676b;
    --accent-blue: #0f3870;
    --danger: #d31f26; /* Shkar Red */
    
    /* Sent (You) vs Received (Peer) Chat bubbles */
    --msg-sent-bg: #e1f5fe;
    --msg-sent-border: #b3e5fc;
    --msg-recv-bg: #ffffff;
    --msg-recv-border: #d31f26;
    
    --transition-speed: 0.3s;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    overflow: hidden; /* Prevent body scroll to lock UI */
    width: 100vw;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport for nested mobile browsers */
    
    /* Zoom & Selection Lockdowns */
    touch-action: manipulation; 
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    user-select: none; /* Disables selection */
    -webkit-user-select: none;
}

/* Force 75% Zoom on Mobile as requested */
@media (max-width: 600px) {
    html {
        zoom: 75%;
        -moz-transform: scale(0.75);
        -moz-transform-origin: top center;
    }
}

/* Allow text selection only inside specific areas if needed, but per prompt lockdown is strong */
input[type="text"] {
    user-select: text;
    -webkit-user-select: text;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-speed) ease-in-out;
    z-index: 10;
}

.screen.active {
    opacity: 1;
    pointer-events: all;
    z-index: 20;
}

/* ================= LOGIN SCREEN ================= */

.login-container {
    margin: auto;
    background: var(--bg-surface);
    padding: 2.5rem;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    text-align: center;
    width: 90%;
    max-width: 400px;
    border: 1px solid rgba(0,0,0,0.1);
    position: relative; /* For info button positioning */
}

.logo {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.login-container h1 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.login-container p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#passcode-input {
    width: 100%;
    padding: 1.2rem;
    font-size: 2.5rem;
    letter-spacing: 0.8rem; /* Wide spacing for a dialer look */
    text-align: center;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid var(--bg-surface-elevated);
    color: var(--primary-color);
    border-radius: 16px;
    outline: none;
    transition: all var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 800;
    font-family: 'Inter', sans-serif;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border: 2px solid transparent;
    background-image: linear-gradient(white, white), linear-gradient(to right, #0f3870, #007bff);
    background-origin: border-box;
    background-clip: padding-box, border-box;
}

#passcode-input:focus {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px rgba(15, 56, 112, 0.3);
    outline: none;
}

#connect-btn {
    padding: 1.2rem;
    font-size: 1.1rem;
    font-weight: 600;
    background: var(--primary-color);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    color: white;
    transition: background var(--transition-speed), transform 0.1s, opacity 0.2s;
}

#connect-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--text-secondary);
}

#connect-btn:active {
    transform: scale(0.98);
}

#connect-btn:hover {
    background: var(--primary-hover);
}

.status-msg {
    margin-top: 1rem;
    font-size: 0.9rem;
    color: var(--accent-blue);
    min-height: 1.5em;
}

.info-icon-btn {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    opacity: 0.8;
    cursor: pointer;
    z-index: 30;
    transition: all 0.2s ease;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.info-icon-btn:hover {
    transform: translateX(-50%) scale(1.1);
    color: var(--primary-color);
    opacity: 1;
}

/* ================= TRANSFER SCREEN ================= */

.app-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0 1.2rem;
    background: var(--bg-surface);
    border-bottom: 1px solid rgba(0,0,0,0.1);
    height: 60px;
    flex-shrink: 0;
}

.connection-status {
    font-size: 0.85rem;
    font-weight: 600;
    margin-right: auto;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ccc;
    transition: all 0.3s ease;
}

.status-dot.online {
    background: #4caf50;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

.status-dot.offline {
    background: #d31f26;
    box-shadow: 0 0 10px rgba(211, 31, 38, 0.5);
}

.status-dot.connecting {
    background: #ff9800;
    animation: status-pulse 1s infinite alternate;
}

@keyframes status-pulse {
    from { opacity: 0.4; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1.1); }
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

@media (max-width: 380px) {
    .app-header {
        padding: 0 0.6rem;
    }
}

/* Pill Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-surface-elevated);
    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-color);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

.toggle-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    transition: background 0.2s, color 0.2s;
}

.icon-btn:hover {
    background: rgba(255,255,255,0.1);
    color: var(--danger);
}

/* Chat Layout Log */
.transfer-log {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1.2rem;
    background: var(--bg-dark);
    align-content: start;
    position: relative;
}

.status-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-secondary);
    width: 80%;
    pointer-events: none;
}

.status-placeholder p {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--primary-color);
    margin-top: 1rem;
}

.status-placeholder span {
    font-size: 0.85rem;
    opacity: 0.7;
}

.pulse-icon {
    color: var(--primary-color);
    opacity: 0.3;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 0.3; }
    50% { transform: scale(1.1); opacity: 0.5; }
    100% { transform: scale(1); opacity: 0.3; }
}

/* Custom Scrollbar */
.transfer-log::-webkit-scrollbar {
    width: 8px;
}
.transfer-log::-webkit-scrollbar-thumb {
    background: var(--bg-surface-elevated);
    border-radius: 4px;
}

.log-info-msg {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin: 1rem 0;
    background: rgba(0,0,0,0.05);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    align-self: center;
}

/* Message Bubbles */
.transfer-bubble {
    display: flex;
    flex-direction: column;
    width: 100%;
    margin-bottom: 0;
    transition: opacity 0.3s ease;
}

.transfer-bubble.pending {
    opacity: 0.5;
}

.transfer-bubble.pending .bubble-content {
    border-style: dashed;
    border-color: var(--text-secondary);
}

.transfer-bubble.pending .progress-bar-container {
    visibility: hidden;
}

.transfer-bubble.sent, .transfer-bubble.recv {
    align-self: stretch;
}

.bubble-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
}

.file-number {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--primary-color);
    background: rgba(0,0,0,0.05);
    padding: 2px 6px;
    border-radius: 4px;
}

.bubble-status-label {
    flex: 1;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bubble-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.bubble-content {
    padding: 1rem;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.transfer-bubble.sent .bubble-content {
    background: var(--msg-sent-bg);
    border: 1px solid var(--msg-sent-border);
}

.transfer-bubble.recv .bubble-content {
    background: var(--msg-recv-bg);
    border: 1px solid var(--msg-recv-border);
}

.file-info {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.file-name {
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.transfer-bubble.sent .file-meta {
    color: #a5d6a7;
}

.transfer-bubble.recv .file-meta {
    color: #9fa8da;
}

.progress-bar-container {
    margin-top: 1rem;
    height: 12px;
    background: rgba(0,0,0,0.05);
    border-radius: 10px;
    position: relative;
    overflow: visible; /* To allow label to sit nicely */
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #007bff, #00c6ff);
    border-radius: 10px;
    transition: width 0.1s linear;
    position: relative;
    box-shadow: 0 1px 4px rgba(0,123,255,0.3);
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    animation: shimmer 1.5s infinite;
}

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

.progress-percent {
    position: absolute;
    right: 0;
    top: -18px;
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--primary-color);
    font-family: 'Inter', sans-serif;
}

.transfer-bubble.recv .progress-bar {
    background: var(--accent-blue);
}

.image-preview {
    margin-top: 0.8rem;
    width: 100%;
    height: 120px;
    border-radius: 8px;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.2s;
    background: rgba(0,0,0,0.05);
}

.image-preview:active {
    transform: scale(0.98);
}

.file-type-placeholder {
    margin-top: 0.8rem;
    width: 100%;
    height: 120px;
    border-radius: 8px;
    background: rgba(0,0,0,0.02);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed rgba(0,0,0,0.05);
    transition: transform 0.2s;
}

.file-type-text {
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--primary-color);
    opacity: 0.3;
    letter-spacing: 1px;
}

/* Action Buttons per item */
.item-actions {
    margin-top: 0.8rem;
    display: flex;
    justify-content: flex-start;
}

.download-icon-btn {
    background: var(--primary-color);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.2s, transform 0.1s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.download-icon-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.download-icon-btn:active {
    transform: translateY(0);
}



.file-input-wrapper {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 50;
}

#file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.fab-btn {
    width: 60px;
    height: 60px;
    background: #007bff; /* Vibrant Blue from the image */
    color: white;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.4);
    transition: transform 0.2s, background 0.2s;
    pointer-events: none; /* Let clicks pass through to hidden input */
}

.file-input-wrapper:hover .fab-btn {
    background: #0069d9;
    transform: scale(1.05);
}

.file-input-wrapper:active .fab-btn {
    transform: scale(0.95);
}

/* ================= LIGHTBOX ================= */
.lightbox {
    position: fixed;
    inset: 0;
    width: auto;
    height: auto;
    background: rgba(0,0,0,0.95);
    z-index: 11000;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.lightbox.active {
    opacity: 1;
    pointer-events: all;
}

.lightbox-header {
    display: flex;
    justify-content: space-between;
    padding: 1rem;
    background: linear-gradient(to bottom, rgba(0,0,0,0.9), rgba(0,0,0,0.4) 60%, transparent);
    position: absolute;
    top: 0;
    width: 100%;
    z-index: 101;
}

.lightbox-header .icon-btn {
    background: rgba(0,0,0,0.5);
    color: white;
    backdrop-filter: blur(5px);
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.lightbox-header .icon-btn:hover {
    background: var(--primary-color);
}

.lightbox-actions {
    display: flex;
    gap: 1rem;
}

.lightbox-content-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

#lightbox-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform-origin: center center;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    width: 100%;
    display: flex;
    justify-content: space-between;
    transform: translateY(-50%);
    padding: 0 1rem;
    pointer-events: none; /* Let clicks fall through except on buttons */
    z-index: 102;
}

.nav-btn {
    pointer-events: all;
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    transition: background 0.2s, transform 0.2s;
}

.nav-btn:hover {
    background: rgba(0,0,0,0.8);
    transform: scale(1.1);
}

/* ================= DRAG & DROP ================= */
#transfer-screen {
    transition: background-color 0.2s ease, opacity 0.2s ease;
}

#transfer-screen.drag-active {
    background-color: var(--bg-surface-elevated);
    opacity: 0.9;
}

/* Modal System (from Dama) */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 19, 24, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 250ms ease;
    z-index: 9999;
}

.modal-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    width: min(460px, calc(100vw - 20px));
    border-radius: 20px;
    padding: 24px;
    background: #ffffff;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(0, 0, 0, 0.1);
    transform: translateY(20px) scale(0.95);
    transition: transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-backdrop.show .modal {
    transform: translateY(0) scale(1);
}

#transfer-screen.drag-active::after {
    content: 'Drop files to send...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
    pointer-events: none;
    z-index: 1000;
}



/* ================= RESPONSIVE BREAKPOINTS ================= */
@media (min-width: 768px) {
    .app-footer {
        padding: 1rem 1.5rem;
    }
    
    .primary-btn {
        max-width: 300px;
    }
    
    .transfer-log {
        padding: 2rem 5%;
    }
}

@media (min-width: 1024px) {
    .transfer-log {
        padding: 2rem 8%;
    }
}
