body { font-family: 'Inter', sans-serif; }
.glass-effect { background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(10px); }
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

.toast-enter { animation: slideIn 0.3s ease-out forwards; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.fade-in { animation: fadeIn 0.2s ease-in; }
@keyframes fadeIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
.sort-icon { font-size: 0.7rem; margin-left: 8px; color: #cbd5e1; transition: color 0.2s; }
th:hover .sort-icon { color: #94a3b8; }
.sort-active { color: #4f46e5 !important; }
.map-root { position: relative; padding-top: 1rem; }
.map-branch { position: relative; margin-left: 5rem; padding-top: 0.5rem; transition: all 0.3s ease-in-out; }
.map-branch.collapsed { display: none; }
.tree-node { position: relative; padding-left: 6rem; margin-bottom: 1.5rem; }
.tree-node::before { content: ""; position: absolute; left: 0; top: -1.5rem; bottom: 0; width: 2px; background: #cbd5e1; }
.tree-node::after { content: ""; position: absolute; left: 0; top: 2.25rem; width: 6rem; height: 2px; background: #cbd5e1; }
.map-root > .tree-node::before, .map-root > .tree-node::after { display: none; }
.map-root > .tree-node { padding-left: 0; }
.tree-node:last-child::before { bottom: auto; height: 3.75rem; }
.port-connector-badge { position: absolute; left: -0.5rem; top: 1.6rem; transform: translateX(-100%); background: #6366f1; color: white; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 800; z-index: 20; box-shadow: 0 2px 6px rgba(99, 102, 241, 0.4); white-space: nowrap; }
.switch-chassis { background-color: #0f172a; background-image: repeating-linear-gradient(0deg, transparent, transparent 1px, rgba(255,255,255,0.02) 1px, rgba(255,255,255,0.02) 2px), linear-gradient(180deg, #1e293b 0%, #0f172a 100%); border: 2px solid #334155; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.1); overflow: visible !important; }
.rack-ear { width: 40px; background: #1e293b; border: 2px solid #334155; display: flex; flex-direction: column; justify-content: space-around; align-items: center; padding: 20px 0; flex-shrink: 0; }
.rack-screw { width: 14px; height: 14px; background: radial-gradient(circle at 30% 30%, #94a3b8, #475569); border-radius: 50%; box-shadow: inset -1px -1px 2px rgba(0,0,0,0.5), 1px 1px 2px rgba(255,255,255,0.1); }
.port-socket { width: 48px; height: 56px; background: #000; border-radius: 4px; position: relative; border: 1px solid #334155; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); cursor: pointer; z-index: 10; }
.port-socket:hover { border-color: #6366f1; transform: scale(1.1); z-index: 100; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.led-indicator { width: 12px; height: 4px; border-radius: 1px; position: absolute; top: 6px; left: 50%; transform: translateX(-50%); transition: all 0.3s; background: #1e2937; }
.led-active { background: #10b981; box-shadow: 0 0 10px #10b981, 0 0 20px rgba(16,185,129,0.4); }
.led-error { background: #ef4444; box-shadow: 0 0 10px #ef4444, 0 0 20px rgba(239,68,68,0.4); }
.port-label { position: absolute; bottom: 4px; left: 0; right: 0; text-align: center; font-size: 15px; font-weight: 900; color: #cbd5e1; z-index: 20; pointer-events: none; }
.port-socket:hover .port-label { color: #fff; }
.toggle-icon { transition: transform 0.2s ease; }
.collapsed-node .toggle-icon { transform: rotate(-90deg); }
.explore-card { transition: all 0.2s; border: 1px dashed #cbd5e1; }
.explore-card:hover { border-color: #6366f1; background: #f8fafc; transform: translateY(-2px); box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); }

/* NEW ANIMATIONS FOR DISCOVERY & LOGO */
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}
.animate-bounce { animation: bounce 2s infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
.animate-pulse { animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; }

/* Connection line and port highlighting */
@keyframes heartbeat {
    0%, 100% { 
        opacity: 0.8; 
        stroke-width: 4;
    }
    50% { 
        opacity: 1; 
        stroke-width: 6;
    }
}

.line-highlight {
    animation: heartbeat 1.2s ease-in-out infinite !important;
}

.port-highlight {
    animation: port-pulse 1.2s ease-in-out infinite !important;
    border-color: #fbbf24 !important;
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.6), 0 0 40px rgba(251, 191, 36, 0.3) !important;
    z-index: 200 !important;
}

@keyframes port-pulse {
    0%, 100% { 
        transform: scale(1); 
        box-shadow: 0 0 20px rgba(251, 191, 36, 0.6), 0 0 40px rgba(251, 191, 36, 0.3);
    }
    50% { 
        transform: scale(1.1); 
        box-shadow: 0 0 30px rgba(251, 191, 36, 0.8), 0 0 60px rgba(251, 191, 36, 0.5);
    }
}

/* Search result ports - do not change colors; only add arrow */
.search-result-port {
    z-index: 150 !important;
}

.search-result-arrow {
    position: absolute;
    top: -16px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 14px;
    animation: bounce-arrow 1.5s ease-in-out infinite;
    z-index: 200;
    pointer-events: none;
}

/* Red arrow for Down/offline ports */
.search-result-arrow.down {
    color: #ef4444;
}

/* Green arrow for Up/online ports */
.search-result-arrow.up {
    color: #10b981;
}

@keyframes bounce-arrow {
    0%, 100% { 
        transform: translateX(-50%) translateY(0);
        opacity: 0.8;
    }
    50% { 
        transform: translateX(-50%) translateY(-6px);
        opacity: 1;
    }
}

@keyframes search-pulse {
    0%, 100% { 
        transform: scale(1); 
        box-shadow: 0 0 15px rgba(99, 102, 241, 0.5), 0 0 30px rgba(99, 102, 241, 0.2);
        border-color: #6366f1;
    }
    50% { 
        transform: scale(1.08); 
        box-shadow: 0 0 25px rgba(99, 102, 241, 0.7), 0 0 50px rgba(99, 102, 241, 0.4);
        border-color: #818cf8;
    }
}

@keyframes search-pulse-red {
    0%, 100% { 
        transform: scale(1); 
        box-shadow: 0 0 15px rgba(239, 68, 68, 0.5), 0 0 30px rgba(239, 68, 68, 0.2);
    }
    50% { 
        transform: scale(1.08); 
        box-shadow: 0 0 25px rgba(239, 68, 68, 0.7), 0 0 50px rgba(239, 68, 68, 0.4);
    }
}

/* MODERN LOGO HOVER ANIMATION */
@keyframes logoFloat {
    0%, 100% { transform: translateY(0px) scale(1) rotate(0deg); }
    25% { transform: translateY(-8px) scale(1.08) rotate(-2deg); }
    50% { transform: translateY(-12px) scale(1.12) rotate(3deg); }
    75% { transform: translateY(-6px) scale(1.06) rotate(-1deg); }
}

@keyframes logoGlow {
    0%, 100% { filter: drop-shadow(0 10px 15px rgba(99, 102, 241, 0.2)); }
    50% { filter: drop-shadow(0 20px 30px rgba(99, 102, 241, 0.4)) brightness(1.1); }
}

.logo-container {
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.logo-container:hover svg {
    animation: logoFloat 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
              logoGlow 0.7s ease-in-out forwards;
}

/* Hover animation for menu icons */
.menu-icon {
    transition: transform 0.2s ease, color 0.2s ease, filter 0.2s ease;
}

button:hover .menu-icon,
.menu-item:hover .menu-icon {
    transform: translateY(-2px) scale(1.08) rotate(-3deg);
    color: #4f46e5;
    filter: drop-shadow(0 6px 10px rgba(79, 70, 229, 0.25));
}

/* ===== MOBILE RESPONSIVE STYLES ===== */

/* Mobile bottom navigation bar */
.mobile-nav-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 76px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border-top: 1px solid #e2e8f0;
    z-index: 45;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
    padding-bottom: env(safe-area-inset-bottom);
}

.mobile-nav-bar.active {
    display: flex;
    justify-content: space-around;
    align-items: stretch;
}

.mobile-nav-button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: transparent;
    border: none;
    padding: 10px 8px;
    cursor: pointer;
    font-size: 22px;
    color: #94a3b8;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    position: relative;
}

.mobile-nav-button::before {
    content: '';
    position: absolute;
    inset: 4px;
    border-radius: 12px;
    background: transparent;
    transition: all 0.15s ease;
}

.mobile-nav-button.active {
    color: #6366f1;
}

.mobile-nav-button.active::before {
    background: linear-gradient(135deg, #eef2ff 0%, #f0f4ff 100%);
}

.mobile-nav-button span {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.mobile-nav-button:active {
    transform: scale(0.92);
}

.mobile-nav-button:active::before {
    background: #e0e7ff;
}

/* Mobile layout adjustments */
@media (max-width: 768px) {
    body {
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;
    }

    /* Adjust main to account for bottom nav */
    main {
        padding-bottom: 90px !important;
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    /* Hide desktop view toggle in mobile */
    #viewToggle {
        display: none !important;
    }

    /* Optimize header for mobile */
    header {
        height: 64px !important;
        padding: 0 16px !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
    }

    header .logo-container h1 {
        font-size: 16px !important;
    }

    header .logo-container svg {
        width: 32px !important;
        height: 32px !important;
    }

    /* Hide desktop search when mobile */
    #searchContainer {
        max-width: 100% !important;
    }

    /* Grid adjustments for mobile */
    .grid-view-container {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    /* Reduce padding on device cards */
    .device-card {
        padding: 16px !important;
        border-radius: 12px !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06) !important;
        touch-action: manipulation;
        transition: all 0.2s ease;
    }

    .device-card:active {
        transform: scale(0.98);
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1) !important;
    }

    /* Dashboard cards stack on mobile */
    .dashboard-stats-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    /* Improve stat cards on mobile */
    .stat-card {
        padding: 20px !important;
        border-radius: 16px !important;
    }

    /* Hide non-essential dashboard elements */
    .dashboard-chart-container {
        display: none !important;
    }

    /* Optimize tables for mobile */
    .device-list-table {
        font-size: 14px !important;
    }

    .device-list-table th,
    .device-list-table td {
        padding: 12px 8px !important;
    }

    /* Hide some desktop controls on mobile */
    #currentUserCard {
        display: none !important;
    }

    .hidden-on-mobile {
        display: none !important;
    }

    /* Optimize port locator for mobile */
    .port-locator-modal {
        width: 100vw !important;
        height: 100vh !important;
        max-height: none !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }

    /* Make buttons larger for touch */
    button {
        min-height: 48px !important;
        min-width: 48px !important;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(99, 102, 241, 0.1);
    }

    /* Optimize modals for mobile */
    .modal-content {
        width: 100vw !important;
        height: 100vh !important;
        max-height: none !important;
        max-width: none !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }

    /* Better input fields on mobile */
    input, select, textarea {
        font-size: 16px !important; /* Prevents zoom on iOS */
        padding: 12px !important;
        border-radius: 8px !important;
    }

    /* Better spacing for touch */
    .device-card {
        margin-bottom: 16px !important;
    }
}

@media (max-width: 480px) {
    /* Extra small screen optimizations */
    header {
        height: 56px !important;
    }

    .logo-container h1 {
        font-size: 14px !important;
    }

    .logo-container span {
        display: none !important;
    }

    /* Single column for everything */
    .grid-view-container {
        grid-template-columns: 1fr !important;
    }

    /* Hide less important info on tiny screens */
    .hidden-on-xs {
        display: none !important;
    }

    /* Reduce all padding */
    main {
        padding: 12px 8px 90px 8px !important;
    }

    /* Bigger touch targets */
    .mobile-nav-button {
        font-size: 20px;
    }

    /* Optimize cards for very small screens */
    .device-card {
        padding: 12px !important;
    }

    /* Stack info vertically on tiny screens */
    .device-card .flex {
        flex-direction: column !important;
        align-items: flex-start !important;
    }

    /* Make text more readable */
    body {
        font-size: 14px !important;
    }

    h1, h2, h3 {
        font-size: 1.25em !important;
    }
}

/* Pull-to-refresh indicator styles */
#pullRefreshIndicator {
    z-index: 100;
}

/* Improve scrolling performance on mobile */
main, .device-list, .grid-view-container {
    -webkit-overflow-scrolling: touch;
}

/* Prevent text selection on buttons for better mobile feel */
button, .mobile-nav-button, .device-card {
    -webkit-user-select: none;
    user-select: none;
}

/* Add visual feedback for loading states */
.loading-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* PWA Install Banner Animation */
@keyframes slideDown {
    from { transform: translateY(0); opacity: 1; }
    to { transform: translateY(100%); opacity: 0; }
}