/**
 * CLAUDIA Dashboard - Mobile UX Improvements
 * Version: 1.1
 * Features:
 * - Enhanced mobile menu with section navigation
 * - Floating Action Button (FAB) for quick navigation
 * - Collapsible sections
 * - Smooth scroll navigation
 * - Font optimization
 * - Skeleton loading screens
 * - Error states
 */

/* =============================================
   FONT OPTIMIZATION
   ============================================= */

/* Optimized system font stack - no external fonts needed */
:root {
    /* Primary sans-serif stack (system fonts) */
    --font-system: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                   'Helvetica Neue', Arial, 'Noto Sans', sans-serif,
                   'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';

    /* Monospace stack for code */
    --font-mono-system: ui-monospace, 'SF Mono', 'Monaco', 'Cascadia Code',
                        'Roboto Mono', 'Consolas', 'Liberation Mono',
                        'Courier New', monospace;
}

/* Base font rendering optimization */
html {
    /* Prevent FOIT (Flash of Invisible Text) */
    font-display: swap;

    /* Optimize text rendering */
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;

    /* Improve text size consistency across platforms */
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Body font defaults */
body {
    font-family: var(--font-system);
    font-feature-settings: 'kern' 1, 'liga' 1;
    font-kerning: normal;
}

/* Monospace elements */
code, pre, kbd, samp, .mono {
    font-family: var(--font-mono-system);
}

/* Font loading optimization classes */
.fonts-loading {
    /* Show system fonts while custom fonts load (if any) */
    font-family: var(--font-system) !important;
}

.fonts-loaded body {
    /* Smooth transition when fonts are loaded */
    transition: font-family 0.1s ease;
}

/* Prevent layout shift from font loading */
@supports (font-display: swap) {
    @font-face {
        font-display: swap;
    }
}

/* Mobile-specific font size adjustments */
@media (max-width: 768px) {
    html {
        /* Slightly larger base for mobile readability */
        font-size: 16px;
    }

    /* Minimum readable sizes */
    body {
        font-size: 1rem;
        line-height: 1.5;
    }

    /* Prevent tiny text on mobile */
    small, .text-small {
        font-size: max(0.75rem, 12px);
    }
}

/* =============================================
   MOBILE SECTION NAVIGATION (inside mobile menu)
   ============================================= */

/* Divider between pages and sections */
.mobile-nav-divider {
    height: 1px;
    background: var(--border-color);
    margin: 1rem 0;
    opacity: 0.5;
}

/* Section label header */
.mobile-nav-section-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0.5rem 1.5rem;
    margin-top: 0.5rem;
}

/* Section navigation items */
.mobile-nav-sections {
    display: flex;
    flex-direction: column;
    padding: 0 1rem;
    gap: 0.25rem;
}

.mobile-section-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    cursor: pointer;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
}

.mobile-section-link:hover {
    background: var(--lohmia-accent-10);
    color: var(--text-primary);
}

.mobile-section-link.active {
    background: var(--lohmia-accent-15);
    color: var(--accent-blue);
    font-weight: 500;
}

.mobile-section-icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

/* Only show section navigation on mobile */
@media (min-width: 769px) {
    .mobile-nav-divider,
    .mobile-nav-section-label,
    .mobile-nav-sections {
        display: none;
    }
}

/* =============================================
   FLOATING ACTION BUTTON (FAB)
   ============================================= */

.fab-container {
    position: fixed;
    bottom: 24px;
    right: 20px;
    z-index: var(--z-fab, 1050);
    display: none; /* Hidden by default, shown only on mobile */
    transition: bottom 0.3s ease;
}

/* Reposition FAB when bottom-nav is present */
body.has-bottom-nav .fab-container {
    bottom: calc(var(--mobile-bottom-space, 84px) + 10px);
}

/* Show FAB only on mobile */
@media (max-width: 768px) {
    .fab-container {
        display: block;
    }
}

/* Main FAB button */
.fab-button {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent-blue);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px var(--lohmia-accent-40);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
}

.fab-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px var(--lohmia-accent-50);
}

.fab-button:active {
    transform: scale(0.95);
}

.fab-button.open {
    transform: rotate(45deg);
    background: var(--accent-red);
}

.fab-icon {
    font-size: 1.5rem;
    color: white;
    transition: transform 0.3s ease;
}

/* FAB mini-menu */
.fab-menu {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 220px;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    padding: 0.5rem 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.9);
    transition: all 0.25s ease;
    max-height: 60vh;
    overflow-y: auto;
}

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

/* Menu header */
.fab-menu-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Menu items */
.fab-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    cursor: pointer;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
}

.fab-menu-item:hover {
    background: var(--lohmia-accent-10);
}

.fab-menu-item.active {
    background: var(--lohmia-accent-15);
    color: var(--accent-blue);
}

.fab-menu-item:active {
    background: var(--lohmia-accent-20);
}

.fab-item-icon {
    font-size: 1rem;
    width: 24px;
    text-align: center;
}

/* Backdrop when FAB menu is open */
.fab-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: var(--z-fab-backdrop, 1049);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
}

.fab-backdrop.open {
    opacity: 1;
    visibility: visible;
}

/* =============================================
   COLLAPSIBLE SECTIONS (Mobile Only)
   ============================================= */

/* Section header becomes clickable on mobile */
@media (max-width: 768px) {
    .section.collapsible .section-header-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        cursor: pointer;
        padding: 0.5rem 0;
        margin-bottom: 0.5rem;
    }

    .section.collapsible h2 {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        flex: 1;
        margin-bottom: 0;
    }

    .section-collapse-icon {
        font-size: 1rem;
        color: var(--text-secondary);
        transition: transform 0.3s ease;
        width: 24px;
        height: 24px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(255, 255, 255, 0.05);
        border-radius: 4px;
    }

    .section.collapsible.collapsed .section-collapse-icon {
        transform: rotate(-90deg);
    }

    .section-collapsible-content {
        max-height: 2000px;
        overflow: hidden;
        transition: max-height 0.4s ease, opacity 0.3s ease;
        opacity: 1;
    }

    .section.collapsible.collapsed .section-collapsible-content {
        max-height: 0;
        opacity: 0;
        padding: 0;
        margin: 0;
    }

    /* Add collapse indicator badge */
    .collapse-indicator {
        font-size: 0.65rem;
        padding: 2px 6px;
        border-radius: 4px;
        background: var(--lohmia-accent-10);
        color: var(--accent-blue);
        margin-left: auto;
        margin-right: 8px;
    }

    .section.collapsed .collapse-indicator {
        background: rgba(139, 92, 246, 0.1);
        color: var(--accent-purple);
    }
}

/* Hide collapse elements on desktop - siempre expandido */
@media (min-width: 769px) {
    .section-collapse-icon,
    .collapse-indicator {
        display: none !important;
    }

    .section-header-toggle {
        cursor: default !important;
    }

    /* Forzar contenido siempre visible en desktop */
    .section-collapsible-content,
    .collapsible-content {
        max-height: none !important;
        opacity: 1 !important;
        overflow: visible !important;
    }

    .section.collapsible.collapsed .section-collapsible-content,
    .collapsible-section.collapsed .collapsible-content {
        max-height: none !important;
        opacity: 1 !important;
        overflow: visible !important;
    }
}

/* =============================================
   ACTIVE SECTION INDICATOR
   ============================================= */

/* Current section indicator dot */
.section-indicator-dot {
    width: 6px;
    height: 6px;
    background: var(--accent-blue);
    border-radius: 50%;
    margin-left: auto;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-section-link.active .section-indicator-dot,
.fab-menu-item.active .section-indicator-dot {
    opacity: 1;
}

/* =============================================
   SCROLL TO TOP BUTTON
   ============================================= */

.scroll-to-top {
    position: fixed;
    bottom: 90px; /* Above FAB */
    right: 26px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    cursor: pointer;
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    z-index: var(--z-scroll-top, 1040);
    color: var(--text-primary);
    font-size: 1.2rem;
}

/* Reposition scroll-to-top when bottom-nav is present */
body.has-bottom-nav .scroll-to-top {
    bottom: calc(var(--mobile-bottom-space, 84px) + 70px);
}

.scroll-to-top:hover {
    background: var(--accent-blue);
    color: white;
    transform: translateY(-2px);
}

.scroll-to-top.visible {
    display: flex;
}

/* Only show on mobile */
@media (min-width: 769px) {
    .scroll-to-top {
        display: none !important;
    }
}

/* =============================================
   SMOOTH SCROLL BEHAVIOR
   ============================================= */

html {
    scroll-behavior: smooth;
}

/* Anchor offset for sticky header */
.section[id]:target,
#infrastructure:target,
#status:target {
    scroll-margin-top: 80px;
}

/* =============================================
   ADDITIONAL MOBILE OPTIMIZATIONS
   ============================================= */

@media (max-width: 768px) {
    /* Reduce padding on mobile for more content space */
    .content-grid {
        padding: 0 1rem var(--mobile-bottom-space, 84px); /* Sync with bottom-nav */
    }

    .summary {
        padding: 1rem;
        margin-top: 90px !important; /* Space for fixed header */
    }

    /* Ensure sections have IDs for navigation */
    .section {
        scroll-margin-top: 70px; /* Account for sticky header */
    }

    /* Better touch targets for action buttons */
    .action-btn {
        min-height: 48px;
    }

    /* Mobile menu improvements */
    .mobile-nav {
        width: var(--sidebar-width, 280px);
        left: calc(-1 * var(--sidebar-width, 280px));
        overflow-y: auto;
    }

    .mobile-nav.active {
        left: 0;
    }
}

/* =============================================
   ANIMATION UTILITIES
   ============================================= */

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

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.fab-button.pulse {
    animation: pulse 2s infinite;
}

/* Entry animation for FAB */
.fab-container {
    animation: slideUp 0.5s ease 0.5s backwards;
}

/* =============================================
   FIX: HEADER OVERFLOW ON MOBILE
   ============================================= */

@media (max-width: 480px) {
    /* Prevent horizontal overflow */
    html, body {
        overflow-x: hidden;
        max-width: 100vw;
    }

    /* Fix header layout on small screens */
    .main-header {
        padding: 0.5rem 0.75rem !important;
        gap: 0.5rem !important;
        overflow: hidden;
    }

    /* Make header-actions compact */
    .header-actions {
        flex: 0 0 auto !important;
        gap: 0.25rem !important;
        max-width: 100px;
    }

    /* Compact Refresh button */
    .header-actions .btn,
    .header-actions .btn-primary {
        padding: 0.4rem 0.6rem !important;
        font-size: 0.8rem !important;
        white-space: nowrap;
    }

    /* Hide text, show only icon on very small screens */
    .header-actions .btn-primary {
        min-width: auto;
    }

    /* Logo text smaller */
    .logo h1 {
        font-size: 1.1rem !important;
    }

    /* Ensure logo section doesn't expand */
    .logo-section {
        flex: 0 0 auto !important;
        max-width: calc(100vw - 120px);
    }
}

/* Additional fix for 375px and below */
@media (max-width: 375px) {
    .main-header {
        padding: 0.4rem 0.5rem !important;
    }

    .header-actions .btn-primary {
        padding: 0.35rem 0.5rem !important;
        font-size: 0.75rem !important;
    }

    .logo h1 {
        font-size: 1rem !important;
    }

    .mobile-menu-toggle {
        font-size: 1.2rem !important;
        padding: 0.3rem !important;
        min-width: 36px;
    }
}

/* Hide Refresh text on mobile, show only icon */
@media (max-width: 480px) {
    .refresh-btn .refresh-text {
        display: none;
    }
    
    .refresh-btn {
        padding: 0.5rem !important;
        min-width: 40px !important;
        width: 40px !important;
        height: 40px !important;
        border-radius: 8px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .refresh-btn .refresh-icon {
        font-size: 1.2rem;
    }
}

/* =============================================
   MOBILE FORM ELEMENTS - Touch-friendly
   ============================================= */
@media (max-width: 768px) {
    /* Inputs, textareas, selects - min 44px height, 16px font to prevent iOS zoom */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="search"],
    input[type="tel"],
    input[type="url"],
    textarea,
    select,
    .form-input,
    .search-input {
        min-height: 44px !important;
        font-size: 16px !important; /* Prevents iOS zoom on focus */
        padding: 10px 12px !important;
        -webkit-appearance: none;
        appearance: none;
    }

    /* Buttons - min 44px height for touch targets */
    button,
    .btn,
    input[type="submit"],
    input[type="button"] {
        min-height: 44px !important;
        padding: 10px 16px !important;
        font-size: 14px !important;
    }

    /* Smaller buttons that need to stay compact */
    .btn-sm,
    .btn-icon,
    button.icon-only,
    .mobile-menu-toggle,
    .mobile-nav-close,
    .close-panel-btn,
    .history-select-btn,
    .claudia-gallery-close {
        min-height: 40px !important;
        min-width: 40px !important;
        padding: 8px !important;
    }

    /* Delete/action buttons in lists */
    .btn-danger,
    button[class*="delete"],
    button[class*="remove"] {
        min-height: 36px !important;
        padding: 6px 12px !important;
    }

    /* Select dropdown arrow spacing */
    select {
        padding-right: 32px !important;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 10px center;
    }
}

/* =============================================
   MOBILE TEXT READABILITY - Minimum 12px
   ============================================= */
@media (max-width: 768px) {
    /* Small labels that need to stay readable */
    .collapse-indicator,
    .admin-label,
    .status-badge,
    .tab-label,
    .stat-label,
    .metric-label,
    .card-subtitle,
    .text-muted,
    .text-secondary {
        font-size: 12px !important;
    }

    /* Stats and metrics - keep readable */
    .stat-value {
        font-size: 1.25rem !important;
    }
}

/* =============================================
   BOTTOM NAV SPACING - Better touch targets
   ============================================= */
@media (max-width: 768px) {
    /* Increase spacing between bottom nav items */
    .bottom-nav {
        gap: 8px !important;
        padding: 8px 12px !important;
    }

    .bottom-nav-item,
    .nav-item {
        min-width: 56px !important;
        padding: 8px 10px !important;
        gap: 4px !important;
    }

    /* Tab-style bottom nav */
    .page-tabs,
    .view-tabs {
        gap: 8px !important;
    }

    .page-tabs .tab,
    .view-tabs .tab,
    .tab-btn {
        padding: 10px 14px !important;
        min-height: 40px !important;
        font-size: 13px !important;
    }
}

/* =============================================
   TOUCH TARGET SIZES - Minimum 40x40px
   ============================================= */
@media (max-width: 768px) {
    /* Collapse indicators */
    .collapse-indicator,
    .section-collapse-icon,
    .expand-btn,
    .toggle-btn {
        min-width: 40px !important;
        min-height: 40px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Close buttons */
    .close-btn,
    .modal-close,
    [class*="lightbox-clo"],
    button[aria-label="Close"] {
        min-width: 44px !important;
        min-height: 44px !important;
    }

    /* Action icons in lists */
    .action-icon,
    .list-action,
    .row-action {
        min-width: 40px !important;
        min-height: 40px !important;
        padding: 8px !important;
    }
}

/* =============================================
   SKELETON LOADING SCREENS
   Mobile-optimized loading placeholders
   ============================================= */

/* Base skeleton shimmer animation */
.skeleton {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.06) 0%,
        rgba(255, 255, 255, 0.12) 50%,
        rgba(255, 255, 255, 0.06) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
}

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

/* Skeleton text lines */
.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
}
.skeleton-text.short { width: 40%; }
.skeleton-text.medium { width: 70%; }
.skeleton-text.long { width: 90%; }

/* Skeleton card */
.skeleton-card {
    background: var(--bg-card, #334155);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid var(--border-color, #475569);
}

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

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
}

.skeleton-title {
    height: 18px;
    width: 60%;
}

/* Skeleton server card */
.skeleton-server-card {
    background: var(--bg-card, #334155);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid var(--border-color, #475569);
}

.skeleton-server-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.skeleton-server-name {
    height: 20px;
    width: 120px;
}

.skeleton-server-status {
    height: 24px;
    width: 60px;
    border-radius: 12px;
}

.skeleton-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.skeleton-metric {
    height: 48px;
    border-radius: 8px;
}

/* Skeleton chat message */
.skeleton-message {
    display: flex;
    gap: 12px;
    padding: 12px;
}

.skeleton-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
}

.skeleton-message-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.skeleton-message-line {
    height: 14px;
}
.skeleton-message-line:nth-child(1) { width: 80%; }
.skeleton-message-line:nth-child(2) { width: 65%; }
.skeleton-message-line:nth-child(3) { width: 45%; }

/* Loading spinner */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-blue, #00D4AA);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Loading dots */
.loading-dots {
    display: inline-flex;
    gap: 4px;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    background: var(--accent-blue, #00D4AA);
    border-radius: 50%;
    animation: loading-dot 1.4s ease-in-out infinite;
}
.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes loading-dot {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Page loading state */
.page-loading {
    min-height: 50vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: var(--text-secondary, #94a3b8);
}

.page-loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-blue, #00D4AA);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Button loading state */
.btn.loading,
button.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn.loading::after,
button.loading::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

/* Card loading overlay */
.card.loading {
    position: relative;
    overflow: hidden;
}

.card.loading::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.7);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card.loading::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--accent-blue, #00D4AA);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 11;
}

/* Content fade-in after loading */
.content-loaded {
    animation: content-fade-in 0.3s ease-out;
}

@keyframes content-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Skeleton grid for dashboard */
.skeleton-grid {
    display: grid;
    gap: 16px;
    padding: 16px;
}

@media (min-width: 768px) {
    .skeleton-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .skeleton-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* =============================================
   ERROR STATES & EMPTY STATES
   Mobile-friendly error handling
   ============================================= */

/* Empty state container */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    min-height: 200px;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary, #f1f5f9);
    margin-bottom: 8px;
}

.empty-state-description {
    font-size: 14px;
    color: var(--text-secondary, #94a3b8);
    margin-bottom: 24px;
    max-width: 280px;
    line-height: 1.5;
}

.empty-state-action {
    background: var(--accent-blue, #00D4AA);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.empty-state-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 212, 170, 0.3);
}

.empty-state-action:active {
    transform: translateY(0);
}

/* Error state container */
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    min-height: 200px;
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 12px;
    margin: 16px;
}

.error-state-icon {
    width: 64px;
    height: 64px;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    font-size: 28px;
}

.error-state-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--accent-red, #ef4444);
    margin-bottom: 8px;
}

.error-state-description {
    font-size: 14px;
    color: var(--text-secondary, #94a3b8);
    margin-bottom: 24px;
    max-width: 280px;
    line-height: 1.5;
}

.error-state-code {
    font-family: monospace;
    font-size: 12px;
    background: rgba(0, 0, 0, 0.2);
    padding: 8px 12px;
    border-radius: 4px;
    color: var(--text-secondary, #94a3b8);
    margin-bottom: 16px;
}

/* Retry button */
.retry-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--accent-red, #ef4444);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.retry-btn:hover {
    background: #dc2626;
    transform: translateY(-2px);
}

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

.retry-btn.loading {
    pointer-events: none;
    opacity: 0.7;
}

.retry-btn svg,
.retry-btn .icon {
    width: 16px;
    height: 16px;
}

/* Offline state */
.offline-state {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    z-index: 9999;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.offline-state.visible {
    transform: translateY(0);
}

.offline-state-icon {
    font-size: 18px;
}

/* Inline error message */
.inline-error {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 12px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    margin: 8px 0;
}

.inline-error-icon {
    color: var(--accent-red, #ef4444);
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 2px;
}

.inline-error-text {
    font-size: 13px;
    color: var(--text-primary, #f1f5f9);
    line-height: 1.4;
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 9998;
    opacity: 0;
    transition: all 0.3s ease;
    max-width: calc(100vw - 32px);
}

.toast.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast-error {
    background: var(--accent-red, #ef4444);
    color: white;
}

.toast-success {
    background: var(--accent-green, #10b981);
    color: white;
}

.toast-warning {
    background: var(--accent-yellow, #f59e0b);
    color: #1a1a1a;
}

.toast-info {
    background: var(--bg-card, #334155);
    color: var(--text-primary, #f1f5f9);
    border: 1px solid var(--border-color, #475569);
}

.toast-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.toast-close {
    background: none;
    border: none;
    color: inherit;
    opacity: 0.7;
    cursor: pointer;
    padding: 4px;
    margin-left: auto;
    font-size: 16px;
}

.toast-close:hover {
    opacity: 1;
}

/* Network error specific */
.network-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px 24px;
    text-align: center;
}

.network-error-animation {
    width: 80px;
    height: 80px;
    margin-bottom: 16px;
    position: relative;
}

.network-error-animation::before,
.network-error-animation::after {
    content: '';
    position: absolute;
    border-radius: 50%;
}

.network-error-animation::before {
    width: 60px;
    height: 60px;
    top: 10px;
    left: 10px;
    border: 3px solid rgba(239, 68, 68, 0.2);
}

.network-error-animation::after {
    width: 40px;
    height: 40px;
    top: 20px;
    left: 20px;
    border: 3px dashed var(--accent-red, #ef4444);
    animation: network-spin 2s linear infinite;
}

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

/* Form validation errors */
.form-field.has-error input,
.form-field.has-error select,
.form-field.has-error textarea {
    border-color: var(--accent-red, #ef4444) !important;
    background: rgba(239, 68, 68, 0.05);
}

.form-field.has-error input:focus,
.form-field.has-error select:focus,
.form-field.has-error textarea:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.field-error {
    font-size: 12px;
    color: var(--accent-red, #ef4444);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.field-error::before {
    content: '!';
    width: 14px;
    height: 14px;
    background: var(--accent-red, #ef4444);
    color: white;
    border-radius: 50%;
    font-size: 10px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Connection status indicator */
.connection-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
}

.connection-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.connection-status.online .connection-status-dot {
    background: var(--accent-green, #10b981);
    box-shadow: 0 0 8px var(--accent-green, #10b981);
}

.connection-status.offline .connection-status-dot {
    background: var(--accent-red, #ef4444);
    animation: pulse-dot 1.5s ease-in-out infinite;
}

.connection-status.reconnecting .connection-status-dot {
    background: var(--accent-yellow, #f59e0b);
    animation: pulse-dot 0.8s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

/* Mobile-specific adjustments */
@media (max-width: 768px) {
    .toast {
        bottom: calc(var(--mobile-bottom-space, 84px) + 16px);
        left: 16px;
        right: 16px;
        transform: translateX(0) translateY(100px);
        max-width: none;
    }

    .toast.visible {
        transform: translateX(0) translateY(0);
    }

    .error-state,
    .empty-state {
        margin: 8px;
        padding: 32px 16px;
    }

    .error-state-icon,
    .empty-state-icon {
        font-size: 40px;
    }

    .offline-state {
        padding: 10px 12px;
        font-size: 13px;
    }
}
