/* CSS Variables */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #8b5cf6;
    --background-color: #0f172a;
    --surface-color: #1e293b;
    --surface-hover: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --gradient-1: linear-gradient(135deg, #6366f1, #8b5cf6);
    --gradient-2: linear-gradient(135deg, #06b6d4, #3b82f6);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.2);
    --radius: 12px;
    --radius-sm: 8px;
}

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

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

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

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

/* Header */
header {
    text-align: center;
    padding: 2rem 1rem;
    background: linear-gradient(180deg, var(--surface-color) 0%, transparent 100%);
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.logo {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

/* Main Content */
main {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem 2rem;
    width: 100%;
}

/* Upload Section */
.upload-section {
    margin-bottom: 2rem;
}

.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    text-align: center;
    background: var(--surface-color);
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
}

.upload-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.upload-area h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.upload-area p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.upload-btn {
    background: var(--gradient-1);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

/* Tabs */
.tabs-section {
    margin-bottom: 1.5rem;
}

.tabs {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--surface-color);
    border-radius: var(--radius);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab {
    flex: 1;
    min-width: fit-content;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    white-space: nowrap;
}

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

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

/* Content Sections */
.content-section {
    background: var(--surface-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

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

.section-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.control-btn {
    background: var(--surface-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

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

/* Canvas Container */
.canvas-container {
    background: var(--background-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
}

.canvas-container canvas {
    width: 100%;
    height: 200px;
    display: block;
}

/* Waveform specific */
.waveform-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.progress-bar {
    flex: 1;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
    cursor: pointer;
}

.progress {
    height: 100%;
    width: 0%;
    background: var(--gradient-1);
    transition: width 0.1s linear;
}

/* Spectrogram specific */
.legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.color-bar {
    width: 200px;
    height: 16px;
    border-radius: 4px;
    background: linear-gradient(to right, #440154, #414487, #2a788e, #22a884, #7ad151, #fde725);
}

/* Fingerprint specific */
.fingerprint-container {
    text-align: center;
}

.fingerprint-container canvas {
    max-width: 400px;
    margin: 0 auto;
    border-radius: var(--radius-sm);
    background: var(--background-color);
}

.fingerprint-hash {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--background-color);
    border-radius: var(--radius-sm);
}

.fingerprint-hash label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.fingerprint-hash code {
    display: block;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.75rem;
    color: var(--secondary-color);
    word-break: break-all;
    padding: 0.5rem;
    background: var(--surface-color);
    border-radius: var(--radius-sm);
}

/* Analysis Grid */
.analysis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.analysis-card {
    background: var(--background-color);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
}

.analysis-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.analysis-data {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.data-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
}

.data-row span:first-child {
    color: var(--text-secondary);
}

.data-row span:last-child {
    font-weight: 500;
    color: var(--text-primary);
}

/* Comparison Section */
.comparison-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.comparison-files {
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.comparison-file {
    flex: 1;
    min-width: 200px;
    max-width: 300px;
    text-align: center;
}

.comparison-file h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
}

.file-preview,
.file-drop {
    background: var(--background-color);
    border-radius: var(--radius-sm);
    padding: 1rem;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.file-drop {
    border: 2px dashed var(--border-color);
    cursor: pointer;
    transition: all 0.3s ease;
}

.file-drop:hover {
    border-color: var(--primary-color);
}

.comparison-file canvas {
    display: block;
    margin: 1rem auto 0;
    border-radius: var(--radius-sm);
    background: var(--background-color);
}

.comparison-vs {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-secondary);
    padding: 1rem;
}

.comparison-result {
    background: var(--background-color);
    border-radius: var(--radius-sm);
    padding: 1.5rem;
    text-align: center;
}

.comparison-result h3 {
    margin-bottom: 1.5rem;
}

.similarity-meter {
    position: relative;
    height: 40px;
    background: var(--surface-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.meter-fill {
    height: 100%;
    width: 0%;
    background: var(--gradient-1);
    transition: width 0.5s ease;
}

.meter-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.comparison-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
    text-align: left;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem;
    background: var(--surface-color);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
}

/* Select Inputs */
select {
    background: var(--surface-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Range Input */
input[type="range"] {
    width: 80px;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}

/* Loading */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 1000;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 1rem;
    background: var(--surface-color);
    border-top: 1px solid var(--border-color);
}

footer p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

footer a:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.5rem;
    }

    .logo {
        width: 36px;
        height: 36px;
    }

    .upload-area {
        padding: 2rem 1rem;
    }

    .upload-icon {
        font-size: 3rem;
    }

    .tabs {
        padding: 0.25rem;
    }

    .tab {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }

    .content-section {
        padding: 1rem;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .controls {
        width: 100%;
        justify-content: flex-start;
    }

    .canvas-container canvas {
        height: 150px;
    }

    .comparison-files {
        flex-direction: column;
    }

    .comparison-vs {
        transform: rotate(90deg);
    }

    .comparison-file {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .upload-area h2 {
        font-size: 1.25rem;
    }

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

    .fingerprint-hash code {
        font-size: 0.625rem;
    }
}

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

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

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

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

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