:root {
    --bg-main: #0a0e17;
    --bg-secondary: #131b2c;
    --text-main: #ffffff;
    --text-muted: #a0aec0;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --accent: #8b5cf6;
    --success: #22c55e;
    --danger: #ef4444;
    --card-bg: rgba(19, 27, 44, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --glow: rgba(99, 102, 241, 0.3);
}

.light-theme {
    --bg-main: #f8fafc;
    --bg-secondary: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --card-bg: rgba(255, 255, 255, 0.9);
    --border-color: rgba(0, 0, 0, 0.1);
    --glow: rgba(99, 102, 241, 0.15);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 3rem;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    transition: transform 0.2s;
}

.icon-btn:hover {
    transform: scale(1.1);
}

.container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
}

.view {
    display: none;
    width: 100%;
    text-align: center;
    animation: fadeIn 0.4s ease forwards;
}

.view.active {
    display: flex;
    flex-direction: column;
    align-items: center;
}

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

.glow-text {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 0 0 20px var(--glow);
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.2rem;
    margin-bottom: 3rem;
}

.cards-container {
    display: flex;
    gap: 2rem;
    justify-content: center;
    flex-wrap: wrap;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2.5rem;
    width: 280px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
    box-shadow: 0 10px 30px var(--glow);
}

.icon-wrapper {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
    margin: 0 auto 1.5rem auto;
}

.sender-gradient {
    background: linear-gradient(135deg, var(--primary), var(--accent));
}

.receiver-gradient {
    background: linear-gradient(135deg, #10b981, #059669);
}

.card h3 {
    margin-bottom: 0.5rem;
}

.card p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Sender & Receiver UI */
.qr-container {
    background: white;
    padding: 1rem;
    border-radius: 12px;
    display: inline-block;
    margin: 2rem 0;
}

.session-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.session-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.session-id-display {
    font-family: monospace;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
}

.input-group {
    display: flex;
    gap: 0.5rem;
    margin: 2rem 0;
    width: 100%;
    max-width: 400px;
}

.input-group input {
    flex: 1;
    padding: 1rem 1.5rem;
    border-radius: 50px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-main);
    font-size: 1rem;
    font-family: monospace;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--glow);
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    border: none;
    border-radius: 50px;
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.2s;
}

.primary-btn.sm {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.primary-btn:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

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

.ghost-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem 1rem;
    font-size: 1rem;
    transition: color 0.2s;
}

.ghost-btn:hover {
    color: var(--text-main);
}

.mt-2 { margin-top: 1rem; }

/* Connected Transfer Zone */
.connection-status {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.transfer-workspace {
    width: 100%;
    max-width: 800px;
    display: grid;
    gap: 2rem;
}

.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 16px;
    padding: 4rem 2rem;
    background: var(--bg-secondary);
    transition: all 0.3s ease;
    cursor: pointer;
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.drop-zone i {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

.drop-zone h3 {
    margin-bottom: 0.5rem;
}

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

.files-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

.file-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
    overflow: hidden;
}

.file-icon {
    font-size: 2rem;
    color: var(--primary);
}

.file-details {
    flex: 1;
    text-align: left;
    z-index: 1;
}

.file-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
    word-break: break-all;
}

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

.file-progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 4px;
    background: var(--primary);
    width: 0%;
    transition: width 0.1s linear;
}

/* Toasts */
#toastContainer {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
}

.toast {
    background: var(--bg-secondary);
    border-left: 4px solid var(--primary);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    animation: slideIn 0.3s ease forwards;
    color: var(--text-main);
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@media (max-width: 768px) {
    .cards-container { flex-direction: column; }
    .card { width: 100%; max-width: 350px; }
    .session-box { flex-direction: column; text-align: center; }
}

/* Custom Elements for Global Connect */
.code-box {
    width: 100%;
    padding: 1rem;
    background: var(--bg-main);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.8rem;
    font-family: monospace;
    resize: vertical;
    outline: none;
    word-break: break-all;
}
.code-box:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--glow);
}

/* --- Messenger / WhatsApp Layout --- */
.chat-layout {
    display: flex;
    height: calc(100vh - 85px);
    width: 100%;
    margin: 0;
    overflow: hidden;
    background: var(--bg-secondary);
}

.sidebar {
    width: 320px;
    background: var(--bg-main);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.sidebar-header {
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.chat-item {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-item:hover, .chat-item.active {
    background: rgba(99, 102, 241, 0.1);
}

.chat-item-name {
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.chat-item-preview {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-main);
    position: relative;
}

.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.active-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.chat-header {
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.chat-title {
    font-size: 1.2rem;
    font-weight: 700;
}

.chat-messages {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.msg-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 75%;
}

.msg-wrapper.sent {
    align-self: flex-end;
}

.msg-wrapper.received {
    align-self: flex-start;
}

.msg-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    position: relative;
    word-break: break-word;
    font-size: 0.95rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.msg-wrapper.sent .msg-bubble {
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 2px;
}

.msg-wrapper.received .msg-bubble {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-bottom-left-radius: 2px;
}

.msg-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
    display: block;
}
.msg-wrapper.sent .msg-time { text-align: right; }

.chat-input-area {
    padding: 1rem 1.5rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-input-area input[type="text"] {
    flex: 1;
    padding: 12px 20px;
    border-radius: 50px;
    border: 1px solid var(--border-color);
    background: var(--bg-main);
    color: var(--text-main);
    font-size: 1rem;
    outline: none;
}
.chat-input-area input[type="text"]:focus {
    border-color: var(--primary);
}

.typing-indicator {
    font-size: 0.8rem;
    color: var(--primary);
    padding: 0 1.5rem 0.5rem 1.5rem;
    font-style: italic;
}

.media-attachment {
    max-width: 300px;
    border-radius: 8px;
    margin-bottom: 5px;
    display: block;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}
.modal {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 2rem;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

/* A/V Calls */
.call-overlay {
    background: rgba(10, 14, 23, 0.95);
}
.call-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 800px;
    padding: 2rem;
}
.video-grid {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin: 2rem 0;
    position: relative;
    width: 100%;
    height: 60vh;
    background: #000;
    border-radius: 16px;
    overflow: hidden;
}
#remoteVideo {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
#localVideo {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 150px;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    background: #222;
}
.call-controls {
    display: flex;
    gap: 20px;
}
.call-btn {
    width: 60px; height: 60px;
    border-radius: 50%;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex; justify-content: center; align-items: center;
}
.call-btn.accept { background: var(--success); }
.call-btn.reject { background: var(--danger); }
.call-btn:hover { filter: brightness(1.2); }

@media (max-width: 768px) {
    .sidebar { width: 100%; position: absolute; top: 0; bottom: 0; left: 0; z-index: 20; }
    .sidebar.hidden { display: none; }
}
