@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

/* Theme Variables */
:root {
    /* Light Theme */
    --primary-color-light: #2563eb;
    --secondary-color-light: #3b82f6;
    --background-color-light: #fafafa;
    --surface-color-light: #ffffff;
    --text-color-light: #0f172a;
    --border-color-light: #e2e8f0;

    /* Dark Theme */
    --primary-color-dark: #818cf8;
    --secondary-color-dark: #6366f1;
    --background-color-dark: #0f172a;
    --surface-color-dark: #1e293b;
    --text-color-dark: #f8fafc;
    --border-color-dark: #334155;

    /* Active Theme (default light) */
    --primary-color: var(--primary-color-light);
    --secondary-color: var(--secondary-color-light);
    --background-color: var(--background-color-light);
    --surface-color: var(--surface-color-light);
    --text-color: var(--text-color-light);
    --border-color: var(--border-color-light);
}

/* Dark Theme Override */
[data-theme="dark"] {
    --primary-color: var(--primary-color-dark);
    --secondary-color: var(--secondary-color-dark);
    --background-color: var(--background-color-dark);
    --surface-color: var(--surface-color-dark);
    --text-color: var(--text-color-dark);
    --border-color: var(--border-color-dark);
}

/* Base Styles */
body {
    font-family: 'Inter', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Layout Components */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--surface-color);
    color: var(--text-color);
    padding: 0.75rem 2rem;
    width: 100%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid var(--border-color);
}

main {
    width: 100%;
    max-width: 1200px;
    padding: 2rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: calc(100vh - 60px); /* Adjust based on header height */
    overflow-y: auto;
    padding: 1rem;
    box-sizing: border-box;
}

/* Upload Section */
.upload-section {
    width: 100%;
    max-width: 600px;
    border: 2px dashed var(--primary-color);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    margin-bottom: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent; /* Removes tap highlight on mobile */
    touch-action: manipulation; /* Improves touch handling */
    max-height: 200px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin: 1rem auto;
    position: relative;
    z-index: 1;
}

.upload-section:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.upload-section.dragover {
    background-color: var(--surface-color);
    border-color: var(--secondary-color);
}

/* Hide the native file input */
input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
    display: block !important; /* Ensure it's not completely hidden */
}

/* Transcription Section */
.transcription {
    display: none;
    margin-top: 2rem;
    max-width: 600px;
    width: 100%;
    background-color: var(--surface-color);
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-color);
    max-height: calc(100vh - 400px);
    overflow-y: auto;
}

.transcription.active {
    display: block;
    animation: fadeIn 0.5s ease-in-out;
}

/* Segment Styles */
.segment {
    margin: 12px 0;
    padding: 12px;
    background-color: var(--surface-color);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.segment-content {
    display: flex;
    gap: 8px;
    align-items: baseline;
}

.timestamp {
    color: var(--text-color);
    opacity: 0.7;
    font-family: monospace;
    font-size: 0.9em;
    white-space: nowrap;
}

.speaker-label {
    color: var(--primary-color);
    font-weight: 500;
    white-space: nowrap;
}

.text {
    flex: 1;
}

/* Buttons and Controls */
button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    cursor: pointer;
    font-size: 1rem;
    border-radius: 8px;
    transition: all 0.3s ease;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

button:disabled {
    background-color: var(--border-color);
    cursor: not-allowed;
    opacity: 0.7;
}

.download-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}

#downloadFormat {
    appearance: none;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    border-radius: 6px;
    color: var(--text-color);
    cursor: pointer;
    font-size: 0.9rem;
    min-width: 120px;
}

/* Add Styles for Download Button Animation */
.download-btn {
    position: relative;
    overflow: hidden;
    transition: background-color 0.3s ease, transform 0.3s ease;
}

.download-btn.active {
    background-color: var(--secondary-color);
    transform: scale(1.05);
}

.download-btn::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: -100%;
    background: rgba(255, 255, 255, 0.2);
    transition: left 0.3s ease;
    pointer-events: none;
}

.download-btn.active::after {
    left: 0;
}

/* Enhance Download Format Selection */
.format-toggle {
    position: relative;
}

#downloadFormat {
    appearance: none;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    padding: 0.5rem 2rem 0.5rem 0.5rem;
    border-radius: 6px;
    color: var(--text-color);
    cursor: pointer;
    font-size: 0.9rem;
    min-width: 120px;
    background-image: url('data:image/svg+xml;charset=US-ASCII,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="none" stroke="%23%236666f1" stroke-width="2" viewBox="0 0 24 24"><path d="M6 9l6 6 6-6"/></svg>');
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 12px 12px;
}

#downloadFormat:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

/* Optional: Smooth Transition for Select Dropdown */
#downloadFormat {
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Media Queries */
@media (max-width: 600px) {
    header {
        padding: 0.5rem 1rem;
        position: sticky;
        top: 0;
        z-index: 100;
    }

    main {
        padding: 1rem;
        padding: 0.5rem;
        min-height: calc(100vh - 50px);
    }

    .upload-section {
        padding: 1.5rem;
        border-width: 1px;
        margin: 0.5rem auto;
        max-height: 150px;
        min-height: 100px; /* Ensure minimum clickable area */
    }

    .upload-section:active {
        background-color: var(--surface-color);
        opacity: 0.8;
    }

    .download-container {
        flex-direction: column;
        align-items: stretch;
    }

    .download-btn {
        width: 100%;
    }

    #downloadFormat {
        width: 100%;
    }

    .segment {
        padding: 8px;
    }

    .transcription {
        max-height: calc(100vh - 300px);
    }

    body {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Additional Styles */
.hidden {
    display: none;
}
