/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f7fa;
    min-height: 100vh;
    color: #2c3e50;
    line-height: 1.6;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem;
}

/* Accessibility */
.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;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: #1a202c;
    margin-bottom: 0.5rem;
    letter-spacing: -0.025em;
}

header p {
    font-size: 1.1rem;
    color: #64748b;
    font-weight: 500;
}

/* Main content */
main {
    margin-bottom: 2rem;
}

.converter-panel {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

/* Controls Section */
.controls-section {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: center;
    gap: 3rem;
    flex-wrap: wrap;
}

.dark-mode-toggle {
    display: flex;
    align-items: center;
}

.twos-complement-toggle {
    display: flex;
    align-items: center;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
}

.toggle-switch {
    position: relative;
    width: 60px;
    height: 30px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #cbd5e0;
    transition: 0.3s;
    border-radius: 30px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .slider {
    background: #76b900;
}

input:checked + .slider:before {
    transform: translateX(30px);
}

/* Copy URL Button */
.copy-url-section {
    display: flex;
    align-items: center;
}

.copy-url-button {
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.copy-url-button:hover {
    background: #76b900;
    border-color: #76b900;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(118, 185, 0, 0.2);
}

.copy-url-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(118, 185, 0, 0.2);
}

.copy-url-button.copied {
    background: #10b981;
    border-color: #10b981;
    color: white;
}

/* Input Section */
.input-section {
    padding: 2.5rem 3rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.input-group {
    display: flex;
    flex-direction: column;
}

.input-group label {
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.input-group input {
    padding: 1rem 1.25rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1.1rem;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', monospace;
    transition: all 0.2s ease;
    background: #fafafa;
    width: 100%;
}

.input-group input:focus {
    outline: none;
    border-color: #76b900;
    background: white;
    box-shadow: 0 0 0 3px rgba(118, 185, 0, 0.1);
}

.input-group input::placeholder {
    color: #9ca3af;
}

.input-group input.error {
    border-color: #ef4444;
    background: #fef2f2;
}

.input-group input.error:focus {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Visualization Section */
.visualization-section {
    border-top: 1px solid #e2e8f0;
    padding: 2rem;
}

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

.viz-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1a202c;
}

.bit-info {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.bit-count, .max-value {
    font-size: 0.875rem;
    color: #64748b;
    font-weight: 500;
}

.bit-count {
    padding: 0.25rem 0.75rem;
    background: rgba(118, 185, 0, 0.1);
    color: #5a7c00;
    border-radius: 6px;
}

/* Bit display */
.bit-display {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 4rem;
    padding: 1.5rem 1.5rem 2.5rem 1.5rem;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    justify-content: flex-start;
}

.bit-group {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
    position: relative;
    margin-bottom: 20px;
}

.bit-group-subscript {
    position: absolute;
    bottom: -18px;
    right: 0;
    font-size: 0.7rem;
    color: #64748b;
    font-weight: 500;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', monospace;
}

.bit-display .bit {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', monospace;
}

.bit-display .bit.zero {
    background: #f1f5f9 !important;
    color: #64748b !important;
    border: 1px solid #cbd5e0 !important;
}

.bit-display .bit.one {
    background: #76b900 !important;
    color: #ffffff !important;
    border: 1px solid #5a7c00 !important;
}

.bit-display .bit:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.bit-display .bit.zero:hover {
    background: #e2e8f0 !important;
}

.bit-display .bit.one:hover {
    background: #5a7c00 !important;
}

/* Hex section */
.hex-section {
    margin-top: 2rem;
}

.hex-section h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1a202c;
    margin-bottom: 1rem;
}

.hex-display {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 1.5rem 1.5rem 2.5rem 1.5rem;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    justify-content: flex-start;
}

.hex-group {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    position: relative;
    margin-bottom: 20px;
}

.hex-group-subscript {
    position: absolute;
    bottom: -18px;
    right: 0;
    font-size: 0.7rem;
    color: #64748b;
    font-weight: 500;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', monospace;
}

/* Hex character styling - Simple zero/nonzero system */
.hex-char {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1.125rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', monospace;
}

.hex-char.zero {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #cbd5e0;
}

.hex-char.nonzero {
    background: #76b900;
    color: #ffffff;
    border: 1px solid #5a7c00;
}

.hex-char:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.hex-char.zero:hover {
    background: #e2e8f0;
}

.hex-char.nonzero:hover {
    background: #5a7c00;
}

/* Empty state styling */
.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 60px;
    color: #9ca3af;
    font-style: italic;
    font-size: 0.875rem;
    text-align: center;
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: rgba(0,0,0,0.92);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 1000;
    white-space: nowrap;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', monospace;
}

.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(0,0,0,0.92);
}

.tooltip.show {
    opacity: 1;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .controls-section {
        justify-content: center;
        gap: 1.5rem;
        padding: 1rem 1.5rem;
    }
    
    .input-section {
        padding: 1.5rem;
    }
    
    .input-group input {
        font-size: 1rem;
        padding: 0.875rem 1rem;
    }
    
    .visualization-section {
        padding: 1.5rem;
    }
    
    .bit-display {
        justify-content: center;
        gap: 6px;
        padding: 1rem;
        margin-bottom: 2.5rem;
    }
    
    .bit-group {
        gap: 1px;
    }
    
    .bit-group-subscript,
    .hex-group-subscript {
        font-size: 0.65rem;
        bottom: -16px;
    }
    
    .bit-display .bit {
        width: 24px;
        height: 24px;
        font-size: 0.75rem;
    }
    
    .hex-display {
        justify-content: center;
        gap: 6px;
        padding: 1rem;
        margin-bottom: 2.5rem;
    }
    
    .hex-group {
        gap: 2px;
    }
    
    .hex-char {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
    
    .viz-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .bit-info {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0.5rem;
    }
    
    .input-section {
        padding: 1rem;
    }
    
    .input-group input {
        font-size: 0.9rem;
        padding: 0.75rem 0.875rem;
    }
    
    .visualization-section {
        padding: 1rem;
    }
    
    .controls-section {
        padding: 0.75rem 1rem;
    }
}

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

/* Dark mode support */
.dark-mode {
    background: #1a1a1a;
    color: #f1f5f9;
}

.dark-mode header h1 {
    color: #f1f5f9;
}

.dark-mode header p {
    color: #cbd5e0;
}

.dark-mode .converter-panel {
    background: #2a2a2a;
    border-color: #404040;
}

.dark-mode .controls-section {
    background: #404040;
    border-color: #555555;
}

.dark-mode .toggle-label {
    color: #e2e8f0;
}

.dark-mode .copy-url-button {
    background: #374151;
    border-color: #555555;
    color: #e2e8f0;
}

.dark-mode .copy-url-button:hover {
    background: #76b900;
    border-color: #76b900;
    color: white;
}

.dark-mode .copy-url-button.copied {
    background: #10b981;
    border-color: #10b981;
    color: white;
}

.dark-mode .input-group label {
    color: #f1f5f9;
}

.dark-mode .input-group input {
    background: #404040;
    border-color: #555555;
    color: #f1f5f9;
}

.dark-mode .input-group input:focus {
    border-color: #76b900;
    background: #555555;
}

.dark-mode .input-group input::placeholder {
    color: #94a3b8;
}

.dark-mode .input-group input.error {
    border-color: #ef4444;
    background: #450a0a;
}

.dark-mode .input-group input.error:focus {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.dark-mode .viz-header h2, .dark-mode .hex-section h3 {
    color: #f1f5f9;
}

.dark-mode .bit-count, .dark-mode .max-value {
    color: #cbd5e0;
}

.dark-mode .bit-display, .dark-mode .hex-display {
    background: #404040;
    border-color: #555555;
}

.dark-mode .bit-group {
    /* Inherits gap and layout from parent */
}

.dark-mode .bit-display .bit.zero {
    background: #555555 !important;
    color: #cbd5e0 !important;
    border-color: #666666 !important;
}

.dark-mode .bit-display .bit.one {
    background: #76b900 !important;
    color: #ffffff !important;
    border-color: #5a7c00 !important;
}

.dark-mode .bit-display .bit.zero:hover {
    background: #666666 !important;
}

.dark-mode .bit-display .bit.one:hover {
    background: #5a7c00 !important;
}

.dark-mode .hex-display {
    background: #404040;
    border-color: #555555;
}

.dark-mode .hex-group {
    /* Inherits gap and layout from parent */
}

.dark-mode .bit-group-subscript,
.dark-mode .hex-group-subscript {
    color: #9ca3af;
}

.dark-mode .hex-char {
    background: #555555;
    color: #cbd5e0;
    border-color: #666666;
}

.dark-mode .hex-char.zero {
    background: #555555;
    color: #cbd5e0;
    border-color: #666666;
}

.dark-mode .hex-char.nonzero {
    background: #76b900;
    color: #ffffff;
    border-color: #5a7c00;
}

.dark-mode .hex-char:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.dark-mode .hex-char.zero:hover {
    background: #666666;
}

.dark-mode .hex-char.nonzero:hover {
    background: #5a7c00;
}

/* Dark mode empty state styling */
.dark-mode .empty-state {
    color: #6b7280;
}

/* About Section */
.about-section {
    margin-top: 2rem;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

.about-content {
    padding: 2rem;
    text-align: left;
}

.about-content h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a202c;
    margin-bottom: 1.5rem;
    letter-spacing: -0.025em;
}

.about-info {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: flex-start;
}

.about-info p {
    font-size: 1rem;
    color: #64748b;
    margin: 0;
}

.about-info strong {
    color: #374151;
    font-weight: 600;
}

.about-info a {
    color: #76b900;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.about-info a:hover {
    color: #5a7c00;
    text-decoration: underline;
}

.about-info a:focus {
    outline: 2px solid #76b900;
    outline-offset: 2px;
    border-radius: 4px;
}

/* Dark mode for about section */
.dark-mode .about-section {
    background: #2a2a2a;
    border-color: #404040;
}

.dark-mode .about-content h2 {
    color: #f1f5f9;
}

.dark-mode .about-info p {
    color: #cbd5e0;
}

.dark-mode .about-info strong {
    color: #e2e8f0;
}

.dark-mode .about-info a {
    color: #76b900;
}

.dark-mode .about-info a:hover {
    color: #9fcd3a;
}

/* Responsive design for about section */
@media (max-width: 768px) {
    .about-content {
        padding: 1.5rem;
    }
    
    .about-content h2 {
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }
    
    .about-info {
        gap: 0.5rem;
    }
    
    .about-info p {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .about-content {
        padding: 1rem;
    }
}

/* Media query for system preference (fallback) */
@media (prefers-color-scheme: dark) {
    body:not(.dark-mode) {
        /* Apply dark mode styles if no explicit class is set */
    }
} 