/* =================================================================== */
/* UPDATED MAIN CSS - HERO LAYOUT & MOBILE FIXES */
/* =================================================================== */

body {
    font-family: 'Inter', sans-serif;
    margin: 0;
    background-color: #111827;
    color: #f3f4f6;
    overflow-x: hidden;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* HERO SECTION STYLES */
.hero-section {
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    border-bottom: 1px solid #374151;
}

.viewer-section {
    background-color: #111827;
}

/* ENHANCED FULLSCREEN CONTAINER */
.fullscreen-container {
    position: relative;
    border-radius: 0.75rem;
    overflow: hidden;
    transition: all 0.3s ease;
}

.fullscreen-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 20;
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    gap: 8px;
}

.fullscreen-container:hover .fullscreen-controls,
.fullscreen-container:focus-within .fullscreen-controls {
    opacity: 1;
}

/* MOBILE EXIT FULLSCREEN BUTTON */
.mobile-exit-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 30;
}

.mobile-exit-btn.show {
    display: block !important;
}

/* ENHANCED FULLSCREEN ACTIVE STATE */
.fullscreen-active {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 999999 !important;
    background: black !important;
    border-radius: 0 !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

.fullscreen-active iframe {
    width: 100vw !important;
    height: 100vh !important;
    border: none !important;
    border-radius: 0 !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 999999 !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* IFRAME FULLSCREEN SUPPORT - ENHANCED FOR VIDEO PLAYERS */
iframe:-webkit-full-screen {
    width: 100vw !important;
    height: 100vh !important;
    border: none !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 999999 !important;
    background: black !important;
    margin: 0 !important;
    padding: 0 !important;
}

iframe:-moz-full-screen {
    width: 100vw !important;
    height: 100vh !important;
    border: none !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 999999 !important;
    background: black !important;
    margin: 0 !important;
    padding: 0 !important;
}

iframe:fullscreen {
    width: 100vw !important;
    height: 100vh !important;
    border: none !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 999999 !important;
    background: black !important;
    margin: 0 !important;
    padding: 0 !important;
}

iframe:-ms-fullscreen {
    width: 100vw !important;
    height: 100vh !important;
    border: none !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 999999 !important;
    background: black !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* VIDEO ELEMENT FULLSCREEN SUPPORT */
video:fullscreen,
video:-webkit-full-screen,
video:-moz-full-screen,
video:-ms-fullscreen {
    width: 100vw !important;
    height: 100vh !important;
    object-fit: contain !important;
    background: black !important;
}

/* BOOKMARK ITEMS - CARD LAYOUT */
.bookmark-item {
    transition: all 0.2s ease;
    border-radius: 0.75rem;
    position: relative;
    cursor: pointer;
    border: 1px solid transparent;
    background: linear-gradient(135deg, #374151 0%, #4b5563 100%);
    padding: 1rem;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
}

.bookmark-item:hover, .bookmark-item:focus {
    transform: translateY(-4px) scale(1.02);
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    background: linear-gradient(135deg, #4b5563 0%, #6b7280 100%);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.bookmark-item:active {
    transform: translateY(-2px) scale(1.01);
}

.bookmark-name {
    font-size: 1rem;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bookmark-url {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-bottom: 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bookmark-visits {
    font-size: 0.625rem;
    color: #6b7280;
}

.bookmark-category {
    font-size: 0.625rem;
    color: #8b5cf6;
    font-weight: 500;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.bookmark-remove {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s ease;
    background: rgba(220, 38, 38, 0.9);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    border: none;
    cursor: pointer;
}

.bookmark-item:hover .bookmark-remove {
    opacity: 1;
}

.bookmark-remove:hover {
    background: rgba(220, 38, 38, 1);
    transform: scale(1.1);
}

/* MOBILE INPUT FIXES - COMPLETELY REWRITTEN */
input[type="text"], 
input[type="url"], 
input[type="email"], 
input[type="search"],
textarea {
    /* Reset all custom styling that might interfere */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    
    /* Essential mobile compatibility */
    font-size: 16px; /* Critical: Prevents zoom on iOS */
    line-height: 1.5;
    border-radius: 0.5rem;
    border: 2px solid #374151;
    background-color: #f9fafb;
    color: #111827;
    padding: 12px 16px;
    width: 100%;
    box-sizing: border-box;
    
    /* Mobile-specific properties */
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    
    /* Disable any transforms or transitions that might interfere */
    transform: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="text"]:focus, 
input[type="url"]:focus, 
input[type="email"]:focus, 
input[type="search"]:focus,
textarea:focus {
    border-color: #3b82f6;
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    background-color: #ffffff;
    
    /* Ensure no transforms on focus */
    transform: none !important;
}

/* MOBILE SPECIFIC INPUT STYLES - CRITICAL FIXES */
@media (max-width: 768px) {
    input[type="text"], 
    input[type="url"], 
    input[type="email"], 
    input[type="search"],
    textarea {
        /* Force proper mobile input styling */
        font-size: 16px !important; /* Prevents zoom on iOS */
        min-height: 48px !important;
        padding: 12px 16px !important;
        line-height: 1.5 !important;
        border-radius: 8px !important;
        
        /* Ensure text input is recognized */
        -webkit-user-select: text !important;
        -moz-user-select: text !important;
        -ms-user-select: text !important;
        user-select: text !important;
        -webkit-touch-callout: default !important;
        
        /* Remove any interference */
        -webkit-appearance: none !important;
        -moz-appearance: none !important;
        appearance: none !important;
        
        /* Ensure proper touch handling */
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: transparent !important;
        
        /* Force proper background and text color */
        background-color: #ffffff !important;
        color: #111827 !important;
        border: 2px solid #d1d5db !important;
        
        /* Disable problematic CSS */
        transform: none !important;
        animation: none !important;
        transition: border-color 0.2s ease !important;
    }
    
    input[type="text"]:focus, 
    input[type="url"]:focus, 
    input[type="email"]:focus, 
    input[type="search"]:focus,
    textarea:focus {
        border-color: #3b82f6 !important;
        background-color: #ffffff !important;
        color: #111827 !important;
        outline: none !important;
        box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2) !important;
        transform: none !important;
    }
    
    /* Specific fixes for input elements with classes */
    .input-mobile {
        font-size: 16px !important;
        min-height: 48px !important;
        padding: 12px 16px !important;
        line-height: 1.5 !important;
        -webkit-text-size-adjust: 100% !important;
        background-color: #ffffff !important;
        color: #111827 !important;
        border: 2px solid #d1d5db !important;
        border-radius: 8px !important;
        -webkit-appearance: none !important;
        touch-action: manipulation !important;
        -webkit-user-select: text !important;
        user-select: text !important;
    }
    
    .input-mobile:focus {
        border-color: #3b82f6 !important;
        background-color: #ffffff !important;
        color: #111827 !important;
        outline: none !important;
        box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2) !important;
    }
    
    /* URL input specific fixes */
    #urlInput {
        font-size: 16px !important;
        -webkit-appearance: none !important;
        background-color: #ffffff !important;
        color: #111827 !important;
        border: 2px solid #d1d5db !important;
        padding: 12px 16px !important;
        border-radius: 8px !important;
        touch-action: manipulation !important;
        -webkit-user-select: text !important;
        user-select: text !important;
    }
    
    #urlInput:focus {
        border-color: #3b82f6 !important;
        background-color: #ffffff !important;
        color: #111827 !important;
        outline: none !important;
        box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2) !important;
    }
    
    /* Modal input fixes */
    #addBookmarkModal input[type="text"],
    #addBookmarkModal input[type="url"] {
        font-size: 16px !important;
        min-height: 48px !important;
        padding: 12px 16px !important;
        background-color: #374151 !important;
        color: #ffffff !important;
        border: 2px solid #4b5563 !important;
        border-radius: 8px !important;
        -webkit-appearance: none !important;
        -webkit-user-select: text !important;
        user-select: text !important;
        touch-action: manipulation !important;
    }
    
    #addBookmarkModal input[type="text"]:focus,
    #addBookmarkModal input[type="url"]:focus {
        border-color: #3b82f6 !important;
        background-color: #374151 !important;
        color: #ffffff !important;
        outline: none !important;
        box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3) !important;
    }
}

/* BLOCKED INDICATOR ANIMATION */
.blocked-indicator {
    animation: pulse 2s infinite;
    border-radius: 0.5rem;
    backdrop-filter: blur(4px);
}

@keyframes pulse {
    0%, 100% { 
        opacity: 1;
        transform: scale(1);
    }
    50% { 
        opacity: 0.7;
        transform: scale(1.02);
    }
}

/* SCROLLBAR STYLING */
.scrollbar-thin::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.scrollbar-thin::-webkit-scrollbar-track {
    background: #374151;
    border-radius: 3px;
}

.scrollbar-thin::-webkit-scrollbar-thumb {
    background: #6b7280;
    border-radius: 3px;
    transition: background 0.2s ease;
}

.scrollbar-thin::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ENHANCED FULLSCREEN CONTROLS */
.fullscreen-controls button {
    background: rgba(0, 0, 0, 0.7) !important;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    border-radius: 0.5rem;
    color: white;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
}

.fullscreen-controls button:hover {
    background: rgba(0, 0, 0, 0.9) !important;
    transform: scale(1.05);
    border-color: rgba(255, 255, 255, 0.2);
}

.fullscreen-controls button:active {
    transform: scale(0.95);
}

.fullscreen-controls button:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* BUTTON ENHANCEMENTS */
button {
    transition: all 0.2s ease;
    cursor: pointer;
    touch-action: manipulation;
}

button:hover {
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0) scale(0.98);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.button-mobile {
    min-height: 48px;
    padding: 12px 16px;
    font-size: 1rem;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* TOUCH TARGET IMPROVEMENTS */
.touch-target {
    min-height: 44px;
    min-width: 44px;
    padding: 12px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* RESPONSIVE IFRAME IMPROVEMENTS */
.viewer-height {
    height: 60vh;
    min-height: 400px;
    transition: height 0.3s ease;
    border-radius: 0.75rem;
    overflow: hidden;
    position: relative;
}

@media (min-width: 768px) {
    .viewer-height {
        height: 70vh;
        min-height: 500px;
    }
}

@media (min-width: 1024px) {
    .viewer-height {
        height: 75vh;
        min-height: 600px;
    }
}

/* LOADING STATES */
.viewer-loading {
    pointer-events: none;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.viewer-loaded {
    pointer-events: auto;
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* ENHANCED VISUAL FEEDBACK */
.fullscreen-entering {
    animation: fullscreenEnter 0.3s ease-out;
}

.fullscreen-exiting {
    animation: fullscreenExit 0.3s ease-in;
}

@keyframes fullscreenEnter {
    from {
        transform: scale(0.95);
        opacity: 0.9;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes fullscreenExit {
    from {
        transform: scale(1);
        opacity: 1;
    }
    to {
        transform: scale(0.95);
        opacity: 0.9;
    }
}

/* MODAL ENHANCEMENTS */
#addBookmarkModal {
    backdrop-filter: blur(4px);
}

#addBookmarkModal .bg-gray-800 {
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ACTIVITY LOG ENHANCEMENTS */
#activityLog {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
}

#activityLog > div {
    padding: 0.25rem 0;
    border-left: 2px solid transparent;
    padding-left: 0.5rem;
    transition: all 0.2s ease;
}

#activityLog > div:hover {
    border-left-color: #3b82f6;
    background: rgba(59, 130, 246, 0.05);
}

/* STATS CARDS ENHANCEMENTS */
.stats-grid > div {
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.stats-grid > div:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* WELCOME MESSAGE ENHANCEMENTS */
#welcomeMessage {
    backdrop-filter: blur(2px);
    background: rgba(17, 24, 39, 0.8);
}

/* LOADING SPINNER ENHANCEMENTS */
#loadingSpinner {
    backdrop-filter: blur(4px);
}

#loadingSpinner .animate-spin {
    filter: drop-shadow(0 0 6px rgba(59, 130, 246, 0.5));
}

/* MOBILE SPECIFIC STYLES */
@media (max-width: 768px) {
    body {
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
    }
    
    .fullscreen-controls {
        opacity: 1 !important;
        background: rgba(0, 0, 0, 0.5);
        border-radius: 8px;
        padding: 4px;
    }
    
    .fullscreen-controls button {
        padding: 12px !important;
        font-size: 1.1rem !important;
        min-width: 44px;
        min-height: 44px;
    }
    
    .mobile-exit-btn button {
        min-width: 60px;
        min-height: 48px;
        font-size: 0.875rem;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }
    
    .bookmark-item {
        min-height: 100px;
        padding: 0.75rem;
    }
    
    .bookmark-name {
        font-size: 0.875rem;
    }
    
    .bookmark-url {
        font-size: 0.625rem;
    }
}

/* ACCESSIBILITY IMPROVEMENTS */
.focusable {
    cursor: pointer;
    transition: all 0.2s ease;
}

.focusable:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    transform: scale(1.02);
}

/* CHECKBOX STYLING */
input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    accent-color: #3b82f6;
    cursor: pointer;
}

/* WEBKIT FULLSCREEN API FIXES */
iframe::-webkit-media-controls-fullscreen-button {
    display: block !important;
    -webkit-appearance: media-controls-fullscreen-button;
}

iframe::-webkit-media-controls {
    width: 100% !important;
    height: 100% !important;
}

/* PERFORMANCE OPTIMIZATIONS */
.fullscreen-active,
iframe:fullscreen,
iframe:-webkit-full-screen,
iframe:-moz-full-screen,
iframe:-ms-fullscreen {
    will-change: transform;
    transform: translateZ(0);
}

/* CROSS-BROWSER COMPATIBILITY */
.fullscreen-container {
    -webkit-transform: translateZ(0);
    -moz-transform: translateZ(0);
    -ms-transform: translateZ(0);
    -o-transform: translateZ(0);
    transform: translateZ(0);
}

/* REDUCED MOTION PREFERENCES */
@media (prefers-reduced-motion: reduce) {
    .bookmark-item,
    .fullscreen-controls button,
    button,
    input,
    .viewer-height,
    .fullscreen-entering,
    .fullscreen-exiting {
        transition: none !important;
        animation: none !important;
    }
    
    .blocked-indicator {
        animation: none !important;
    }
}

/* HIGH CONTRAST MODE */
@media (prefers-contrast: high) {
    .fullscreen-controls button {
        border: 2px solid #ffffff;
        background: rgba(0, 0, 0, 0.9) !important;
    }
    
    .bookmark-item:focus,
    button:focus,
    input:focus {
        outline: 3px solid #ffffff;
        outline-offset: 2px;
    }
}

/* PRINT STYLES */
@media print {
    .fullscreen-controls,
    .mobile-exit-btn {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
    
    .viewer-height {
        height: auto !important;
        min-height: 50vh;
        border: 1px solid #000;
    }
}

/* SAFE AREA INSETS FOR MOBILE DEVICES */
@supports (padding: max(0px)) {
    .hero-section,
    .viewer-section {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
}