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

:root {
    /* Enhanced Color Palette */
    --primary-color: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --secondary-color: #8b5cf6;
    --accent-color: #ec4899;
    --success-color: #10b981;
    --danger-color: #f43f5e;
    --warning-color: #f59e0b;
    --info-color: #06b6d4;

    /* Gradient Designs */
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-accent: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-success: linear-gradient(135deg, #4ade80 0%, #06b6d4 100%);
    --gradient-cosmic: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);

    /* Background System */
    --bg-color: #0a0e1a;
    --bg-secondary: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.6);
    --card-bg-solid: #1e293b;
    --card-bg-hover: rgba(30, 41, 59, 0.85);
    --border-color: rgba(148, 163, 184, 0.15);
    --input-bg: rgba(30, 41, 59, 0.5);

    /* Glass Morphism */
    --glass-bg: rgba(30, 41, 59, 0.75);
    --glass-border: rgba(148, 163, 184, 0.15);
    --glass-highlight: rgba(255, 255, 255, 0.1);

    /* Text Colors */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Enhanced Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 30px 60px rgba(0, 0, 0, 0.6);

    /* Glow Effects */
    --glow-primary: 0 0 20px rgba(99, 102, 241, 0.4);
    --glow-secondary: 0 0 20px rgba(139, 92, 246, 0.4);
    --glow-success: 0 0 20px rgba(16, 185, 129, 0.4);
    --glow-warning: 0 0 20px rgba(245, 158, 11, 0.4);
    --glow-accent: 0 0 20px rgba(236, 72, 153, 0.4);
}

/* Light Mode Theme */
[data-theme="light"] {
    /* Background System */
    --bg-color: #f8fafc;
    --bg-secondary: #f1f5f9;
    --card-bg: rgba(255, 255, 255, 0.9);
    --card-bg-solid: #ffffff;
    --card-bg-hover: rgba(255, 255, 255, 1);
    --border-color: rgba(148, 163, 184, 0.3);
    --input-bg: rgba(255, 255, 255, 0.8);

    /* Glass Morphism */
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(148, 163, 184, 0.25);
    --glass-highlight: rgba(255, 255, 255, 0.9);

    /* Text Colors */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    /* Enhanced Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.15);
    --shadow-xl: 0 30px 60px rgba(0, 0, 0, 0.2);

    /* Glow Effects - more subtle for light mode */
    --glow-primary: 0 0 15px rgba(99, 102, 241, 0.2);
    --glow-secondary: 0 0 15px rgba(139, 92, 246, 0.2);
    --glow-success: 0 0 15px rgba(16, 185, 129, 0.2);
    --glow-warning: 0 0 15px rgba(245, 158, 11, 0.2);
    --glow-accent: 0 0 15px rgba(236, 72, 153, 0.2);
}

[data-theme="light"] body {
    background-image:
        radial-gradient(ellipse at 10% 10%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 90% 10%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 100%, rgba(236, 72, 153, 0.06) 0%, transparent 50%);
}

[data-theme="light"] body::before {
    background: radial-gradient(circle at 50% 50%, rgba(99, 102, 241, 0.03), transparent 70%);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-color);
    background-image:
        radial-gradient(ellipse at 10% 10%, rgba(99, 102, 241, 0.2) 0%, transparent 50%),
        radial-gradient(ellipse at 90% 10%, rgba(139, 92, 246, 0.2) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 100%, rgba(236, 72, 153, 0.15) 0%, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        linear-gradient(45deg, transparent 48%, rgba(99, 102, 241, 0.03) 50%, transparent 52%),
        linear-gradient(-45deg, transparent 48%, rgba(139, 92, 246, 0.03) 50%, transparent 52%);
    background-size: 60px 60px;
    pointer-events: none;
    z-index: -1;
    opacity: 0.5;
}

/* Screen Management */
.screen {
    display: none;
    animation: fadeIn 0.5s ease;
}

.screen.active {
    display: block;
}

/* Login Screen */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    position: relative;
}

.login-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.1) 0%, transparent 70%);
    animation: rotate 20s linear infinite;
}

@keyframes rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.login-box {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    padding: 50px;
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 440px;
    position: relative;
    z-index: 1;
}

.login-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 24px 24px 0 0;
}

.login-box h1 {
    text-align: center;
    margin-bottom: 10px;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 2rem;
    font-weight: 800;
}

.subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 40px;
    font-size: 0.95rem;
}

/* Navigation Bar */
.navbar {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    padding: 18px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand h2 {
    background: linear-gradient(135deg, var(--primary-light), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 1.5rem;
    font-weight: 700;
}

.navbar-menu {
    display: flex;
    gap: 15px;
    align-items: center;
}

.user-info {
    color: var(--text-secondary);
    font-weight: 500;
    padding: 8px 16px;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

/* Main Container */
.main-container {
    display: flex;
    height: calc(100vh - 70px);
}

/* Sidebar */
.sidebar {
    width: 300px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.sidebar-header > div {
    display: flex;
    gap: 5px;
}

.sidebar-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    width: 100%;
}

.sidebar-filters {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.search-input, .filter-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--input-bg);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all 0.3s;
}

.search-input::placeholder {
    color: var(--text-secondary);
    opacity: 1;
}

.search-input:focus, .filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: var(--card-bg-solid);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.pages-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.pages-list::-webkit-scrollbar {
    width: 6px;
}

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

.pages-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.pages-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.page-item {
    padding: 14px 18px;
    margin-bottom: 8px;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

.page-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, var(--primary-color), var(--secondary-color));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.page-item:hover {
    background: var(--card-bg-hover);
    border-color: var(--glass-border);
    transform: translateX(6px);
}

.page-item:hover::before {
    opacity: 0.5;
}

.page-item.active {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    box-shadow: var(--glow-primary), var(--shadow);
    transform: translateX(6px);
    border-color: rgba(99, 102, 241, 0.3);
}

.page-item.active::before {
    opacity: 1;
    width: 5px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.3));
}

.page-item.archived {
    opacity: 0.6;
}

.page-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-item-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.page-item-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.page-item-name {
    flex: 1;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.page-item-badge {
    background: rgba(255, 255, 255, 0.15);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.page-item.active .page-item-badge {
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.page-item-meta {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.page-category-badge {
    background: rgba(139, 92, 246, 0.2);
    color: var(--secondary-color);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.page-item.active .page-category-badge {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-color: rgba(255, 255, 255, 0.3);
}

.page-item-description {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
    opacity: 0.8;
}

.page-item.active .page-item-description {
    color: rgba(255, 255, 255, 0.8);
}

/* Content Area */
.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.content-header {
    padding: 24px 30px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.content-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.content-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Mobile-First: Base styles for mobile devices - Multi-column rectangular buttons */
.button-grid {
    flex: 1;
    padding: clamp(0.75rem, 3vw, 1rem);
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: clamp(0.75rem, 3vw, 1rem);
    align-content: start;
    perspective: 1000px;
    position: relative;
}

/* Single-column mobile stack layout - detected by having 1 column */
.button-grid:has(.button-card:first-child:last-child),
.button-grid[style*="repeat(1, 1fr)"] {
    grid-template-columns: 1fr !important;
    padding: 16px 20px;
    gap: 16px !important;
}

.button-grid[style*="repeat(1, 1fr)"] .button-card {
    width: 100%;
    min-height: 110px !important;
    padding: 24px !important;
}

.button-grid[style*="repeat(1, 1fr)"] .button-label {
    font-size: clamp(1.4rem, 4.5vw, 2rem) !important;
    font-weight: 700;
    line-height: 1.3;
}

/* Additional mobile-specific single column styling */
@media (max-width: 768px) {
    .button-grid[style*="repeat(1, 1fr)"] {
        padding: 14px 18px;
        gap: 14px !important;
    }

    .button-grid[style*="repeat(1, 1fr)"] .button-card {
        min-height: 120px !important;
        padding: 26px 20px !important;
    }

    .button-grid[style*="repeat(1, 1fr)"] .button-label {
        font-size: clamp(1.6rem, 6vw, 2.2rem) !important;
    }
}

/* Add subtle gradient overlay to grid background for depth */
.button-grid::before {
    content: '';
    position: fixed;
    top: 70px;
    left: 300px;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse at 20% 30%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
        radial-gradient(ellipse at 80% 70%, rgba(139, 92, 246, 0.06) 0%, transparent 40%);
    pointer-events: none;
    z-index: 0;
    opacity: 0.6;
}

.button-grid > * {
    position: relative;
    z-index: 1;
}

.button-grid::-webkit-scrollbar {
    width: 8px;
}

.button-grid::-webkit-scrollbar-track {
    background: transparent;
}

.button-grid::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.button-grid::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-secondary);
    padding: 80px 20px;
    font-size: 1.1rem;
}

/* Button Card - Mobile-First: Rectangular buttons for better readability */
.button-card {
    background: var(--glass-bg);
    backdrop-filter: blur(30px);
    border: 2px solid transparent;
    border-radius: 1rem;
    box-shadow: var(--shadow-lg),
                inset 0 1px 0 rgba(255, 255, 255, 0.15),
                inset 0 -1px 0 rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.15s ease-out;
    padding: clamp(1rem, 4vw, 1.25rem);
    text-align: center;
    position: relative;
    overflow: hidden;
    background-clip: padding-box;
    width: 100%;
    /* Rectangular design for mobile - better text readability */
    min-height: clamp(3.5rem, 15vw, 4.5rem);
    height: auto;
}

/* Animated gradient border */
.button-card::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(
        135deg,
        rgba(99, 102, 241, 0.6),
        rgba(139, 92, 246, 0.6),
        rgba(236, 72, 153, 0.6),
        rgba(99, 102, 241, 0.6)
    );
    background-size: 200% 200%;
    border-radius: 28px;
    opacity: 0;
    z-index: -1;
    transition: opacity 0.5s ease;
    animation: borderGlow 3s ease infinite;
}

@keyframes borderGlow {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

/* Shimmer effect - removed for cleaner button feel */
.button-card::after {
    content: none;
}

.button-card:hover::before {
    opacity: 0.3;
}

/* Subtle hover lift */
.button-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4),
                0 4px 12px rgba(99, 102, 241, 0.3),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Realistic button press - pushes down */
.button-card:active {
    transform: translateY(1px) scale(0.98);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3),
                inset 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.05s ease-out;
}

/* Drag and drop cursor */
.button-card {
    cursor: grab;
}

.button-card:active {
    cursor: grabbing;
}

/* Dragging state */
.button-card[draggable="true"]:hover {
    cursor: grab;
}

/* Active state - when button is pressed locally */
.button-card.active {
    transform: translateY(1px) scale(0.98);
    box-shadow: 0 0 0 2px var(--success-color),
                0 2px 8px rgba(16, 185, 129, 0.4),
                inset 0 2px 4px rgba(0, 0, 0, 0.2);
    border-color: var(--success-color);
}

/* Feedback state - when button is pressed in Companion */
.button-card.feedback-active {
    transform: translateY(1px) scale(0.98);
    box-shadow: 0 0 0 2px var(--warning-color),
                0 2px 8px rgba(245, 158, 11, 0.4),
                inset 0 2px 4px rgba(0, 0, 0, 0.2);
    border-color: var(--warning-color);
}

.button-label {
    font-weight: 700;
    white-space: normal;
    word-break: keep-all;
    overflow-wrap: normal;
    width: 100%;
    position: relative;
    z-index: 2;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6),
                 0 4px 16px rgba(0, 0, 0, 0.4);
    letter-spacing: 0.01em;
    font-size: clamp(0.65rem, 2vw, 1rem);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.25;
    filter: drop-shadow(0 1px 2px rgba(255, 255, 255, 0.1));
    flex: 1;
    text-align: center;
    padding: 4px 10px;
    max-width: 100%;
}

.button-instance-name {
    font-size: 0.65rem;
    margin-top: 4px;
    opacity: 0.6;
    position: absolute;
    bottom: 8px;
    z-index: 2;
    font-weight: 400;
    letter-spacing: 0.01em;
}

/* Inner gradient overlay for depth */
.button-card > *:not(.button-actions) {
    position: relative;
    z-index: 2;
}

.button-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: none;
    gap: 6px;
    z-index: 2;
}

.button-card:hover .button-actions {
    display: flex;
    animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(15px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.button-action-btn {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(15px);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.15);
    width: 30px;
    height: 30px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.button-action-btn:hover {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    transform: scale(1.15) rotate(5deg);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    border-color: rgba(99, 102, 241, 0.5);
}

.button-action-btn:active {
    transform: scale(1.05) rotate(0deg);
}

/* Form Styles */
.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
    color: var(--text-primary);
    transition: all 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    background: var(--card-bg-solid);
}

.form-group input[type="color"] {
    height: 50px;
    cursor: pointer;
}

.form-group small {
    display: block;
    margin-top: 6px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 10px;
    border-radius: 8px;
    transition: background 0.2s;
}

.checkbox-label:hover {
    background: var(--card-bg);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Buttons - Enhanced Design */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
    letter-spacing: 0.02em;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.btn:hover:not(:disabled)::before {
    width: 350px;
    height: 350px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.5),
                inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 2px solid var(--glass-border);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--card-bg-hover);
    border-color: rgba(148, 163, 184, 0.3);
    transform: translateY(-2px);
    box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger-color), #dc2626);
    color: white;
    box-shadow: 0 4px 12px rgba(244, 63, 94, 0.4),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(244, 63, 94, 0.3);
}

.btn-danger:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(244, 63, 94, 0.5),
                inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color), #059669);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.btn-success:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.5),
                inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

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

/* Modal - Enhanced Design */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--glass-bg);
    backdrop-filter: blur(30px);
    border: 2px solid var(--glass-border);
    border-radius: 24px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl),
                0 0 60px rgba(99, 102, 241, 0.15),
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
    animation: modalSlideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

.modal-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color), var(--accent-color));
    border-radius: 24px 24px 0 0;
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(60px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-content::-webkit-scrollbar {
    width: 8px;
}

.modal-content::-webkit-scrollbar-track {
    background: transparent;
}

.modal-content::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.3);
}

.modal-sm {
    max-width: 440px;
}

.modal-lg {
    max-width: 900px;
}

.modal-header {
    padding: 28px 28px 24px 28px;
    border-bottom: 2px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.4rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal-close {
    background: var(--card-bg);
    border: 2px solid var(--glass-border);
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
}

.modal-close:hover {
    background: var(--card-bg-hover);
    color: var(--danger-color);
    border-color: rgba(244, 63, 94, 0.3);
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 0 20px rgba(244, 63, 94, 0.3);
}

.modal-body {
    padding: 28px;
    padding-bottom: 40px; /* Extra padding at bottom for footer visibility */
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 28px;
    padding-bottom: 8px; /* Extra padding to prevent cutoff */
    width: 100%;
    flex-wrap: wrap;
}

.modal-footer .btn {
    flex-shrink: 0;
    min-width: 100px;
}

/* Tabs - Enhanced Design */
.tabs {
    display: flex;
    gap: 6px;
    background: var(--card-bg);
    backdrop-filter: blur(15px);
    padding: 6px;
    border-radius: 14px;
    margin-bottom: 28px;
    border: 2px solid var(--glass-border);
    box-shadow: var(--shadow-sm);
}

.tab-btn {
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-secondary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    letter-spacing: 0.02em;
    position: relative;
}

.tab-btn::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    transform: translateX(-50%);
    transition: width 0.3s ease;
}

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

.tab-btn:hover::before {
    width: 60%;
}

.tab-btn.active {
    color: white;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.tab-btn.active::before {
    width: 0;
}

.tab-content {
    display: none;
    animation: fadeIn 0.4s ease;
}

.tab-content.active {
    display: block;
}

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

/* Lists - Enhanced Design */
.instances-list,
.users-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.list-item {
    padding: 24px;
    background: var(--card-bg);
    backdrop-filter: blur(15px);
    border: 2px solid var(--glass-border);
    border-radius: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.list-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, var(--primary-color), var(--secondary-color));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.list-item:hover {
    background: var(--card-bg-hover);
    border-color: rgba(148, 163, 184, 0.25);
    transform: translateX(6px);
    box-shadow: var(--shadow-md), 0 0 30px rgba(99, 102, 241, 0.1);
}

.list-item:hover::before {
    opacity: 1;
}

.list-item-info h4 {
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 1.1rem;
    letter-spacing: 0.01em;
}

.list-item-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.list-item-actions {
    display: flex;
    gap: 10px;
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    border-radius: 24px;
    font-size: 0.8rem;
    font-weight: 700;
    margin-top: 10px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    backdrop-filter: blur(10px);
}

.status-indicator.connected {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(5, 150, 105, 0.25));
    color: #6ee7b7;
    border: 2px solid rgba(16, 185, 129, 0.4);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.2);
}

.status-indicator.disconnected {
    background: linear-gradient(135deg, rgba(244, 63, 94, 0.2), rgba(220, 38, 38, 0.25));
    color: #fca5a5;
    border: 2px solid rgba(244, 63, 94, 0.4);
    box-shadow: 0 0 20px rgba(244, 63, 94, 0.2);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(0.9);
    }
}

.status-dot.connected {
    background: #6ee7b7;
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.6),
                inset 0 0 5px rgba(255, 255, 255, 0.3);
}

.status-dot.disconnected {
    background: #fca5a5;
    box-shadow: 0 0 15px rgba(244, 63, 94, 0.6),
                inset 0 0 5px rgba(255, 255, 255, 0.3);
}

/* Messages */
.error-message {
    color: #fecdd3;
    background: rgba(244, 63, 94, 0.2);
    border: 1px solid rgba(244, 63, 94, 0.3);
    padding: 14px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: none;
    font-size: 0.9rem;
}

.error-message.show {
    display: block;
    animation: slideIn 0.3s ease;
}

.success-message {
    color: #a7f3d0;
    background: rgba(16, 185, 129, 0.2);
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 14px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: none;
    font-size: 0.9rem;
}

.success-message.show {
    display: block;
    animation: slideIn 0.3s ease;
}

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

/* Connection Status */
.connection-status {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    padding: 14px 20px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    display: none;
    align-items: center;
    gap: 12px;
    z-index: 1000;
    animation: slideInUp 0.4s ease;
}

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

.connection-status.show {
    display: flex;
}

/* Emoji Picker */
.emoji-category-btn {
    padding: 6px 14px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.85rem;
    font-weight: 500;
}

.emoji-category-btn:hover {
    background: var(--card-bg-hover);
    color: var(--text-primary);
    border-color: var(--primary-color);
}

.emoji-category-btn.active {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.emoji-grid {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.emoji-grid::-webkit-scrollbar {
    width: 6px;
}

.emoji-grid::-webkit-scrollbar-track {
    background: transparent;
}

.emoji-grid::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.emoji-grid::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.emoji-item {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
    background: var(--card-bg);
    border: 1px solid transparent;
}

.emoji-item:hover {
    background: var(--card-bg-hover);
    transform: scale(1.15);
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    z-index: 10;
}

.emoji-item:active {
    transform: scale(1.05);
}

/* Button Search */
.button-search-input {
    width: 100%;
    padding: 10px 16px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all 0.3s;
}

.button-search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--card-bg-solid);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.button-search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 8px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 2px solid var(--glass-border);
    border-radius: 12px;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: var(--shadow-lg), 0 0 30px rgba(99, 102, 241, 0.15);
    display: none;
    z-index: 50;
}

.button-search-suggestions:not(:empty) {
    display: block;
}

.button-search-suggestion {
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.button-search-suggestion:last-child {
    border-bottom: none;
}

.button-search-suggestion:hover {
    background: var(--card-bg-hover);
}

.button-search-suggestion-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.button-search-suggestion-label {
    flex: 1;
    color: var(--text-primary);
    font-weight: 500;
}

.button-search-suggestion-instance {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Templates Grid */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.template-card {
    background: var(--card-bg);
    border: 2px solid var(--glass-border);
    border-radius: 16px;
    padding: 24px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.template-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.template-card:hover {
    background: var(--card-bg-hover);
    border-color: var(--primary-color);
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg), 0 0 30px rgba(99, 102, 241, 0.2);
}

.template-card:hover::before {
    opacity: 1;
}

.template-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.template-name {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.template-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.template-meta {
    display: flex;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Control Panel - Enhanced Large Buttons */
.control-panel {
    padding: 40px;
    max-width: 1600px;
    margin: 0 auto;
}

.control-panel h1, .control-panel h2 {
    margin-bottom: 30px;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
}

.control-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
    margin-top: 30px;
}

.control-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 2px solid var(--glass-border);
    border-radius: 24px;
    padding: 60px 40px;
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Gradient overlay */
.control-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.4s ease;
}

/* Shimmer effect on hover */
.control-card::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent 30%,
        rgba(255, 255, 255, 0.15) 50%,
        transparent 70%
    );
    transform: translateX(-100%) translateY(-100%) rotate(45deg);
    transition: transform 0.8s ease;
}

.control-card:hover::before {
    opacity: 1;
}

.control-card:hover::after {
    transform: translateX(100%) translateY(100%) rotate(45deg);
}

.control-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: var(--shadow-xl),
                inset 0 1px 0 rgba(255, 255, 255, 0.2),
                0 0 40px rgba(99, 102, 241, 0.3);
    border-color: rgba(99, 102, 241, 0.4);
}

.control-card:active {
    transform: translateY(-4px) scale(0.98);
    box-shadow: var(--shadow-lg),
                0 0 30px rgba(99, 102, 241, 0.4);
}

.control-card h3 {
    font-size: 1.6rem;
    font-weight: 700;
    text-align: center;
    color: var(--text-primary);
    position: relative;
    z-index: 1;
    letter-spacing: 0.02em;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Control card variants */
.control-card.primary {
    border-color: rgba(99, 102, 241, 0.3);
}

.control-card.primary:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(79, 70, 229, 0.2));
    border-color: var(--primary-color);
    box-shadow: var(--shadow-xl),
                0 0 50px rgba(99, 102, 241, 0.5),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.control-card.success {
    border-color: rgba(16, 185, 129, 0.3);
}

.control-card.success:hover {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(5, 150, 105, 0.2));
    border-color: var(--success-color);
    box-shadow: var(--shadow-xl),
                0 0 50px rgba(16, 185, 129, 0.5),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.control-card.warning {
    border-color: rgba(245, 158, 11, 0.3);
}

.control-card.warning:hover {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(217, 119, 6, 0.2));
    border-color: var(--warning-color);
    box-shadow: var(--shadow-xl),
                0 0 50px rgba(245, 158, 11, 0.5),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.control-card.danger {
    border-color: rgba(244, 63, 94, 0.3);
}

.control-card.danger:hover {
    background: linear-gradient(135deg, rgba(244, 63, 94, 0.2), rgba(220, 38, 38, 0.2));
    border-color: var(--danger-color);
    box-shadow: var(--shadow-xl),
                0 0 50px rgba(244, 63, 94, 0.5),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Control card with icon */
.control-card-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    display: block;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* Control tabs (for the sub-navigation) */
.control-tabs {
    display: flex;
    gap: 8px;
    background: var(--card-bg);
    backdrop-filter: blur(15px);
    padding: 8px;
    border-radius: 16px;
    margin-bottom: 32px;
    border: 2px solid var(--glass-border);
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
}

.control-tabs button {
    padding: 14px 28px;
    background: transparent;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-secondary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    letter-spacing: 0.02em;
    position: relative;
}

.control-tabs button::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    transform: translateX(-50%);
    transition: width 0.3s ease;
    border-radius: 2px;
}

.control-tabs button:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
}

.control-tabs button:hover::before {
    width: 70%;
}

.control-tabs button.active {
    color: white;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.control-tabs button.active::before {
    width: 0;
}

/* Mobile Actions Menu */
.mobile-menu-btn {
    display: none;
    background: var(--card-bg);
    border: 2px solid var(--glass-border);
    color: var(--text-primary);
    width: 44px;
    height: 44px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-sm);
}

.mobile-menu-btn:hover {
    background: var(--card-bg-hover);
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.mobile-menu-btn:active {
    transform: scale(0.95);
}

.mobile-menu-btn svg {
    display: block;
}

/* Mobile Actions Modal Styles */
.mobile-actions-modal .mobile-actions-content {
    max-width: 100%;
    border-radius: 24px 24px 0 0;
}

.mobile-actions-section {
    margin-bottom: 24px;
}

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

.mobile-actions-section h4 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
    padding-left: 4px;
}

.mobile-actions-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mobile-action-item {
    background: var(--card-bg);
    border: 2px solid var(--glass-border);
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    width: 100%;
    text-align: left;
    min-height: 56px;
    box-shadow: var(--shadow-sm);
}

.mobile-action-item:hover:not(:disabled) {
    background: var(--card-bg-hover);
    border-color: var(--primary-color);
    transform: translateX(4px);
    box-shadow: var(--shadow);
}

.mobile-action-item:active:not(:disabled) {
    transform: translateX(2px) scale(0.98);
}

.mobile-action-item:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.mobile-action-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    width: 32px;
    text-align: center;
}

.mobile-action-text {
    flex: 1;
    letter-spacing: 0.01em;
}

.mobile-action-danger {
    border-color: rgba(244, 63, 94, 0.3);
}

.mobile-action-danger:hover:not(:disabled) {
    background: rgba(244, 63, 94, 0.1);
    border-color: var(--danger-color);
}

/* Admin Only Elements */
.admin-only {
    display: none !important;
}

body.admin .admin-only {
    display: block !important;
}

body.admin .tab-btn.admin-only {
    display: inline-block !important;
}

body.admin button.admin-only {
    display: inline-flex !important;
}

/* Responsive - Enhanced Mobile/Tablet Support */

/* Tablet landscape and smaller */
@media (max-width: 1024px) {
    .button-grid::before {
        left: 0 !important;
    }

    .navbar-brand h2 {
        font-size: 1.2rem;
    }

    .navbar-menu {
        flex-wrap: wrap;
    }

    .button-grid {
        grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr));
        gap: 16px;
        padding: 20px;
    }
}

/* iPad and larger tablets - landscape and portrait */
@media (max-width: 1024px) and (min-width: 769px) {
    .button-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 18px;
        padding: 20px;
    }

    .button-card {
        min-height: 120px;
        padding: 20px !important;
    }

    .button-label {
        font-size: clamp(1.2rem, 3.5vw, 1.8rem) !important;
        font-weight: 700;
        line-height: 1.3;
        white-space: normal;
        word-wrap: break-word;
    }
}

/* Tablet portrait and mobile landscape */
@media (max-width: 768px) and (min-width: 481px) {
    body {
        font-size: 14px;
        background: #1a1f2e; /* Lighter background for mobile */
    }

    /* Navbar */
    .navbar {
        padding: 10px 12px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .button-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 16px;
        padding: 18px;
    }

    .button-card {
        min-height: 110px;
        padding: 18px !important;
    }

    .button-label {
        font-size: clamp(1.1rem, 4vw, 1.5rem) !important;
        font-weight: 700;
        line-height: 1.25;
        white-space: normal;
        word-wrap: break-word;
    }

    .navbar-brand {
        width: 100%;
        margin-bottom: 6px;
    }

    .navbar-brand h2 {
        font-size: 1rem;
    }

    .navbar-menu {
        width: 100%;
        justify-content: flex-start;
        gap: 8px;
        flex-wrap: wrap;
    }

    .navbar-menu .btn {
        font-size: 0.75rem;
        padding: 8px 12px;
        flex: 0 1 auto;
    }

    .user-info {
        font-size: 0.75rem;
        padding: 6px 12px;
        width: 100%;
        text-align: center;
        margin-bottom: 6px;
    }

    /* Main container */
    .main-container {
        flex-direction: column;
        height: auto !important;
    }

    /* Sidebar - collapsible on mobile */
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 50vh;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        position: relative;
    }

    .sidebar-header {
        padding: 12px 16px;
        flex-direction: row;
        align-items: center;
        gap: 10px;
        flex-wrap: nowrap;
    }

    .sidebar-header h3 {
        font-size: 1rem;
        width: auto;
        flex: 0 0 auto;
    }

    .sidebar-header > div {
        width: auto;
        justify-content: flex-end;
        flex-wrap: nowrap;
        gap: 8px;
        flex: 1;
    }

    .sidebar-header .btn {
        flex: 0 0 auto;
        white-space: nowrap;
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .sidebar-filters {
        padding: 8px 16px;
    }

    .sidebar-filters > div {
        margin-bottom: 6px;
    }

    .sidebar-filters label {
        margin-top: 0 !important;
        font-size: 0.8rem;
        padding: 6px;
    }

    .sidebar-filters .search-input,
    .sidebar-filters .filter-select {
        padding: 6px 10px;
        font-size: 0.85rem;
    }

    .sidebar-filters .checkbox-label {
        padding: 4px;
    }

    .pages-list {
        max-height: calc(50vh - 200px);
        min-height: 150px;
    }

    /* Content area */
    .content {
        min-height: 50vh;
        flex: 1;
    }

    .content-header {
        padding: 12px 16px;
        flex-direction: row;
        gap: 10px;
        align-items: center;
        justify-content: space-between;
    }

    .content-header h2 {
        font-size: 1.2rem;
        flex: 1;
    }

    /* Show mobile menu button, hide desktop actions */
    .mobile-menu-btn {
        display: flex !important;
    }

    .content-actions {
        display: none !important;
    }

    .content-actions .btn {
        flex: 0 1 auto;
        min-width: fit-content;
        font-size: 0.75rem;
        padding: 8px 12px;
        white-space: nowrap;
    }

    /* Hide disabled action buttons on mobile to save space */
    .content-actions .btn:disabled {
        display: none;
    }

    /* Button grid - already defined above in media query */

    .button-label {
        font-size: clamp(0.75rem, 2.5vw, 1rem) !important;
        padding: 6px 8px;
        line-height: 1.2;
        white-space: normal;
        word-break: keep-all;
    }

    .button-instance-name {
        font-size: 0.6rem;
        bottom: 6px;
    }

    /* Button actions removed - should only show for admins via admin-only class */

    .button-action-btn {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    /* Forms */
    .form-row {
        grid-template-columns: 1fr;
    }

    .form-group label {
        font-size: 0.85rem;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Modals - full screen on mobile */
    .modal {
        padding: 0;
        align-items: flex-start;
    }

    .modal-content {
        max-width: 100%;
        width: 100%;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }

    /* Mobile Actions Modal - slide up from bottom */
    .mobile-actions-modal {
        align-items: flex-end;
    }

    .mobile-actions-modal .mobile-actions-content {
        border-radius: 24px 24px 0 0;
        max-height: 80vh;
        animation: slideUpFromBottom 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

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

    .modal-content::before {
        border-radius: 0;
    }

    .modal-header {
        padding: 20px 16px 16px 16px;
        position: sticky;
        top: 0;
        background: var(--glass-bg);
        backdrop-filter: blur(30px);
        z-index: 10;
    }

    .modal-header h3 {
        font-size: 1.2rem;
    }

    .modal-body {
        padding: 16px;
        padding-bottom: 60px; /* Extra padding on mobile for footer visibility */
    }

    .modal-footer {
        flex-direction: column-reverse;
        gap: 8px;
        padding-bottom: 16px; /* Extra padding to prevent cutoff on mobile */
        margin-bottom: 8px;
    }

    .modal-footer .btn {
        width: 100%;
    }

    /* Tabs */
    .tabs {
        flex-wrap: wrap;
    }

    .tab-btn {
        padding: 10px 16px;
        font-size: 0.85rem;
    }

    /* List items */
    .list-item {
        padding: 16px;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .list-item-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .list-item:hover {
        transform: none;
    }

    /* Login */
    .login-box {
        padding: 30px 25px;
        border-radius: 16px;
    }

    .login-box h1 {
        font-size: 1.6rem;
    }

    /* Master Buttons Screen */
    #masterButtonsScreen .main-container {
        padding: 20px;
    }

    #masterButtonsScreen .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    #masterButtonsScreen .content-header > div {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 12px;
    }

    #masterButtonsScreen .content-header .btn {
        flex: 0 1 auto;
        white-space: nowrap;
    }

    /* Template grid */
    .templates-grid {
        grid-template-columns: 1fr;
    }

    /* Control grid */
    .control-grid {
        grid-template-columns: 1fr;
    }

    .control-panel {
        padding: 20px;
    }

    /* Status indicators */
    .status-indicator {
        font-size: 0.7rem;
        padding: 6px 12px;
    }

    /* Screenshot upload modal adjustments */
    #screenshotResultsList {
        max-height: 200px;
    }

    /* Filters - stack on mobile */
    .sidebar-filters,
    .master-buttons-filters {
        flex-direction: column;
    }

    .search-input,
    .filter-select {
        width: 100%;
    }

    /* Connection status - adjust position */
    .connection-status {
        bottom: 12px;
        right: 12px;
        left: 12px;
        padding: 12px 16px;
    }

    /* Page items */
    .page-item {
        padding: 10px 12px;
        margin-bottom: 6px;
    }

    .page-item-badge {
        font-size: 0.65rem;
        padding: 3px 8px;
    }

    .page-item-icon {
        font-size: 1rem;
    }

    .page-item-name {
        font-size: 0.9rem;
    }
}

/* Mobile portrait - smallest screens */
@media (max-width: 480px) {
    /* Compact navbar for more space */
    .navbar {
        padding: 8px 10px;
    }

    .navbar-brand h2 {
        font-size: 0.95rem;
    }

    .navbar-menu {
        gap: 6px;
    }

    .navbar-menu .btn {
        font-size: 0.7rem;
        padding: 6px 10px;
    }
}

/* Mobile portrait - smallest screens */
@media (max-width: 480px) {
    /* Mobile portrait - FORCE 2-column button grid for usability */
    .button-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px;
        padding: 10px;
    }

    /* Make buttons larger and more touch-friendly on mobile */
    .button-card {
        min-height: 64px !important;
        padding: 12px !important;
        border-radius: 14px;
    }

    .button-label {
        font-size: clamp(0.8rem, 3vw, 1.1rem) !important;
        line-height: 1.2;
        padding: 8px 6px;
        white-space: normal;
        word-break: keep-all;
    }

    /* Compact sidebar - give MORE room to control buttons */
    .sidebar {
        width: 100%;
        max-height: 75vh; /* Use most of screen for pages list */
        border-right: none;
        border-bottom: 2px solid var(--border-color);
    }

    .sidebar-header {
        padding: 6px 10px; /* Reduced padding */
    }

    .sidebar-header h3 {
        font-size: 0.85rem;
    }

    /* Hide filters on smallest screens to save space */
    .sidebar-filters {
        display: none;
    }

    .pages-list {
        /* Vertical stack on mobile */
        display: flex !important;
        flex-direction: column !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        max-height: calc(75vh - 60px) !important; /* Match sidebar height minus header */
        height: auto !important;
        padding: 8px !important;
        gap: 8px !important;
        -webkit-overflow-scrolling: touch; /* Smooth momentum scrolling on iOS */
        scrollbar-width: none; /* Hide scrollbar Firefox */
    }

    /* Hide scrollbar for cleaner look */
    .pages-list::-webkit-scrollbar {
        display: none !important;
    }

    /* Simplify page items for vertical stacking */
    .page-item {
        flex-direction: row;
        width: 100%;
        min-width: 100%;
        max-width: 100%;
        height: auto;
        min-height: 50px;
        padding: 10px 12px;
        margin-bottom: 0;
        gap: 10px;
        align-items: center;
        justify-content: flex-start;
        flex-shrink: 0;
        border-radius: 12px;
    }

    /* Hide complex elements on mobile */
    .page-item-badge,
    .page-item-meta,
    .page-item-description,
    .page-category-badge {
        display: none !important;
    }

    .page-item-header {
        flex-direction: column;
        gap: 2px;
        width: 100%;
    }

    .page-item-title {
        flex-direction: column;
        gap: 2px;
        width: 100%;
    }

    .page-item-icon {
        font-size: 1.2rem;
        flex-shrink: 0;
    }

    .page-item-name {
        font-size: 0.65rem;
        text-align: center;
        white-space: normal; /* Allow text to wrap */
        word-wrap: break-word;
        overflow-wrap: break-word;
        max-width: 100%;
        line-height: 1.2;
        hyphens: auto;
    }

    .page-item:hover {
        transform: translateY(-2px); /* Change from translateX to translateY for horizontal */
    }

    .page-item.active {
        transform: translateY(-2px);
    }

    /* Simplify navbar on mobile */
    .navbar-menu .admin-only {
        display: none !important;
    }

    /* Hide button edit/delete icons on mobile - too confusing inside buttons */
    .button-actions {
        display: none !important;
    }

    body.admin .button-card .button-actions {
        display: none !important;
    }

    /* Smaller modals padding */
    .modal-header {
        padding: 16px 12px 12px 12px;
    }

    .modal-header h3 {
        font-size: 1.1rem;
    }

    .modal-body {
        padding: 12px;
        padding-bottom: 70px; /* Extra padding on smallest screens for footer */
    }

    .login-box {
        padding: 25px 20px;
    }

    .login-box h1 {
        font-size: 1.4rem;
    }

    /* Hide action buttons on mobile, show mobile menu instead */
    .mobile-menu-btn {
        display: flex !important;
    }

    .content-actions {
        display: none !important;
    }

    /* Master buttons list */
    .list-item {
        padding: 12px;
    }

    .list-item h4 {
        font-size: 1rem;
    }

    .list-item-meta {
        font-size: 0.8rem;
    }

    /* Ensure buttons don't get too small */
    .button-card {
        font-size: 0.8rem;
    }
}

/* Landscape mode for phones */
@media (max-height: 500px) and (orientation: landscape) {
    .navbar {
        position: relative;
    }

    .main-container {
        height: auto !important;
    }

    .sidebar {
        max-height: 150px;
    }

    .modal-content {
        max-height: 100vh;
    }

    .button-grid {
        padding: 15px;
        min-height: auto;
    }
}

/* Touch device specific - larger tap targets */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
        padding: 12px 20px;
    }

    .button-action-btn {
        min-width: 44px;
        min-height: 44px;
    }

    .tab-btn {
        min-height: 44px;
    }

    .modal-close {
        min-width: 44px;
        min-height: 44px;
    }

    input[type="checkbox"] {
        min-width: 24px;
        min-height: 24px;
    }

    /* Disable hover effects on touch devices */
    .button-card:hover {
        transform: none;
    }

    .button-card:hover::before {
        opacity: 0;
    }

    /* Button actions are hidden on mobile via 480px media query */
    /* Removed: body.admin .button-card .button-actions - conflicts with mobile UX */
}

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

.button-card,
.page-item,
.list-item {
    animation: fadeIn 0.4s ease;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 5px;
}

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

/* Selection */
::selection {
    background: var(--primary-color);
    color: white;
}

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

/* Confirmation Modal - Pulse Animation */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}
