/* CSS Variables for theming */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-tertiary: #e8e8e8;
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --text-muted: #999999;
    --border-color: #dddddd;
    --accent-color: #2563eb;
    --accent-hover: #1d4ed8;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --radius-sm: 4px;
}

[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #3d3d3d;
    --text-primary: #f0f0f0;
    --text-secondary: #b0b0b0;
    --text-muted: #808080;
    --border-color: #404040;
    --accent-color: #3b82f6;
    --accent-hover: #60a5fa;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
}

.header-content {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 10px;
}

h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Theme Toggle */
.theme-toggle {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    background: var(--accent-color);
    color: white;
}

.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: inline; }

/* Tabs */
.tabs {
    display: flex;
    gap: 5px;
    background: var(--bg-primary);
    padding: 5px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    overflow-x: auto;
}

.tab {
    padding: 12px 24px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    white-space: nowrap;
}

.tab:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.tab.active {
    background: var(--accent-color);
    color: white;
}

/* Tab Content */
.tab-content {
    display: none;
    background: var(--bg-primary);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

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

/* Options Bar */
.options-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
}

.option-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.option-group label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 5px;
}

.option-group select,
.option-group input[type="text"] {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.option-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Editor Container */
.editor-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 768px) {
    .editor-container {
        grid-template-columns: 1fr;
    }
}

/* Editor Panel */
.editor-panel {
    display: flex;
    flex-direction: column;
}

.editor-panel.full-width {
    width: 100%;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    border: 1px solid var(--border-color);
    border-bottom: none;
}

.panel-header span {
    font-weight: 600;
    color: var(--text-primary);
}

.panel-stats {
    display: flex;
    gap: 15px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.editor-panel textarea {
    width: 100%;
    min-height: 250px;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 0;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    resize: vertical;
    line-height: 1.5;
}

.editor-panel textarea:focus {
    outline: none;
    border-color: var(--accent-color);
}

.panel-actions {
    display: flex;
    gap: 10px;
    padding: 10px 15px;
    background: var(--bg-secondary);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    border: 1px solid var(--border-color);
    border-top: none;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--accent-color);
    color: white;
}

.btn:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-success {
    background: var(--success-color);
}

.btn-success:hover {
    background: #0d9669;
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 50px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--bg-secondary);
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--accent-color);
    background: rgba(37, 99, 235, 0.05);
}

.drop-zone-content {
    pointer-events: none;
}

.drop-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 15px;
}

.drop-zone p {
    color: var(--text-secondary);
    margin: 5px 0;
}

.drop-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* File Results */
.file-results {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.file-result-item {
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 15px;
    border: 1px solid var(--border-color);
}

.file-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.file-name {
    font-weight: 600;
    color: var(--text-primary);
    word-break: break-all;
}

.file-size {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.file-preview-thumb {
    max-width: 200px;
    max-height: 150px;
    border-radius: var(--radius-sm);
    margin: 10px 0;
}

.file-result-output {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px;
    font-family: monospace;
    font-size: 0.8rem;
    word-break: break-all;
    max-height: 100px;
    overflow-y: auto;
    color: var(--text-secondary);
}

.file-result-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}

/* File Preview */
.file-preview {
    margin-top: 20px;
    text-align: center;
}

.file-preview img {
    max-width: 100%;
    max-height: 400px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.preview-info {
    margin-top: 15px;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

.preview-info p {
    margin: 5px 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.preview-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

/* Hex View */
.hex-view-container {
    margin-top: 20px;
}

.hex-view {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 15px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.8rem;
    overflow-x: auto;
    max-height: 300px;
    overflow-y: auto;
    color: var(--text-secondary);
    line-height: 1.8;
}

.hex-offset {
    color: var(--accent-color);
}

.hex-bytes {
    color: var(--text-primary);
}

.hex-ascii {
    color: var(--success-color);
}

/* History */
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.history-header h2 {
    font-size: 1.2rem;
    color: var(--text-primary);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.history-item-info {
    flex: 1;
    min-width: 0;
}

.history-item-type {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--accent-color);
    font-weight: 600;
    margin-bottom: 5px;
}

.history-item-preview {
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 5px;
}

.history-item-actions {
    display: flex;
    gap: 8px;
    margin-left: 15px;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

/* Error Message */
.error-message {
    margin-top: 15px;
    padding: 12px 15px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error-color);
    border-radius: var(--radius-sm);
    color: var(--error-color);
    font-size: 0.9rem;
    display: none;
}

.error-message.visible {
    display: block;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius);
    max-width: 450px;
    width: 90%;
    box-shadow: var(--shadow);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.copy-options {
    padding: 10px;
}

.copy-option {
    display: block;
    width: 100%;
    padding: 12px 15px;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.2s ease;
}

.copy-option:hover {
    background: var(--bg-secondary);
}

.option-title {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 3px;
}

.option-desc {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: monospace;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-primary);
    color: var(--bg-primary);
    padding: 12px 24px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1001;
}

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

/* Utility */
.hidden {
    display: none !important;
}

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

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

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

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

/* Focus styles */
*:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

button:focus-visible {
    outline-offset: 0;
}

/* Accessibility - Skip Link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--accent-color);
    color: white;
    padding: 8px 16px;
    z-index: 1002;
    text-decoration: none;
    border-radius: 0 0 var(--radius-sm) 0;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 0;
}

/* Visually Hidden (for screen readers) */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Panel Label */
.panel-label {
    font-weight: 600;
    color: var(--text-primary);
}

/* SEO Content Section */
.seo-content {
    margin-top: 40px;
    padding: 30px;
    background: var(--bg-primary);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.seo-content h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--accent-color);
}

.seo-content h3 {
    font-size: 1.15rem;
    color: var(--text-primary);
    margin-top: 25px;
    margin-bottom: 12px;
}

.seo-content p {
    color: var(--text-secondary);
    margin-bottom: 15px;
    line-height: 1.7;
}

.seo-content ul {
    margin-left: 20px;
    margin-bottom: 15px;
}

.seo-content li {
    color: var(--text-secondary);
    margin-bottom: 8px;
    line-height: 1.6;
}

.seo-content dl {
    margin-top: 15px;
}

.seo-content dt {
    color: var(--text-primary);
    margin-top: 15px;
    margin-bottom: 5px;
}

.seo-content dd {
    color: var(--text-secondary);
    margin-left: 20px;
    padding-left: 15px;
    border-left: 3px solid var(--border-color);
}

/* FAQ Section */
.faq-section {
    margin-top: 30px;
    padding: 30px;
    background: var(--bg-primary);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.faq-section h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--accent-color);
}

.faq-item {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    overflow: hidden;
}

.faq-item summary {
    padding: 15px 20px;
    cursor: pointer;
    background: var(--bg-secondary);
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.faq-item summary::-webkit-details-marker {
    display: none;
}

.faq-item summary::after {
    content: '+';
    font-size: 1.3rem;
    font-weight: 300;
    color: var(--accent-color);
    transition: transform 0.2s ease;
}

.faq-item[open] summary::after {
    content: '-';
}

.faq-item summary h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.faq-item summary:hover {
    background: var(--bg-tertiary);
}

.faq-item p {
    padding: 15px 20px;
    color: var(--text-secondary);
    line-height: 1.7;
    margin: 0;
    background: var(--bg-primary);
}

.faq-item code {
    background: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
    color: var(--accent-color);
}

/* Advertisement Container */
.ad-container {
    margin: 30px 0;
    min-height: 100px;
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
}

.ad-container ins {
    max-width: 100%;
}

/* Footer */
footer {
    margin-top: 40px;
    padding: 25px;
    text-align: center;
    border-top: 1px solid var(--border-color);
}

footer p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 10px;
}

footer a {
    color: var(--accent-color);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

.footer-links {
    font-size: 0.85rem;
}

.footer-links a {
    color: var(--text-secondary);
}

/* CLS Prevention - Reserve space for dynamic content */
.editor-panel textarea {
    min-height: 250px;
    height: 250px;
}

.drop-zone {
    min-height: 200px;
}

/* Print styles */
@media print {
    .tabs,
    .theme-toggle,
    .panel-actions,
    .toast,
    .modal,
    .skip-link,
    .ad-container {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    .tab-content {
        display: block !important;
        page-break-inside: avoid;
    }
}
