/* Hex to Text Converter - Modern CSS Styles */

/* Custom Properties */
:root {
    --primary-emerald: #10b981;
    --primary-emerald-50: #ecfdf5;
    --primary-emerald-100: #d1fae5;
    --primary-emerald-500: #10b981;
    --primary-emerald-600: #059669;
    --primary-emerald-700: #047857;
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --accent-orange: #f97316;
    --accent-pink: #ec4899;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --surface-primary: #ffffff;
    --surface-secondary: #f9fafb;
    --border-light: #e5e7eb;
    --border-medium: #d1d5db;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    --radius-3xl: 1.875rem;
}

/* Enhanced Base Styles */
.hex-converter-container {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
}

/* Smooth Scrolling */
html {
    scroll-behavior: smooth;
}

/* Enhanced Button Animations */
.mode-btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateZ(0);
}

.mode-btn::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s ease;
}

.mode-btn:hover::before {
    left: 100%;
}

.mode-btn.active {
    background: linear-gradient(135deg, var(--primary-emerald-500), var(--primary-emerald-600));
    color: white;
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.mode-btn:not(.active):hover {
    background: var(--surface-secondary) !important;
    color: var(--text-primary) !important;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* Specific hover fixes for mode buttons to ensure light theme */
.mode-btn:hover {
    background: #f3f4f6 !important;
    color: #374151 !important;
}

.mode-btn.active:hover {
    background: linear-gradient(135deg, var(--primary-emerald-500), var(--primary-emerald-600)) !important;
    color: white !important;
}

/* Override Tailwind hover classes that might cause dark backgrounds */
#hexToTextBtn:hover,
#textToHexBtn:hover,
#autoDetectBtn:hover {
    background: #f3f4f6 !important;
    color: #374151 !important;
}

#hexToTextBtn.active:hover {
    background: #10b981 !important;
    color: white !important;
}

#textToHexBtn.active:hover {
    background: #10b981 !important;
    color: white !important;
}

#autoDetectBtn.active:hover {
    background: #10b981 !important;
    color: white !important;
}

/* Force light theme for all elements */
.hex-converter-container * {
    color-scheme: light !important;
}

/* Ensure no dark backgrounds anywhere in the converter */
.hex-converter-container *:focus,
.hex-converter-container *:hover {
    background-color: var(--surface-primary, #ffffff) !important;
}

.hex-converter-container textarea:focus {
    background-color: #f9fafb !important;
}

.hex-converter-container .mode-btn:hover {
    background-color: #f3f4f6 !important;
}

.hex-converter-container .mode-btn.active,
.hex-converter-container .mode-btn.active:hover {
    background: #10b981 !important;
    color: white !important;
}

/* Advanced Loading Animation */
#loadingIndicator {
    backdrop-filter: blur(4px);
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#loadingIndicator.show {
    display: flex !important;
    opacity: 1;
    visibility: visible;
}

/* Enhanced Spinner Animation */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Pulse Animation for Processing */
@keyframes pulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Enhanced File Upload Styles */
#fileUploadOverlay {
    backdrop-filter: blur(2px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#fileUploadOverlay.drag-over {
    opacity: 1 !important;
    transform: scale(1.02);
    border-color: var(--primary-emerald-500);
    background: var(--primary-emerald-50);
}

/* Textarea Enhancements */
textarea {
    transition: all 0.2s ease;
    line-height: 1.5;
    font-family: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New", monospace;
}

textarea:focus {
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
    border-color: var(--primary-emerald-500);
    background: var(--surface-primary) !important;
    outline: none !important;
}

/* Specific fix for outputText to prevent black background */
#outputText:focus {
    background: #f9fafb !important;
    border-color: #10b981 !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1) !important;
}

textarea::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

/* Enhanced Quick Action Buttons */
.quick-action {
    position: relative;
    background: linear-gradient(135deg, var(--surface-primary), var(--surface-secondary));
    border: 2px solid transparent;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
}

.quick-action::before {
    content: "";
    position: absolute;
    inset: 0;
    padding: 2px;
    background: linear-gradient(135deg, var(--primary-emerald-500), var(--accent-blue));
    border-radius: inherit;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.quick-action:hover::before {
    opacity: 1;
}

.quick-action:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: var(--shadow-lg);
}

/* Status Indicators */
.status-success {
    color: var(--primary-emerald-600);
    animation: fadeInUp 0.5s ease;
}

.status-error {
    color: #ef4444;
    animation: shake 0.5s ease;
}

.status-warning {
    color: var(--accent-orange);
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shake {
    0%,
    100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-4px);
    }
    75% {
        transform: translateX(4px);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Advanced Panel Transitions */
.panel-transition {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: top;
}

.panel-hidden {
    opacity: 0;
    transform: scaleY(0) translateY(-20px);
    max-height: 0;
    overflow: hidden;
}

.panel-visible {
    opacity: 1;
    transform: scaleY(1) translateY(0);
    max-height: 500px;
}

/* Enhanced Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #cbd5e1;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background: white;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
}

input:checked + .toggle-slider {
    background: var(--primary-emerald-500);
}

input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

input:focus + .toggle-slider {
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

/* Enhanced Select Styles */
select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
    appearance: none;
    transition: all 0.2s ease;
}

select:focus {
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
    border-color: var(--primary-emerald-500);
}

/* Copy Success Animation */
@keyframes copySuccess {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
        background-color: var(--primary-emerald-100);
    }
    100% {
        transform: scale(1);
    }
}

.copy-success {
    animation: copySuccess 0.3s ease;
}

/* Analysis Panel Styles */
.analysis-card {
    background: linear-gradient(135deg, var(--surface-primary), var(--surface-secondary));
    border: 1px solid var(--border-light);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.analysis-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-emerald-500), var(--accent-blue));
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.analysis-card:hover::before {
    transform: scaleX(1);
}

.analysis-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Responsive Enhancements */
@media (max-width: 768px) {
    .mode-btn {
        font-size: 0.75rem;
        padding: 0.5rem 0.75rem;
    }

    .quick-action {
        padding: 0.75rem;
    }

    textarea {
        font-size: 0.875rem;
    }

    .analysis-card {
        padding: 1rem;
    }
}

@media (max-width: 640px) {
    .grid-responsive {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .mode-btn {
        flex: 1;
        min-width: 0;
    }
}

/* Dark Mode Support (if needed) */
@media (prefers-color-scheme: dark) {
    :root {
        --text-primary: #f9fafb;
        --text-secondary: #d1d5db;
        --surface-primary: #1f2937;
        --surface-secondary: #111827;
        --border-light: #374151;
        --border-medium: #4b5563;
    }
}

/* High Performance Animations */
.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000;
}

/* Smooth Transitions for Interactive Elements */
button,
input,
select,
textarea {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Enhanced Focus States for Accessibility */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--primary-emerald-500);
    outline-offset: 2px;
}

/* Performance Optimizations */
* {
    box-sizing: border-box;
}

.will-change-auto {
    will-change: auto;
}

.will-change-transform {
    will-change: transform;
}

/* Print Styles */
@media print {
    .no-print {
        display: none !important;
    }

    .print-break-inside-avoid {
        break-inside: avoid;
    }
}

/* Advanced Grid Layouts */
.grid-auto-fit {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.grid-auto-fill {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

/* Utility Classes */
.backdrop-blur-sm {
    backdrop-filter: blur(4px);
}

.text-gradient {
    background: linear-gradient(135deg, var(--primary-emerald-600), var(--accent-blue));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.border-gradient {
    border: 2px solid transparent;
    background: linear-gradient(white, white) padding-box, linear-gradient(135deg, var(--primary-emerald-500), var(--accent-blue)) border-box;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--surface-secondary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 4px;
    transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-emerald-500);
}

/* Firefox Scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-medium) var(--surface-secondary);
}

/* Micro-interactions */
.micro-bounce:hover {
    animation: microBounce 0.4s ease;
}

@keyframes microBounce {
    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-4px);
    }
    60% {
        transform: translateY(-2px);
    }
}

/* Performance Monitoring Classes */
.perf-monitor {
    opacity: 0.7;
    font-size: 0.75rem;
    font-family: monospace;
    color: var(--text-secondary);
}

/* Accessibility Enhancements */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
