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

:root {
    --primary-color: #4F46E5;
    --primary-dark: #4338CA;
    --secondary-color: #10B981;
    --danger-color: #EF4444;
    --text-dark: #1F2937;
    --text-light: #6B7280;
    --bg-light: #F9FAFB;
    --bg-white: #FFFFFF;
    --border-color: #E5E7EB;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-dark);
    line-height: 1.6;
    background-color: var(--bg-light);
}

/* Login Page Styles */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    width: 100%;
    max-width: 450px;
    padding: 20px;
}

.login-box {
    background: var(--bg-white);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 40px;
}

.logo {
    text-align: center;
    margin-bottom: 30px;
}

.logo-image {
    max-width: 180px;
    height: auto;
    margin-bottom: 15px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.logo h1 {
    color: var(--primary-color);
    font-size: 2rem;
    margin-bottom: 5px;
}

.logo p {
    color: var(--text-light);
    font-size: 0.95rem;
}

.login-form {
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-dark);
    font-weight: 500;
    font-size: 0.95rem;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.error-message {
    color: var(--danger-color);
    font-size: 0.9rem;
    margin-bottom: 15px;
    display: none;
    padding: 10px;
    background-color: #FEE2E2;
    border-radius: 6px;
}

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

.login-info {
    background-color: var(--bg-light);
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    font-size: 0.9rem;
}

.login-info p {
    margin: 5px 0;
    color: var(--text-light);
}

.login-info code {
    background-color: var(--bg-white);
    padding: 2px 8px;
    border-radius: 4px;
    color: var(--primary-color);
    font-weight: 600;
}

/* Button Styles */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    width: 100%;
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

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

.btn-secondary:hover {
    background-color: #059669;
    transform: translateY(-1px);
}

/* Navbar Styles */
.navbar {
    background-color: var(--bg-white);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.3s;
}

.nav-brand:hover {
    opacity: 0.8;
}

.nav-logo {
    max-height: 40px;
    width: auto;
}

.nav-brand h2 {
    color: var(--primary-color);
    font-size: 1.5rem;
    margin: 0;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 10px;
    align-items: center;
}

.nav-menu > li {
    position: relative;
}

.nav-menu a {
    color: var(--text-dark);
    text-decoration: none;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 6px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.nav-menu a:hover {
    background-color: var(--bg-light);
    color: var(--primary-color);
}

.nav-menu a.active {
    background-color: var(--primary-color);
    color: white;
}

.nav-menu a.logout {
    color: var(--danger-color);
}

.nav-menu a.logout:hover {
    background-color: #FEE2E2;
}

/* Dropdown Menu */
.nav-dropdown {
    position: relative;
}

.nav-dropdown > a {
    cursor: pointer;
}

.nav-dropdown-toggle::after {
    content: '▼';
    font-size: 0.7rem;
    margin-left: 4px;
    transition: transform 0.3s;
}

.nav-dropdown.active .nav-dropdown-toggle::after {
    transform: rotate(180deg);
}

.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    background-color: var(--bg-white);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s;
    z-index: 1001;
}

.nav-dropdown.active .nav-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.nav-dropdown-menu::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 20px;
    width: 12px;
    height: 12px;
    background-color: var(--bg-white);
    transform: rotate(45deg);
    box-shadow: -2px -2px 2px rgba(0, 0, 0, 0.05);
}

.nav-dropdown-menu a {
    display: block;
    padding: 12px 20px;
    color: var(--text-dark);
    text-decoration: none;
    transition: all 0.3s;
    border-radius: 0;
    font-size: 0.95rem;
}

.nav-dropdown-menu a:first-child {
    border-radius: 8px 8px 0 0;
}

.nav-dropdown-menu a:last-child {
    border-radius: 0 0 8px 8px;
}

.nav-dropdown-menu a:hover {
    background-color: var(--bg-light);
    color: var(--primary-color);
    padding-left: 24px;
}

.nav-dropdown-menu a.active {
    background-color: var(--primary-color);
    color: white;
}

.nav-dropdown-menu a.active:hover {
    padding-left: 24px;
}

.nav-dropdown-item-icon {
    display: inline-block;
    width: 20px;
    text-align: center;
    margin-right: 8px;
}

/* Container and Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

.dashboard-header,
.page-header {
    text-align: center;
    margin-bottom: 50px;
}

.dashboard-header h1,
.page-header h1 {
    font-size: 2.5rem;
    color: var(--text-dark);
    margin-bottom: 10px;
}

.dashboard-header p,
.page-header p {
    font-size: 1.1rem;
    color: var(--text-light);
}

/* Feature Grid */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-top: 40px;
}

.feature-card {
    background: var(--bg-white);
    border-radius: 12px;
    padding: 40px 30px;
    box-shadow: var(--shadow);
    text-align: center;
    transition: all 0.3s;
}

.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.feature-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.feature-card h3 {
    font-size: 1.8rem;
    color: var(--text-dark);
    margin-bottom: 15px;
}

.feature-card p {
    color: var(--text-light);
    margin-bottom: 25px;
    line-height: 1.6;
}

/* Demo Placeholder */
.demo-placeholder {
    background: var(--bg-white);
    border-radius: 12px;
    padding: 60px 40px;
    box-shadow: var(--shadow);
    text-align: center;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.placeholder-content {
    max-width: 600px;
}

.placeholder-icon {
    font-size: 5rem;
    margin-bottom: 20px;
}

.placeholder-content h2 {
    font-size: 2rem;
    color: var(--text-dark);
    margin-bottom: 15px;
}

.placeholder-content p {
    font-size: 1.1rem;
    color: var(--text-light);
    margin-bottom: 30px;
}

.feature-list {
    list-style: none;
    text-align: left;
    display: inline-block;
    margin-top: 30px;
}

.feature-list li {
    padding: 12px 0;
    color: var(--text-dark);
    font-size: 1rem;
    position: relative;
    padding-left: 30px;
}

.feature-list li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--secondary-color);
    font-weight: bold;
    font-size: 1.2rem;
}

/* TTS Page Styles */
.tts-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-top: 30px;
}

.form-card,
.result-card {
    background: var(--bg-white);
    border-radius: 12px;
    padding: 30px;
    box-shadow: var(--shadow);
}

.form-card h3,
.result-card h3 {
    font-size: 1.3rem;
    color: var(--text-dark);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
}

.tts-textarea {
    width: 100%;
    padding: 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 20px;
    transition: border-color 0.3s;
}

.tts-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-row {
    display: grid;
    gap: 15px;
    margin-bottom: 20px;
}

.voice-select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background-color: var(--bg-white);
    cursor: pointer;
    transition: border-color 0.3s;
}

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

.api-config {
    background-color: var(--bg-light);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.api-config label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-dark);
    font-weight: 500;
    font-size: 0.95rem;
}

.api-input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: 'Courier New', monospace;
    background-color: var(--bg-white);
}

.api-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.help-text {
    display: block;
    margin-top: 6px;
    font-size: 0.85rem;
    color: var(--text-light);
}

.btn-large {
    width: 100%;
    padding: 15px;
    font-size: 1.1rem;
}

.error-box {
    display: none;
    margin-top: 15px;
    padding: 12px 15px;
    background-color: #FEE2E2;
    border-left: 4px solid var(--danger-color);
    border-radius: 6px;
    color: var(--danger-color);
    font-size: 0.9rem;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.5;
    max-height: 300px;
    overflow-y: auto;
}

/* Loading Indicator */
.loading-indicator {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    text-align: center;
}

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

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-indicator p {
    margin-top: 15px;
    color: var(--text-light);
    font-size: 1rem;
}

/* Audio Result */
.audio-result {
    margin-bottom: 20px;
}

.audio-placeholder {
    text-align: center;
    padding: 60px 20px;
    background-color: var(--bg-light);
    border-radius: 8px;
    border: 2px dashed var(--border-color);
}

.placeholder-icon-large {
    font-size: 4rem;
    margin-bottom: 15px;
    opacity: 0.5;
}

.audio-placeholder p {
    color: var(--text-light);
    font-size: 1rem;
}

/* Audio Controls */
.audio-controls {
    display: none;
}

.audio-player {
    width: 100%;
    margin-bottom: 20px;
    border-radius: 8px;
}

.control-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.control-buttons .btn {
    flex: 1;
}

/* Audio Info */
.audio-info {
    display: none;
    background-color: var(--bg-light);
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.info-item:last-child {
    border-bottom: none;
}

.info-label {
    color: var(--text-light);
    font-size: 0.9rem;
}

.info-value {
    color: var(--text-dark);
    font-weight: 600;
    font-size: 0.9rem;
}

/* OCR Page Styles */
.ocr-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-top: 30px;
}

/* Upload Area */
.upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 50px 20px;
    border: 3px dashed var(--border-color);
    border-radius: 12px;
    background-color: var(--bg-light);
    cursor: pointer;
    transition: all 0.3s;
    min-height: 300px;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background-color: #F0F0FF;
}

.upload-area.drag-over {
    border-color: var(--primary-color);
    background-color: #E8E8FF;
    transform: scale(1.02);
}

.upload-icon {
    font-size: 4rem;
    margin-bottom: 15px;
    opacity: 0.6;
}

.upload-text {
    font-size: 1.1rem;
    color: var(--text-dark);
    margin-bottom: 8px;
    font-weight: 500;
}

.upload-hint {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 20px;
}

/* File Preview */
.file-preview {
    display: none;
    padding: 20px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background-color: var(--bg-white);
    margin-bottom: 20px;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
}

.file-name {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 1rem;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-clear {
    background: none;
    border: none;
    color: var(--danger-color);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 8px;
    transition: transform 0.2s;
}

.btn-clear:hover {
    transform: scale(1.2);
}

.preview-image {
    width: 100%;
    max-height: 400px;
    object-fit: contain;
    border-radius: 8px;
    margin-bottom: 10px;
    background-color: var(--bg-light);
}

.file-info {
    text-align: center;
    color: var(--text-light);
    font-size: 0.9rem;
}

/* OCR Result */
.ocr-result {
    margin-bottom: 20px;
}

.result-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 80px 20px;
    background-color: var(--bg-light);
    border-radius: 8px;
    border: 2px dashed var(--border-color);
}

.result-content {
    display: none;
}

.result-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.result-actions .btn {
    flex: 1;
}

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

.result-text-container {
    margin-bottom: 20px;
}

.extracted-text {
    width: 100%;
    min-height: 300px;
    padding: 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Courier New', monospace;
    resize: vertical;
    background-color: var(--bg-white);
    line-height: 1.6;
}

.extracted-text:focus {
    outline: none;
    border-color: var(--primary-color);
}

.result-info {
    display: none;
    background-color: var(--bg-light);
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
}

/* STT Page Styles */
.stt-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-top: 30px;
}

.stt-upload-section,
.stt-result-section {
    min-height: 400px;
}

.audio-preview {
    margin: 15px 0;
}

.record-section {
    margin: 25px 0;
}

.record-divider {
    text-align: center;
    margin: 20px 0;
    position: relative;
}

.record-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background-color: var(--border-color);
    z-index: 0;
}

.record-divider span {
    position: relative;
    display: inline-block;
    padding: 0 15px;
    background-color: var(--bg-white);
    color: var(--text-light);
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 1;
}

.recording-indicator {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 15px;
    background-color: #FEE2E2;
    border-radius: 8px;
    margin: 15px 0;
    color: var(--danger-color);
    font-weight: 600;
}

.recording-dot {
    width: 12px;
    height: 12px;
    background-color: var(--danger-color);
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

#recordingTime {
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
}

.stt-result {
    margin-bottom: 20px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        height: auto;
        padding: 15px 20px;
    }

    .nav-menu {
        flex-wrap: wrap;
        gap: 10px;
        margin-top: 15px;
        justify-content: center;
    }

    .nav-dropdown-menu {
        position: fixed;
        left: 50%;
        transform: translateX(-50%) translateY(-10px);
        width: 90%;
        max-width: 300px;
    }

    .nav-dropdown.active .nav-dropdown-menu {
        transform: translateX(-50%) translateY(0);
    }

    .dashboard-header h1,
    .page-header h1 {
        font-size: 2rem;
    }

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

    .demo-placeholder {
        padding: 40px 20px;
    }

    .login-box {
        padding: 30px 20px;
    }

    .tts-container,
    .ocr-container,
    .stt-container {
        grid-template-columns: 1fr;
    }

    .control-buttons,
    .result-actions {
        flex-direction: column;
    }
    
    .upload-area {
        padding: 30px 15px;
        min-height: 200px;
    }
    
    .preview-image {
        max-height: 250px;
    }
}

