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

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

:root {
    --bg-primary: #06060f;
    --bg-secondary: #0c0c1d;
    --bg-card: rgba(18, 18, 40, 0.7);
    --bg-card-hover: rgba(28, 28, 60, 0.8);
    --bg-input: rgba(15, 15, 35, 0.9);
    --border-color: rgba(100, 100, 255, 0.08);
    --border-glow: rgba(0, 212, 255, 0.15);
    --text-primary: #e8e8f0;
    --text-secondary: #8888aa;
    --text-muted: #555577;
    --accent-cyan: #00d4ff;
    --accent-violet: #7c3aed;
    --accent-teal: #06d6a0;
    --accent-orange: #ff6b35;
    --accent-pink: #ec4899;
    --gradient-primary: linear-gradient(135deg, #00d4ff 0%, #7c3aed 100%);
    --gradient-glow: linear-gradient(135deg, rgba(0,212,255,0.12) 0%, rgba(124,58,237,0.12) 100%);
    --gradient-card: linear-gradient(145deg, rgba(18,18,40,0.9) 0%, rgba(10,10,25,0.95) 100%);
    --shadow-glow: 0 0 40px rgba(0, 212, 255, 0.08);
    --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* ===== Animated Background ===== */
.bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.bg-animation .orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    animation: float 20s ease-in-out infinite;
}

.bg-animation .orb:nth-child(1) {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(0,212,255,0.15), transparent);
    top: -10%;
    left: -10%;
    animation-duration: 25s;
}

.bg-animation .orb:nth-child(2) {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(124,58,237,0.12), transparent);
    bottom: -10%;
    right: -5%;
    animation-duration: 30s;
    animation-delay: -5s;
}

.bg-animation .orb:nth-child(3) {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(6,214,160,0.08), transparent);
    top: 50%;
    left: 40%;
    animation-duration: 22s;
    animation-delay: -10s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -40px) scale(1.05); }
    50% { transform: translate(-20px, 20px) scale(0.95); }
    75% { transform: translate(40px, 30px) scale(1.02); }
}

/* ===== Grid Pattern ===== */
.grid-pattern {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(100,100,255,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(100,100,255,0.03) 1px, transparent 1px);
    background-size: 60px 60px;
}

/* ===== Layout ===== */
.app-container {
    position: relative;
    z-index: 1;
    min-height: 100vh;
}

/* ===== Auth Page ===== */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-container {
    width: 100%;
    max-width: 460px;
}

.auth-header {
    text-align: center;
    margin-bottom: 40px;
}

.auth-logo {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

.logo-icon {
    width: 56px;
    height: 56px;
    background: var(--gradient-primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.2);
}

.logo-text {
    font-size: 28px;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.auth-subtitle {
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 400;
}

.auth-card {
    background: var(--gradient-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 40px;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-card);
}

.auth-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-input);
    padding: 4px;
    border-radius: var(--radius-full);
    margin-bottom: 32px;
}

.auth-tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    border-radius: var(--radius-full);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    border: none;
    background: transparent;
}

.auth-tab.active {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 212, 255, 0.25);
}

.auth-tab:hover:not(.active) {
    color: var(--text-primary);
}

/* ===== Form Elements ===== */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    transition: var(--transition);
    outline: none;
}

.form-input:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    border-radius: var(--radius-md);
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    width: 100%;
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 20px rgba(0, 212, 255, 0.2);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 212, 255, 0.35);
}

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

.btn-secondary {
    background: rgba(124, 58, 237, 0.15);
    color: var(--accent-violet);
    border: 1px solid rgba(124, 58, 237, 0.2);
}

.btn-secondary:hover {
    background: rgba(124, 58, 237, 0.25);
}

.btn-success {
    background: rgba(6, 214, 160, 0.15);
    color: var(--accent-teal);
    border: 1px solid rgba(6, 214, 160, 0.2);
}

.btn-success:hover {
    background: rgba(6, 214, 160, 0.25);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-sm);
}

/* ===== Dashboard Layout ===== */
.dashboard {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 280px;
    background: var(--gradient-card);
    border-right: 1px solid var(--border-color);
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 10;
    backdrop-filter: blur(20px);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 24px;
    margin-bottom: 32px;
}

.sidebar-logo .logo-icon {
    width: 40px;
    height: 40px;
    font-size: 20px;
}

.sidebar-logo .logo-text {
    font-size: 20px;
}

.sidebar-nav {
    flex: 1;
    padding: 0 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 4px;
}

.nav-item:hover {
    background: rgba(0, 212, 255, 0.05);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--gradient-glow);
    color: var(--accent-cyan);
    border: 1px solid var(--border-glow);
}

.nav-item .nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.sidebar-user {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
}

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

.user-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-code {
    font-size: 12px;
    color: var(--accent-cyan);
    font-family: 'JetBrains Mono', monospace;
}

.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 32px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
}

.page-title {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.page-title span {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===== Cards ===== */
.card {
    background: var(--gradient-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-card);
    transition: var(--transition);
}

.card:hover {
    border-color: var(--border-glow);
    box-shadow: var(--shadow-glow);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    padding: 24px;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.stat-card:nth-child(1)::before { background: var(--gradient-primary); }
.stat-card:nth-child(2)::before { background: linear-gradient(90deg, var(--accent-teal), var(--accent-cyan)); }
.stat-card:nth-child(3)::before { background: linear-gradient(90deg, var(--accent-violet), var(--accent-pink)); }
.stat-card:nth-child(4)::before { background: linear-gradient(90deg, var(--accent-orange), #f59e0b); }

.stat-value {
    font-size: 36px;
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== Connect Box ===== */
.connect-box {
    margin-bottom: 32px;
}

.connect-input-group {
    display: flex;
    gap: 12px;
}

.connect-input-group .form-input {
    flex: 1;
    font-size: 18px;
    padding: 16px 20px;
    letter-spacing: 2px;
    font-family: 'JetBrains Mono', 'Inter', monospace;
    text-align: center;
}

.connect-input-group .btn {
    padding: 16px 32px;
    font-size: 16px;
}

/* ===== Device Grid ===== */
.device-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.device-card {
    padding: 24px;
    cursor: pointer;
}

.device-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.device-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.device-icon.pc { background: rgba(0, 212, 255, 0.1); }
.device-icon.laptop { background: rgba(124, 58, 237, 0.1); }
.device-icon.mobile { background: rgba(6, 214, 160, 0.1); }
.device-icon.tablet { background: rgba(255, 107, 53, 0.1); }

.device-name {
    font-size: 16px;
    font-weight: 600;
}

.device-os {
    font-size: 13px;
    color: var(--text-secondary);
}

.device-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.device-code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    color: var(--accent-cyan);
    background: rgba(0, 212, 255, 0.08);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.online {
    background: rgba(6, 214, 160, 0.12);
    color: var(--accent-teal);
}

.status-badge.offline {
    background: rgba(136, 136, 170, 0.12);
    color: var(--text-secondary);
}

.status-badge.pending {
    background: rgba(255, 107, 53, 0.12);
    color: var(--accent-orange);
}

.status-badge.active {
    background: rgba(0, 212, 255, 0.12);
    color: var(--accent-cyan);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.status-badge.online .status-dot {
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ===== Sessions Table ===== */
.sessions-list {
    margin-top: 16px;
}

.session-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: var(--bg-input);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    transition: var(--transition);
}

.session-item:hover {
    background: var(--bg-card-hover);
}

.session-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.session-details h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

.session-details p {
    font-size: 12px;
    color: var(--text-secondary);
}

.session-actions {
    display: flex;
    gap: 8px;
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--gradient-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 32px;
    width: 90%;
    max-width: 500px;
    backdrop-filter: blur(20px);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    transform: scale(0.9) translateY(20px);
    transition: var(--transition);
}

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.modal-title {
    font-size: 20px;
    font-weight: 700;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.modal-footer {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

/* ===== Remote View Page ===== */
.remote-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.remote-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--gradient-card);
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(20px);
    z-index: 10;
}

.remote-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.remote-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.remote-controls {
    display: flex;
    gap: 8px;
}

.remote-viewport {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    position: relative;
}

.remote-viewport video {
    max-width: 100%;
    max-height: calc(100vh - 60px);
    object-fit: contain;
}

.remote-placeholder {
    text-align: center;
    color: var(--text-secondary);
}

.remote-placeholder .icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.remote-placeholder h3 {
    font-size: 20px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

/* ===== Notifications ===== */
.notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.notification {
    background: var(--gradient-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    min-width: 320px;
    max-width: 400px;
    backdrop-filter: blur(20px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    animation: slideIn 0.3s ease-out;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.notification.success { border-left: 3px solid var(--accent-teal); }
.notification.error { border-left: 3px solid #ef4444; }
.notification.info { border-left: 3px solid var(--accent-cyan); }
.notification.warning { border-left: 3px solid var(--accent-orange); }

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

.notification-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.notification-body {
    flex: 1;
}

.notification-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

.notification-message {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ===== Selection ===== */
.form-select {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    transition: var(--transition);
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%238888aa' viewBox='0 0 16 16'%3E%3Cpath d='M8 12L2 6h12L8 12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
}

.form-select:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

.form-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* ===== Loading Spinner ===== */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1001;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .main-content {
        margin-left: 0;
    }

    .connect-input-group {
        flex-direction: column;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .device-grid {
        grid-template-columns: 1fr;
    }

    .auth-card {
        padding: 24px;
    }
}

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

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

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

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

/* ===== Additional utilities ===== */
.text-center { text-align: center; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }
.w-full { width: 100%; }
