/* CSS Variables for Theming */
:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #16213e;
    --bg-card: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    --text-primary: #f0f0f0;
    --text-secondary: #b8b8d0;
    --text-muted: #7a7a9a;
    --accent: #e94560;
    --accent-secondary: #7c3aed;
    --accent-gradient: linear-gradient(135deg, #e94560 0%, #7c3aed 100%);
    --accent-hover: #ff6b6b;
    --border: #2d2d4a;
    --border-glow: rgba(233, 69, 96, 0.3);
    --input-bg: #0d0d1a;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --code-bg: #0a0a12;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 30px rgba(233, 69, 96, 0.15);
    --header-bg: linear-gradient(180deg, #1a1a2e 0%, #0f0f1a 100%);
}

[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-card: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-glow: rgba(233, 69, 96, 0.2);
    --input-bg: #ffffff;
    --code-bg: #f8fafc;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-glow: 0 0 30px rgba(233, 69, 96, 0.1);
    --header-bg: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

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

/* Layout */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    background: var(--header-bg);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    text-decoration: none;
}

.logo-icon {
    font-size: 1.75rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-section {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.site-tagline {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0;
    font-weight: 400;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Theme Toggle */
.theme-toggle {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 2rem;
    padding: 0.5rem 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

/* Navigation */
.nav-tabs {
    display: flex;
    gap: 0.35rem;
    overflow-x: auto;
    padding: 0.25rem 0 0.5rem 0;
    scrollbar-width: thin;
}

.nav-tabs::-webkit-scrollbar {
    height: 4px;
}

.nav-tabs::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 2px;
}

.nav-tab {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    padding: 0.5rem 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

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

.nav-tab.active {
    background: var(--accent-gradient);
    border-color: transparent;
    color: white;
    box-shadow: 0 2px 10px rgba(233, 69, 96, 0.3);
}

/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    gap: 2rem;
    padding: 2rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

/* Tool Panel */
.tool-area {
    flex: 1;
    min-width: 0;
}

.tool-panel {
    display: none;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.tool-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent-gradient);
}

.tool-panel.active {
    display: block;
}

.tool-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.tool-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tool-description {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.7;
}

/* Sidebar */
.sidebar {
    width: 300px;
    flex-shrink: 0;
}

.ad-placeholder {
    min-height: 250px;
    width: 300px;
    position: sticky;
    top: 200px;
}

/* Form Elements */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--input-bg);
    border: 2px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.3s ease;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--border-glow);
}

.form-textarea {
    min-height: 150px;
    resize: vertical;
    font-family: 'JetBrains Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
}

.form-textarea.json-input {
    min-height: 300px;
}

.form-input-group {
    display: flex;
    gap: 0.5rem;
}

.form-input-group .form-input {
    flex: 1;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(233, 69, 96, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(233, 69, 96, 0.4);
}

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

.btn-secondary:hover {
    border-color: var(--accent);
    background: var(--bg-secondary);
    transform: translateY(-2px);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.btn-group {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Code Output */
.output-area {
    background: var(--code-bg);
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem;
    font-family: 'JetBrains Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.9rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    min-height: 100px;
    max-height: 400px;
    overflow-y: auto;
}

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

.output-label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

/* Status Messages */
.status {
    padding: 1rem 1.25rem;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    margin-top: 1rem;
}

.status-success {
    background: rgba(16, 185, 129, 0.15);
    border: 2px solid var(--success);
    color: var(--success);
}

.status-error {
    background: rgba(239, 68, 68, 0.15);
    border: 2px solid var(--error);
    color: var(--error);
}

.status-warning {
    background: rgba(245, 158, 11, 0.15);
    border: 2px solid var(--warning);
    color: var(--warning);
}

/* Grid Layout for Tools */
.tool-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.tool-grid-full {
    grid-column: 1 / -1;
}

/* Color Swatch */
.color-swatch {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    border: 2px solid var(--border);
}

.color-palette {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.palette-color {
    width: 65px;
    height: 65px;
    border-radius: 10px;
    border: 2px solid var(--border);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    box-shadow: var(--shadow);
}

.palette-color:hover {
    transform: scale(1.1) translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

/* Gradient Preview */
.gradient-preview {
    height: 180px;
    border-radius: 12px;
    border: 2px solid var(--border);
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

/* Regex Matches */
.regex-highlight {
    background: linear-gradient(135deg, rgba(233, 69, 96, 0.4) 0%, rgba(124, 58, 237, 0.4) 100%);
    border-radius: 3px;
    padding: 1px 4px;
}

.match-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.match-item {
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
    font-family: monospace;
    font-size: 0.9rem;
    border-left: 3px solid var(--accent);
}

.match-index {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* JWT Sections */
.jwt-section {
    margin-bottom: 1.25rem;
    border-radius: 10px;
    overflow: hidden;
}

.jwt-header {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(239, 68, 68, 0.05) 100%);
    border-left: 4px solid #ef4444;
}

.jwt-payload {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(16, 185, 129, 0.05) 100%);
    border-left: 4px solid #10b981;
}

.jwt-signature {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(59, 130, 246, 0.05) 100%);
    border-left: 4px solid #3b82f6;
}

.jwt-section .output-area {
    padding-left: 1.25rem;
    border: none;
    border-radius: 0;
}

/* Favicon Preview */
.favicon-preview {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin: 1rem 0;
}

.favicon-size {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem;
    background: var(--bg-tertiary);
    border-radius: 12px;
    border: 2px solid var(--border);
    transition: all 0.3s ease;
}

.favicon-size:hover {
    border-color: var(--accent);
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.favicon-size img {
    image-rendering: pixelated;
}

/* Image Converter Preview */
.image-preview-box {
    background: var(--bg-tertiary);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: all 0.3s ease;
}

.image-preview-box:hover {
    border-color: var(--accent);
}

.image-preview-box img {
    max-width: 100%;
    max-height: 200px;
    object-fit: contain;
    border-radius: 8px;
}

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

.favicon-size-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* Drag & Drop Area */
.drop-zone {
    border: 3px dashed var(--border);
    border-radius: 16px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--accent);
    background: linear-gradient(135deg, rgba(233, 69, 96, 0.1) 0%, rgba(124, 58, 237, 0.1) 100%);
    transform: scale(1.01);
}

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

.drop-zone-text strong {
    color: var(--accent);
    font-weight: 700;
}

/* Checkbox & Radio */
.checkbox-group {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
}

.checkbox-label input {
    accent-color: var(--accent);
    width: 18px;
    height: 18px;
}

/* Tabs within tools */
.tool-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.tool-tab {
    padding: 0.6rem 1.25rem;
    background: var(--bg-tertiary);
    border: 2px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.tool-tab:hover {
    border-color: var(--accent);
}

.tool-tab.active {
    background: var(--input-bg);
    border-color: var(--accent);
    color: var(--text-primary);
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    z-index: 1000;
    animation: slideIn 0.3s ease;
    font-weight: 500;
}

.toast-success {
    border-color: var(--success);
    background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(16, 185, 129, 0.1) 100%);
}

.toast-error {
    border-color: var(--error);
    background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(239, 68, 68, 0.1) 100%);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Footer */
.footer {
    background: var(--header-bg);
    border-top: 1px solid var(--border);
    padding: 1.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.footer a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

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

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        display: none;
    }

    .tool-grid {
        grid-template-columns: 1fr;
    }

}

@media (max-width: 768px) {
    .header-top {
        flex-direction: column;
        gap: 1rem;
    }

    .main-content {
        padding: 1rem;
    }

    .tool-panel {
        padding: 1.25rem;
        border-radius: 12px;
    }

    .nav-tabs {
        justify-content: flex-start;
    }

    .btn-group {
        flex-direction: column;
    }

    .btn-group .btn {
        width: 100%;
    }
}

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

.text-center {
    text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* Range Slider */
.range-slider {
    width: 100%;
    accent-color: var(--accent);
    height: 8px;
}

.range-value {
    display: inline-block;
    min-width: 3rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
}

/* Inline flex helpers */
.flex {
    display: flex;
}

.flex-wrap {
    flex-wrap: wrap;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

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

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

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

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

/* Selection */
::selection {
    background: var(--accent);
    color: white;
}
