@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #0f172a;
    /* Deepest Blue */
    --primary-light: #1e293b;
    /* Slate 800 */
    --accent: #3b82f6;
    /* Blue 500 */
    --accent-hover: #2563eb;
    /* Blue 600 */
    --text-main: #f8fafc;
    /* Slate 50 */
    --text-muted: #cbd5e1;
    /* Slate 300 */
    --border: rgba(255, 255, 255, 0.1);
    --input-bg: rgba(30, 41, 59, 0.5);
    /* Semi-transparent slate */
    --card-bg: rgba(15, 23, 42, 0.85);
    --radius: 16px;
    --shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
}

* {
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    background-color: #020617;
    /* Very dark background */
    background-image:
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.15) 0px, transparent 50%);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
}

.app-container {
    width: 100%;
    max-width: 440px;
    min-height: 500px;
    /* Instead of fixed height to prevent overlap */
    background: var(--card-bg);
    border: 1px solid var(--border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px;
    display: flex;
    flex-direction: column;
    position: relative;
    /* overflow: hidden; Removed to allow dropdowns/popups if needed, usually safer */
    transition: height 0.3s ease;
}

/* Header */
/* Header */
header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
}

.logo img {
    height: 40px;
    /* Adjust based on logo aspect ratio */
    width: auto;
    object-fit: contain;
}

.user-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.auth-status {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

.auth-btn {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.2s;
}

.auth-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.btn-action {
    background: var(--accent);
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.4);
}

.btn-action:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(59, 130, 246, 0.5);
    color: white;
}

.login-tip {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 20px;
}

/* Layout */
main {
    flex: 1;
    /* Allow main to fill available space */
    position: relative;
    /* For absolute positioning of sections if needed, but flex is better */
    width: 100%;
    display: flex;
    flex-direction: column;
}

section {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.hidden {
    display: none !important;
}

/* Auth Screen */
.auth-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: #fff;
    text-align: center;
    margin: 10px 0 5px 0;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
    margin: 0 0 25px 0;
}

.input-group {
    width: 100%;
}

input {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border);
    padding: 14px 16px;
    border-radius: 10px;
    color: #fff;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s;
    outline: none;
}

input:focus {
    border-color: var(--accent);
    background: rgba(30, 41, 59, 0.8);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

button,
.btn-sso {
    width: 100%;
    padding: 14px;
    border-radius: 10px;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    transition: all 0.2s;
}

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

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

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.btn-sso {
    background: #fff;
    color: #0f172a;
    border: 1px solid #e2e8f0;
    font-weight: 600;
    margin-bottom: 0px;
    /* Reset margins */
}

.btn-sso:hover {
    background: #f1f5f9;
}

.btn-sso img {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.or-divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin: 10px 0;
}

.or-divider::before,
.or-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border);
}

.or-divider span {
    padding: 0 10px;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

/* Room Code Box - Refined */
.room-box {
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 16px;
    padding: 30px 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    transition: transform 0.2s;
}

.room-box:hover {
    background: rgba(59, 130, 246, 0.12);
}

.room-box h3 {
    margin: 0;
    font-size: 0.85rem;
    color: var(--accent);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.code-value {
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 3rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: 6px;
    line-height: 1;
    cursor: pointer;
    text-shadow: 0 2px 10px rgba(59, 130, 246, 0.3);
}

/* Share Button */
.btn-share {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    margin-top: 5px;
}

.btn-share:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.btn-share svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* Auth Screens Spacing */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    /* Increased gap */
}

/* Spacer utilities */
.spacer-lg {
    height: 30px;
}

.spacer-md {
    height: 20px;
}

.spacer-sm {
    height: 10px;
}

/* Or Divider - More breathing room */
.or-divider {
    margin: 25px 0;
    color: rgba(255, 255, 255, 0.3);
}

/* Buttons - larger touch targets */
button,
.btn-sso {
    padding: 16px;
    /* Larger padding */
    font-size: 1.05rem;
}

/* Join Section */
.join-section {
    background: rgba(255, 255, 255, 0.03);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Device List */
.device-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
    max-height: 150px;
    /* Prevent it from taking too much space */
    overflow-y: auto;
}

.device-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 10px;
    transition: all 0.2s;
    cursor: pointer;
}

.device-item:hover {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.1);
}

.device-name {
    font-weight: 600;
    color: #fff;
    font-size: 0.95rem;
}

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

/* Transfer UI */
.transfer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.device-badge {
    background: rgba(16, 185, 129, 0.1);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.2);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
}

.drop-area {
    border: 2px dashed var(--border);
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 10px;
}

.drop-area:hover {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.05);
}

.drop-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.8;
}

.file-list {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 250px;
    overflow-y: auto;
}

.file-item {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 12px;
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
}

.file-icon {
    font-size: 1.5rem;
    margin-right: 15px;
}

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

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

.file-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--accent);
    width: 0%;
    transition: width 0.2s;
    box-shadow: 0 0 10px var(--accent);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive Desktop Layout */
@media (min-width: 768px) {
    .app-container {
        max-width: 900px;
        padding: 40px;
    }

    /* Init Screen Grid */
    .init-options {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        gap: 30px;
        align-items: center;
    }

    /* Assign grid areas */
    .init-left {
        grid-column: 1;
        width: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .init-right {
        grid-column: 3;
        height: 100%;
        /* Vertical centering happens via flex below */
        display: flex;
        flex-direction: column;
        justify-content: center;
        width: 100%;
    }

    /* Ensure room box and join section take full width of their columns */
    .room-box,
    #create-room-btn-container,
    .join-section,
    #my-devices-container,
    .login-tip {
        width: 100%;
    }

    /* Vertical Divider - Scoped to Init Screen */
    .init-options .or-divider {
        grid-column: 2;
        display: flex;
        flex-direction: column;
        height: 100%;
        margin: 0;
        width: 40px;
        justify-content: center;
    }

    .init-options .or-divider::before,
    .init-options .or-divider::after {
        border-bottom: none;
        border-left: 1px solid var(--border);
        width: 1px;
        height: 100%;
    }

    .init-options .or-divider span {
        padding: 10px 0;
        writing-mode: vertical-rl;
        text-orientation: upright;
        letter-spacing: 2px;
    }

    /* Auth Screen adjustments */
    #auth-screen .auth-form {
        max-width: 400px;
        margin: 0 auto;
    }
}