/* ============================================
   DASHBOARD LAYOUT
   ============================================ */

/* Background Layer */
.background-layer {
    position: fixed;
    inset: 0;
    z-index: -1;
    background-color: var(--bg-void);
    background-size: cover;
    background-position: center;
}

.background-layer::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, var(--overlay-opacity, 0.4));
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.background-layer[style*="url"]::after {
    opacity: 1;
}

/* App Container */
#app {
    height: 100vh;
    overflow: hidden;
}

/* Main Layout - Vertical Stack */
.app-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

/* ============================================
   DASHBOARD HEADER - Premium SaaS Style
   ============================================ */

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-lg);
    background: linear-gradient(
        180deg,
        rgba(15, 15, 25, 0.85) 0%,
        rgba(10, 10, 18, 0.75) 100%
    );
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.03) inset,
        0 4px 24px -4px rgba(0, 0, 0, 0.3);
    z-index: 100;
    height: 52px;
    position: relative;
}

/* Subtle top highlight for depth */
.dashboard-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(139, 92, 246, 0.2) 20%,
        rgba(139, 92, 246, 0.3) 50%,
        rgba(139, 92, 246, 0.2) 80%,
        transparent 100%
    );
    pointer-events: none;
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-xs);
    border-radius: var(--radius-md);
    transition: all var(--transition-normal);
    text-decoration: none;
    position: relative;
}

.logo::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    background: var(--gradient-primary);
    opacity: 0;
    filter: blur(8px);
    transition: opacity var(--transition-normal);
    z-index: -1;
}

.logo:hover {
    background: rgba(139, 92, 246, 0.08);
}

.logo:hover::before {
    opacity: 0.4;
}

.logo-image {
    height: 36px;
    width: auto;
    display: block;
    transition: all var(--transition-normal);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.logo:hover .logo-image {
    transform: scale(1.05);
    filter: drop-shadow(0 4px 8px rgba(139, 92, 246, 0.4));
}

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

/* Subtle pulse animation on load */
@keyframes logoPulse {
    0%, 100% {
        filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    }
    50% {
        filter: drop-shadow(0 2px 8px rgba(139, 92, 246, 0.3));
    }
}

.logo-image {
    animation: logoPulse 3s ease-in-out infinite;
    animation-delay: 1s;
}

.logo:hover .logo-image {
    animation: none;
}

/* Profile Indicator */
.profile-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    font-size: 0.7rem;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.profile-indicator:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
    color: var(--text-secondary);
}

.profile-indicator-icon {
    font-size: 0.85rem;
}

.profile-indicator-name {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .profile-indicator-name {
        display: none;
    }
}

/* ============================================
   WORKSPACE DROPDOWN SELECTOR - Premium Style
   ============================================ */

.workspace-selector {
    position: relative;
    z-index: 200;
}

/* Trigger Button */
.workspace-selector-trigger {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-normal);
    min-width: 140px;
    max-width: 200px;
}

.workspace-selector-trigger:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
}

.workspace-selector-trigger:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

.workspace-selector.open .workspace-selector-trigger {
    background: rgba(139, 92, 246, 0.1);
    border-color: var(--accent);
}

.workspace-selector-icon {
    font-size: 1rem;
    line-height: 1;
    flex-shrink: 0;
}

.workspace-selector-label {
    flex: 1;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
}

.workspace-selector-chevron {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    transition: transform var(--transition-normal);
    flex-shrink: 0;
}

.workspace-selector-chevron svg {
    width: 12px;
    height: 12px;
}

.workspace-selector.open .workspace-selector-chevron {
    transform: rotate(180deg);
    color: var(--accent);
}

/* Dropdown Menu */
.workspace-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 220px;
    max-width: 280px;
    background: rgba(20, 20, 35, 0.98);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.3),
        0 10px 20px -5px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.96);
    transform-origin: top left;
    transition: all 0.2s var(--ease-out);
    overflow: hidden;
}

.workspace-selector.open .workspace-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Dropdown Header */
.workspace-dropdown-header {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.workspace-dropdown-title {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

/* Dropdown List */
.workspace-dropdown-list {
    padding: var(--space-xs);
    max-height: 280px;
    overflow-y: auto;
}

/* Custom scrollbar for dropdown */
.workspace-dropdown-list::-webkit-scrollbar {
    width: 4px;
}

.workspace-dropdown-list::-webkit-scrollbar-track {
    background: transparent;
}

.workspace-dropdown-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

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

/* Dropdown Item */
.workspace-dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.workspace-dropdown-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.workspace-dropdown-item.active {
    background: rgba(139, 92, 246, 0.12);
}

.workspace-dropdown-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--gradient-primary);
    border-radius: 0 2px 2px 0;
}

.workspace-dropdown-item-icon {
    font-size: 1.1rem;
    line-height: 1;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.workspace-dropdown-item:hover .workspace-dropdown-item-icon {
    background: rgba(255, 255, 255, 0.08);
}

.workspace-dropdown-item.active .workspace-dropdown-item-icon {
    background: var(--gradient-primary);
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}

.workspace-dropdown-item-label {
    flex: 1;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
    transition: color var(--transition-fast);
}

.workspace-dropdown-item:hover .workspace-dropdown-item-label {
    color: var(--text-primary);
}

.workspace-dropdown-item.active .workspace-dropdown-item-label {
    color: var(--text-primary);
    font-weight: 600;
}

/* Check mark for active item */
.workspace-dropdown-item-check {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    color: var(--accent);
    flex-shrink: 0;
    transition: opacity var(--transition-fast);
}

.workspace-dropdown-item-check svg {
    width: 14px;
    height: 14px;
}

.workspace-dropdown-item.active .workspace-dropdown-item-check {
    opacity: 1;
}

/* Edit mode indicator on items */
.workspace-dropdown-item-edit {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    opacity: 0;
    flex-shrink: 0;
    transition: opacity var(--transition-fast);
}

.workspace-dropdown-item-edit svg {
    width: 12px;
    height: 12px;
}

.workspace-dropdown-item:hover .workspace-dropdown-item-edit {
    opacity: 1;
}

/* Delete button in edit mode */
.workspace-dropdown-item-delete {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 59, 48, 0.1);
    border: none;
    border-radius: var(--radius-sm);
    color: #ff6b6b;
    cursor: pointer;
    opacity: 0;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.workspace-dropdown-item-delete svg {
    width: 12px;
    height: 12px;
}

.app-editing .workspace-dropdown-item-delete {
    opacity: 0.7;
}

.app-editing .workspace-dropdown-item:hover .workspace-dropdown-item-delete {
    opacity: 1;
}

.workspace-dropdown-item-delete:hover {
    background: rgba(255, 59, 48, 0.2);
    color: #ff4757;
}

/* Dropdown Footer - Add Workspace */
.workspace-dropdown-footer {
    padding: var(--space-xs);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.workspace-dropdown-add {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: 1px dashed rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--text-muted);
}

.workspace-dropdown-add:hover {
    background: rgba(139, 92, 246, 0.08);
    border-color: var(--accent);
    color: var(--accent);
}

.workspace-dropdown-add-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 300;
}

.workspace-dropdown-add-label {
    font-size: 0.8rem;
    font-weight: 500;
}

/* Legacy workspace-tabs-nav container (keeping for compatibility) */
.workspace-tabs-nav {
    display: flex;
    align-items: center;
}

/* Header Right */
.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.header-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all var(--transition-normal);
    position: relative;
}

.header-btn::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    background: var(--gradient-primary);
    opacity: 0;
    transition: opacity var(--transition-normal);
    z-index: -1;
}

.header-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.08);
}

.header-btn.active {
    color: white;
    background: var(--gradient-primary);
    border-color: transparent;
    box-shadow:
        0 2px 8px rgba(139, 92, 246, 0.35),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

.header-btn.active:hover {
    box-shadow:
        0 4px 12px rgba(139, 92, 246, 0.45),
        0 0 0 1px rgba(255, 255, 255, 0.15) inset;
}

/* Locked state for unregistered devices */
.header-btn:disabled,
.header-btn.locked {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: auto;
}

.header-btn.locked:hover {
    background: rgba(255, 100, 100, 0.1);
    border-color: rgba(255, 100, 100, 0.2);
    color: rgba(255, 100, 100, 0.8);
}

.header-btn.locked::after {
    content: '🔒';
    position: absolute;
    bottom: -2px;
    right: -2px;
    font-size: 0.5rem;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

/* ============================================
   DASHBOARD MAIN CONTENT
   ============================================ */

.dashboard-main {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* ============================================
   HERO SECTION - Ultra Compact
   ============================================ */

.hero-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    background: var(--gradient-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    position: relative;
    animation: fadeIn 0.5s var(--ease-out);
    gap: var(--space-lg);
}

/* Subtle glow */
.hero-glow {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse at left, rgba(139, 92, 246, 0.08) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
    border-radius: inherit;
}

.clock-container {
    position: relative;
    z-index: 1;
}

/* Search */
.search-container {
    flex: 1;
    max-width: 320px;
    position: relative;
    z-index: 1;
}

.search-form {
    width: 100%;
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.75rem;
    pointer-events: none;
    transition: color var(--transition-fast);
}

.search-input {
    width: 100%;
    padding: 8px 12px;
    padding-left: 30px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.75rem;
    transition: all var(--transition-fast);
}

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

.search-input:focus {
    border-color: var(--accent);
    outline: none;
}

.search-input:focus + .search-icon,
.search-input-wrapper:focus-within .search-icon {
    color: var(--accent);
}

/* Search Engine Toggle */
.search-toggle {
    display: flex;
    gap: 2px;
    padding: 3px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    margin-right: var(--space-xs);
}

.search-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: calc(var(--radius-md) - 2px);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    opacity: 0.5;
}

.search-toggle-btn:hover {
    opacity: 0.8;
    background: rgba(255, 255, 255, 0.08);
}

.search-toggle-btn.active {
    opacity: 1;
    background: var(--accent);
    box-shadow: 0 2px 8px var(--accent-glow);
}

/* Adjust search icon when toggle is present */
.search-toggle + .search-icon {
    position: relative;
    left: 0;
    transform: none;
    margin-right: var(--space-xs);
    flex-shrink: 0;
}

.search-toggle ~ .search-input {
    padding-left: 8px;
}

/* ============================================
   DASHBOARD GRID
   ============================================ */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-sm);
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
    animation: fadeIn 0.5s var(--ease-out) 0.1s backwards;
}

/* Empty state */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: var(--space-2xl);
    color: var(--text-tertiary);
}

/* ============================================
   ANIMATIONS
   ============================================ */

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

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .dashboard-header {
        padding: var(--space-sm) var(--space-md);
        height: auto;
        min-height: 52px;
        flex-wrap: nowrap;
        gap: var(--space-sm);
    }

    .dashboard-header::before {
        display: none;
    }

    .logo {
        padding: var(--space-xs);
    }

    .logo-image {
        height: 32px;
    }

    /* Workspace Dropdown Mobile */
    .workspace-selector-trigger {
        min-width: auto;
        max-width: 160px;
        padding: 6px 10px;
    }

    .workspace-selector-label {
        font-size: 0.75rem;
        max-width: 80px;
    }

    .workspace-dropdown {
        min-width: 200px;
        max-width: calc(100vw - 32px);
    }

    .header-btn {
        width: 36px;
        height: 36px;
    }

    .dashboard-main {
        padding: var(--space-md);
    }

    .hero-section {
        padding: var(--space-lg) 0;
    }

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

/* Extra small screens */
@media (max-width: 480px) {
    .workspace-selector-label {
        display: none;
    }

    .workspace-selector-trigger {
        min-width: auto;
        padding: 6px 8px;
    }

    .workspace-dropdown {
        left: -40px;
    }
}

/* ============================================
   LEGACY SUPPORT (for old sidebar references)
   ============================================ */

.sidebar { display: none; }
.main-canvas { display: none; }
.workspace-content { display: contents; }
