/**
 * Contacts Manager - Main Styles
 * Modern, SaaS-style interface with light/dark theme support
 * Version 4.0.0
 */

/* ========================================
   CSS Custom Properties (Theme Variables)
   ======================================== */
:root {
    /* Primary Colors - Indigo/Purple */
    --color-primary: #6366f1;
    --color-primary-hover: #4f46e5;
    --color-primary-light: #eef2ff;
    --color-primary-dark: #4338ca;
    --color-primary-50: #eef2ff;
    --color-primary-100: #e0e7ff;
    --color-primary-500: #6366f1;
    --color-primary-600: #4f46e5;
    --color-primary-700: #4338ca;

    /* Secondary Colors */
    --color-secondary: #8b5cf6;
    --color-secondary-light: #ede9fe;

    /* Semantic Colors */
    --color-success: #10b981;
    --color-success-light: #d1fae5;
    --color-warning: #f59e0b;
    --color-warning-light: #fef3c7;
    --color-danger: #ef4444;
    --color-danger-light: #fee2e2;
    --color-info: #3b82f6;
    --color-info-light: #dbeafe;

    /* Accent Colors */
    --color-purple: #8b5cf6;
    --color-purple-light: #ede9fe;
    --color-orange: #f97316;
    --color-orange-light: #ffedd5;
    --color-cyan: #06b6d4;
    --color-cyan-light: #cffafe;
    --color-pink: #ec4899;
    --color-pink-light: #fce7f3;
    --color-yellow: #eab308;
    --color-yellow-light: #fef9c3;

    /* Background Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-elevated: #ffffff;
    --bg-hover: rgba(99, 102, 241, 0.04);
    --bg-active: rgba(99, 102, 241, 0.08);
    --bg-selected: rgba(99, 102, 241, 0.12);

    /* Text Colors */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #64748b;
    --text-muted: #94a3b8;
    --text-inverted: #ffffff;
    --text-link: var(--color-primary);

    /* Border Colors */
    --border-primary: #e2e8f0;
    --border-secondary: #cbd5e1;
    --border-hover: #94a3b8;
    --border-focus: var(--color-primary);

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 10px 10px -5px rgba(0, 0, 0, 0.03);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    --shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.04);
    --shadow-focus: 0 0 0 3px rgba(99, 102, 241, 0.15);
    --shadow-primary: 0 4px 14px rgba(99, 102, 241, 0.25);

    /* Transitions */
    --transition-fast: 100ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Border Radius */
    --radius-xs: 0.25rem;
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    --radius-full: 9999px;

    /* Layout */
    --header-height: 4rem;
    --sidebar-width: 17rem;
    --panel-width: 26rem;

    /* Z-index */
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-modal-backdrop: 900;
    --z-modal: 1000;
    --z-toast: 1100;
}

/* Dark Theme */
[data-theme="dark"] {
    --color-primary: #818cf8;
    --color-primary-hover: #a5b4fc;
    --color-primary-light: rgba(129, 140, 248, 0.15);
    --color-primary-dark: #6366f1;
    --color-primary-50: rgba(129, 140, 248, 0.1);
    --color-primary-100: rgba(129, 140, 248, 0.2);

    --color-success-light: rgba(16, 185, 129, 0.15);
    --color-warning-light: rgba(245, 158, 11, 0.15);
    --color-danger-light: rgba(239, 68, 68, 0.15);
    --color-info-light: rgba(59, 130, 246, 0.15);
    --color-purple-light: rgba(139, 92, 246, 0.15);
    --color-orange-light: rgba(249, 115, 22, 0.15);
    --color-cyan-light: rgba(6, 182, 212, 0.15);
    --color-pink-light: rgba(236, 72, 153, 0.15);
    --color-yellow-light: rgba(234, 179, 8, 0.15);

    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-elevated: #1e293b;
    --bg-hover: rgba(129, 140, 248, 0.06);
    --bg-active: rgba(129, 140, 248, 0.12);
    --bg-selected: rgba(129, 140, 248, 0.18);

    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --text-muted: #64748b;

    --border-primary: #334155;
    --border-secondary: #475569;
    --border-hover: #64748b;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.35);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.4);
    --shadow-focus: 0 0 0 3px rgba(129, 140, 248, 0.25);
    --shadow-primary: 0 4px 14px rgba(129, 140, 248, 0.3);
}

/* ========================================
   Reset & Base Styles
   ======================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    min-height: 100vh;
    overflow: hidden;
}

a {
    color: var(--text-link);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-primary-hover);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ========================================
   Layout Structure
   ======================================== */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-layout {
    display: flex;
    flex: 1;
    margin-top: var(--header-height);
    height: calc(100vh - var(--header-height));
    overflow: hidden;
}

/* ========================================
   Header Styles
   ======================================== */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    z-index: var(--z-sticky);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-primary);
    backdrop-filter: blur(12px);
    background-color: rgba(255, 255, 255, 0.9);
}

[data-theme="dark"] .app-header {
    background-color: rgba(15, 23, 42, 0.95);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 1.5rem;
    gap: 1.5rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

/* Sidebar Toggle Button in Header */
.sidebar-toggle-btn {
    width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.sidebar-toggle-btn:hover {
    background-color: var(--bg-hover);
    color: var(--color-primary);
}

.sidebar-toggle-btn i {
    font-size: 1.125rem;
}

.logo {
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    border-radius: var(--radius-lg);
    color: white;
    font-size: 1.25rem;
    box-shadow: var(--shadow-primary);
}

.app-title {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.header-center {
    flex: 1;
    max-width: 36rem;
    margin: 0 auto;
}

.search-box {
    position: relative;
    width: 100%;
}

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

.search-box .search-input {
    width: 100%;
    height: 2.75rem;
    padding: 0 3.5rem 0 2.75rem;
    font-size: 0.9375rem;
    font-family: inherit;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-xl);
    outline: none;
    transition: all var(--transition-normal);
}

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

.search-box .search-input:hover {
    border-color: var(--border-hover);
    background-color: var(--bg-primary);
}

.search-box .search-input:focus {
    border-color: var(--color-primary);
    background-color: var(--bg-primary);
    box-shadow: var(--shadow-focus);
}

.search-box .search-input:focus + .search-icon {
    color: var(--color-primary);
}

.search-shortcut {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    padding: 0.25rem 0.5rem;
    font-size: 0.6875rem;
    font-family: inherit;
    font-weight: 500;
    color: var(--text-muted);
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    pointer-events: none;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

/* User Avatar */
.user-avatar {
    width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-purple) 100%);
    border-radius: var(--radius-full);
    color: white;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.user-avatar:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

/* ========================================
   Sidebar Styles
   ======================================== */
.sidebar {
    width: var(--sidebar-width);
    height: 100%;
    background-color: var(--bg-primary);
    border-right: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
    transition: width var(--transition-slow);
}

/* Collapsed Sidebar State */
.sidebar.collapsed {
    width: 0;
    min-width: 0;
    padding: 0;
    overflow: hidden;
}

.sidebar.collapsed .sidebar-content {
    display: none;
}

.sidebar-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Tree Navigation */
.tree-nav {
    flex: 1;
    padding: 0.5rem;
    overflow-y: auto;
}

.tree-section {
    margin-bottom: 0.25rem;
}

.tree-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--text-secondary);
}

.tree-item:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.tree-item.active {
    background-color: var(--bg-selected);
    color: var(--color-primary);
    font-weight: 500;
}

.tree-item.active .tree-icon {
    color: var(--color-primary);
}

.tree-icon {
    font-size: 1rem;
    width: 1.25rem;
    text-align: center;
    color: var(--text-tertiary);
    transition: color var(--transition-fast);
}

.tree-label {
    flex: 1;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-count {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-full);
    color: var(--text-tertiary);
    min-width: 1.5rem;
    text-align: center;
}

.tree-item.active .tree-count {
    background-color: var(--color-primary-light);
    color: var(--color-primary);
}

/* Tree Header */
.tree-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.875rem;
    cursor: pointer;
    user-select: none;
    transition: background-color var(--transition-fast);
    border-radius: var(--radius-md);
}

.tree-header:hover {
    background-color: var(--bg-hover);
}

.tree-header .toggle-icon {
    font-size: 0.625rem;
    color: var(--text-muted);
    transition: transform var(--transition-fast);
}

.tree-header.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.tree-header-label {
    flex: 1;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.tree-action-btn {
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0;
    transition: all var(--transition-fast);
}

.tree-header:hover .tree-action-btn {
    opacity: 1;
}

.tree-action-btn:hover {
    background-color: var(--bg-active);
    color: var(--color-primary);
}

.tree-children {
    padding-left: 1rem;
    overflow: hidden;
    transition: max-height var(--transition-slow);
}

.tree-header.collapsed + .tree-children {
    max-height: 0 !important;
}

.tree-loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.tree-loading i {
    color: var(--color-primary);
}

/* Group Item in Tree */
.group-tree-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.group-tree-item:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.group-tree-item.active {
    background-color: var(--bg-selected);
    color: var(--color-primary);
}

.group-tree-item .group-icon {
    font-size: 0.875rem;
    width: 1.125rem;
    text-align: center;
}

.group-tree-item.private .group-icon {
    color: var(--color-purple);
}

.group-tree-item.shared .group-icon {
    color: var(--color-orange);
}

/* ========================================
   Main Content Area
   ======================================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-secondary);
    overflow: hidden;
    min-width: 0;
}

/* Content Toolbar */
.content-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-primary);
    flex-shrink: 0;
}

.toolbar-left {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
}

.content-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.content-count {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* View Toggle */
.view-toggle {
    display: flex;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 0.25rem;
}

.view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.view-btn:hover {
    color: var(--text-primary);
}

.view-btn.active {
    background-color: var(--bg-primary);
    color: var(--color-primary);
    box-shadow: var(--shadow-sm);
}

/* Sort Dropdown */
.sort-dropdown {
    position: relative;
}

.sort-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.sort-btn:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.sort-btn i:last-child {
    font-size: 0.625rem;
    margin-left: 0.25rem;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 12rem;
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-dropdown);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-0.5rem);
    transition: all var(--transition-fast);
}

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

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    width: 100%;
    padding: 0.625rem 1rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: left;
}

.dropdown-item:first-child {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.dropdown-item:last-child {
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.dropdown-item:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.dropdown-item.active {
    background-color: var(--bg-selected);
    color: var(--color-primary);
}

.dropdown-item i {
    width: 1rem;
    text-align: center;
}

/* ========================================
   Contacts Container
   ======================================== */
.contacts-container {
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* Loading State */
.loading-state {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-secondary);
    z-index: 10;
}

.loading-state.hidden {
    display: none;
}

.loading-spinner {
    font-size: 2.5rem;
    color: var(--color-primary);
    margin-bottom: 1rem;
}

.loading-state p {
    color: var(--text-muted);
    font-size: 0.9375rem;
}

/* Empty State */
.empty-state {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
}

.empty-state.hidden {
    display: none;
}

.empty-icon {
    width: 5rem;
    height: 5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--color-primary-50) 0%, var(--color-primary-100) 100%);
    border-radius: var(--radius-2xl);
    margin-bottom: 1.5rem;
}

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

.empty-state h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    max-width: 20rem;
}

/* ========================================
   Profile Panel
   ======================================== */
.profile-panel {
    width: var(--panel-width);
    height: 100%;
    background-color: var(--bg-primary);
    border-left: 1px solid var(--border-primary);
    flex-shrink: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-slow), opacity var(--transition-slow);
}

.profile-panel.hidden {
    display: none;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.panel-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 1rem;
}

.panel-close {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.panel-close:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

/* Profile Avatar */
.profile-avatar {
    width: 6rem;
    height: 6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-purple) 100%);
    border-radius: var(--radius-2xl);
    margin: 0 auto 1.25rem;
    box-shadow: var(--shadow-primary);
}

.avatar-initials {
    font-size: 2rem;
    font-weight: 600;
    color: white;
    text-transform: uppercase;
}

.profile-name {
    font-size: 1.375rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 0.25rem;
}

.profile-title {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 1.5rem;
}

/* Profile Actions */
.profile-actions {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.375rem;
    padding: 0.75rem;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-width: 4rem;
}

.action-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.action-btn i {
    font-size: 1.125rem;
}

.action-btn span {
    font-size: 0.6875rem;
    font-weight: 500;
}

/* Favorite Toggle */
.favorite-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: 1.5rem;
}

.favorite-toggle:hover {
    border-color: var(--color-warning);
    color: var(--color-warning);
    background-color: var(--color-warning-light);
}

.favorite-toggle.active {
    border-color: var(--color-warning);
    color: var(--color-warning);
    background-color: var(--color-warning-light);
}

.favorite-toggle.active i {
    font-weight: 900;
}

/* Profile Details */
.profile-details {
    border-top: 1px solid var(--border-primary);
    padding-top: 1.25rem;
    flex: 1;
    overflow-y: auto;
}

.detail-section {
    margin-bottom: 1.25rem;
}

.detail-section:last-child {
    margin-bottom: 0;
}

.detail-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.625rem;
}

.detail-title i {
    width: 1rem;
    text-align: center;
}

.detail-title .add-to-group-btn {
    margin-left: auto;
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.detail-title .add-to-group-btn:hover {
    background-color: var(--bg-hover);
    color: var(--color-primary);
}

.detail-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.detail-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 0.75rem;
    background-color: var(--bg-secondary);
    border-radius: var(--radius-md);
    transition: background-color var(--transition-fast);
}

.detail-item:hover {
    background-color: var(--bg-tertiary);
}

.detail-value {
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.detail-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.detail-copy-btn {
    width: 1.75rem;
    height: 1.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0;
    transition: all var(--transition-fast);
}

.detail-item:hover .detail-copy-btn {
    opacity: 1;
}

.detail-copy-btn:hover {
    background-color: var(--bg-hover);
    color: var(--color-primary);
}

.detail-content {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.notes-content {
    padding: 0.75rem;
    background-color: var(--bg-secondary);
    border-radius: var(--radius-md);
    white-space: pre-wrap;
}

/* Groups Tags */
.groups-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.group-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background-color: var(--color-primary-light);
    color: var(--color-primary);
    border-radius: var(--radius-full);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.group-tag:hover {
    background-color: var(--color-primary);
    color: white;
}

.group-tag .remove-tag {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    margin-left: 0.25rem;
    border-radius: var(--radius-full);
    opacity: 0.7;
    transition: opacity var(--transition-fast);
}

.group-tag:hover .remove-tag {
    opacity: 1;
}

/* Panel Footer */
.panel-footer {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-primary);
}

.panel-footer .btn {
    flex: 1;
}

/* Group Profile */
.group-profile {
    text-align: center;
}

.group-profile.hidden {
    display: none;
}

.group-avatar {
    width: 5rem;
    height: 5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--color-purple) 0%, var(--color-pink) 100%);
    border-radius: var(--radius-2xl);
    margin: 0 auto 1.25rem;
    box-shadow: 0 4px 14px rgba(139, 92, 246, 0.3);
}

.group-avatar i {
    font-size: 2rem;
    color: white;
}

.group-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.member-count {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.group-type-badge {
    padding: 0.25rem 0.625rem;
    background-color: var(--color-purple-light);
    color: var(--color-purple);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

/* Group Members */
.group-members {
    text-align: left;
    margin-top: 1.5rem;
}

.members-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.members-header h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.members-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 20rem;
    overflow-y: auto;
}

.member-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem;
    background-color: var(--bg-secondary);
    border-radius: var(--radius-md);
    transition: background-color var(--transition-fast);
}

.member-item:hover {
    background-color: var(--bg-tertiary);
}

.member-avatar {
    width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-purple) 100%);
    border-radius: var(--radius-full);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

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

.member-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.member-email {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.member-remove {
    width: 1.75rem;
    height: 1.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0;
    transition: all var(--transition-fast);
}

.member-item:hover .member-remove {
    opacity: 1;
}

.member-remove:hover {
    background-color: var(--color-danger-light);
    color: var(--color-danger);
}

/* ========================================
   Utility Classes
   ======================================== */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Icon Colors */
.icon-yellow { color: var(--color-warning); }
.icon-purple { color: var(--color-purple); }
.icon-green { color: var(--color-success); }
.icon-orange { color: var(--color-orange); }
.icon-blue { color: var(--color-primary); }
.icon-red { color: var(--color-danger); }

/* ========================================
   Custom Scrollbar
   ======================================== */
::-webkit-scrollbar {
    width: 0.5rem;
    height: 0.5rem;
}

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

::-webkit-scrollbar-thumb {
    background-color: var(--border-secondary);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-muted);
}

/* ========================================
   Responsive Styles
   ======================================== */
@media (max-width: 80rem) {
    :root {
        --sidebar-width: 15rem;
        --panel-width: 24rem;
    }
}

@media (max-width: 64rem) {
    :root {
        --sidebar-width: 14rem;
        --panel-width: 22rem;
    }

    .header-center {
        max-width: 24rem;
    }

    .search-shortcut {
        display: none;
    }
}

@media (max-width: 48rem) {
    :root {
        --header-height: 3.5rem;
        --sidebar-width: 100%;
        --panel-width: 100%;
    }

    .app-layout {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        left: -100%;
        top: var(--header-height);
        width: 80%;
        max-width: 20rem;
        height: calc(100vh - var(--header-height));
        z-index: var(--z-modal);
        transition: left var(--transition-slow);
    }

    .sidebar.open {
        left: 0;
    }

    .main-content {
        width: 100%;
    }

    .profile-panel {
        position: fixed;
        right: -100%;
        top: var(--header-height);
        width: 100%;
        height: calc(100vh - var(--header-height));
        z-index: var(--z-modal);
        transition: right var(--transition-slow);
    }

    .profile-panel.open {
        right: 0;
    }

    .header-center {
        display: none;
    }

    .header-right .btn span {
        display: none;
    }
}

/* ========================================
   Print Styles
   ======================================== */
@media print {
    .app-header,
    .sidebar,
    .profile-panel,
    .toast-container,
    .modal {
        display: none !important;
    }

    .app-layout {
        margin-top: 0;
    }

    .main-content {
        width: 100%;
    }
}

/* ========================================
   Focus Styles
   ======================================== */
*:focus:not(:focus-visible) {
    outline: none;
}

*:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* ========================================
   Animations
   ======================================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(1rem);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-1rem);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
