:root {
    --background-color: #282c34;
    --text-color: #ffffff;
    --primary-color: #61dafb;
    --secondary-color: #20232a;
    --border-color: #444c56;
    --button-bg-color: #4a5058;
    --button-hover-bg-color: #5a6068;
    --placeholder-color: #a0a0a0;
    --recording-color: #ff3b30;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body.light-mode {
    --background-color: #ffffff;
    --text-color: #282c34;
    --primary-color: #007aff;
    --secondary-color: #f0f0f0;
    --border-color: #d1d1d1;
    --button-bg-color: #e0e0e0;
    --button-hover-bg-color: #d0d0d0;
    --placeholder-color: #757575;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
}

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

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

.app-header h1 {
    font-size: 1.8em;
    margin: 0;
    color: var(--primary-color);
}

.icon-button {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.5em;
    cursor: pointer;
}

.editor-controls {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
}

.control-button {
    background-color: var(--button-bg-color);
    color: var(--text-color);
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.2s;
}

.control-button:hover {
    background-color: var(--button-hover-bg-color);
}

.control-button i {
    margin-right: 8px;
}

.editor-title-container {
    margin-bottom: 20px;
}

.editor-title {
    width: 100%;
    padding: 10px;
    font-size: 1.2em;
    font-weight: bold;
    background-color: var(--secondary-color);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    box-sizing: border-box;
    min-height: 30px;
}

.editor-title:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-color-translucent, rgba(97, 218, 251, 0.5));
}

body.light-mode .editor-title:focus {
     box-shadow: 0 0 0 2px var(--primary-color-translucent, rgba(0, 122, 255, 0.5));
}

.recording-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
    padding: 20px;
    background-color: var(--secondary-color);
    border-radius: 8px;
}

#recordButton {
    background-color: var(--primary-color);
    color: white;
    border: none;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    font-size: 2em;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s, transform 0.1s;
    margin-bottom: 10px;
}

#recordButton:hover {
    opacity: 0.9;
}

#recordButton.recording {
    background-color: var(--recording-color);
}

#recordButton:active {
    transform: scale(0.95);
}

.record-button-inner i {
    display: block;
}

.status-message {
    font-size: 0.9em;
    min-height: 1.2em;
}

.recording-interface {
    width: 100%;
    min-height: 60px; /* Ensure space even when hidden */
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 10px;
}

.recording-interface.is-live {
    /* Styles when recording is live */
}

.status-indicator {
    width: 10px;
    height: 10px;
    background-color: var(--placeholder-color);
    border-radius: 50%;
    margin-bottom: 10px;
    display: none; /* Hidden by default, shown by JS */
}

#liveRecordingTitle {
    font-size: 1.1em;
    font-weight: bold;
    margin-bottom: 5px;
}

#liveWaveformCanvas {
    width: 100%;
    height: 50px; /* Adjust as needed */
    background-color: transparent;
    border-radius: 4px;
    margin-bottom: 5px;
}

#liveRecordingTimerDisplay {
    font-family: 'Courier New', Courier, monospace;
    font-size: 1em;
}

.transcription-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

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

.transcription-box {
    background-color: var(--secondary-color);
    padding: 15px;
    border-radius: 5px;
    border: 1px solid var(--border-color);
}

.transcription-box h2 {
    font-size: 1.2em;
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--primary-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
}

[contenteditable="true"] {
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    min-height: 150px;
    background-color: var(--background-color);
    color: var(--text-color);
    overflow-y: auto;
}

[contenteditable="true"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-color-translucent, rgba(97, 218, 251, 0.5));
}

body.light-mode [contenteditable="true"]:focus {
     box-shadow: 0 0 0 2px var(--primary-color-translucent, rgba(0, 122, 255, 0.5));
}

[contenteditable="true"].placeholder-active {
    color: var(--placeholder-color);
    font-style: italic;
}

/* Audio Files Management Styles */
.audio-files-container {
    margin-top: 30px;
    padding: 20px;
    background-color: var(--secondary-color);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.audio-files-container h2 {
    margin-top: 0;
    margin-bottom: 20px;
    color: var(--primary-color);
}

.audio-controls {
    margin-bottom: 20px;
    text-align: center;
}

.audio-session {
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.session-header {
    background-color: var(--button-bg-color);
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.session-header h3 {
    margin: 0;
    font-size: 16px;
    flex: 1;
    min-width: 200px;
}

.session-info {
    display: flex;
    gap: 15px;
    font-size: 14px;
    color: var(--placeholder-color);
}

.delete-session-btn, .delete-chunk-btn {
    background-color: var(--recording-color);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s;
}

.delete-session-btn:hover, .delete-chunk-btn:hover {
    background-color: #cc0000;
}

.chunks-list {
    padding: 0;
}

.chunk-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    flex-wrap: wrap;
    gap: 10px;
}

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

.chunk-item:nth-child(even) {
    background-color: var(--background-color);
}

.chunk-item span {
    flex: 1;
    min-width: 80px;
}

.chunk-item span:first-child {
    font-weight: bold;
    color: var(--primary-color);
}

/* Transcription controls */
.transcription-controls {
    margin-top: 10px;
    text-align: center;
}

.ai-process-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.ai-process-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.ai-process-button:active {
    transform: translateY(0);
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.3);
}

.ai-process-button:disabled {
    background: linear-gradient(135deg, #a0a0a0 0%, #808080 100%);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.ai-process-button:disabled:hover {
    transform: none;
    box-shadow: none;
}

.ai-status {
    text-align: center;
    padding: 10px;
    color: var(--primary-color);
    font-style: italic;
    font-size: 14px;
}

.ai-status i {
    margin-right: 5px;
}

/* Animation for AI processing */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.6; }
    100% { opacity: 1; }
}

.ai-status.processing {
    animation: pulse 2s infinite;
}

/* CSS for voice notes with audio links */
.notes-header {
    padding: 10px 0;
    margin-bottom: 15px;
    border-bottom: 2px solid #007bff;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 5px 5px 0 0;
    text-align: center;
}

.notes-header h3 {
    color: #007bff;
    font-weight: 600;
    margin: 0;
    font-size: 1.2em;
}

.note-audio {
    margin-top: 10px;
    padding: 8px 0;
    border-top: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.audio-link-btn, .audio-chunks-btn {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-right: 8px;
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.3);
}

.audio-chunks-btn {
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
    box-shadow: 0 2px 4px rgba(23, 162, 184, 0.3);
}

.audio-link-btn:hover {
    background: linear-gradient(135deg, #218838 0%, #1e7e34 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(40, 167, 69, 0.4);
}

.audio-chunks-btn:hover {
    background: linear-gradient(135deg, #138496 0%, #117a8b 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(23, 162, 184, 0.4);
}

.audio-link-btn:active, .audio-chunks-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.3);
}

.audio-session-id {
    color: #6c757d;
    font-size: 0.75em;
    font-style: italic;
    padding: 2px 6px;
    background-color: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #dee2e6;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.no-audio {
    color: #6c757d;
    font-style: italic;
    font-size: 0.9em;
    padding: 5px 0;
}

/* Audio chunks container styling */
.audio-chunks-container {
    margin-top: 10px;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.chunks-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #dee2e6;
}

.chunks-header h4 {
    margin: 0;
    color: #495057;
    font-size: 1em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chunks-summary {
    display: flex;
    gap: 15px;
    font-size: 0.85em;
    color: #6c757d;
}

.chunks-summary span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.chunks-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.chunk-item-inline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.chunk-item-inline:hover {
    border-color: #007bff;
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.1);
}

.chunk-info {
    display: flex;
    gap: 15px;
    align-items: center;
    flex: 1;
}

.chunk-number {
    font-weight: 600;
    color: #495057;
    min-width: 80px;
}

.chunk-duration, .chunk-size {
    font-size: 0.85em;
    color: #6c757d;
    min-width: 60px;
}

.chunk-controls {
    display: flex;
    gap: 5px;
}

.chunk-play-btn, .chunk-download-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.8em;
}

.chunk-download-btn {
    background: #6c757d;
}

.chunk-play-btn:hover {
    background: #0056b3;
    transform: scale(1.05);
}

.chunk-download-btn:hover {
    background: #545b62;
    transform: scale(1.05);
}

.chunks-actions {
    display: flex;
    justify-content: center;
    padding-top: 10px;
    border-top: 1px solid #dee2e6;
}

.play-all-btn {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.3);
}

.play-all-btn:hover {
    background: linear-gradient(135deg, #218838 0%, #1e7e34 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(40, 167, 69, 0.4);
}

.chunks-loading, .no-chunks, .chunks-error {
    text-align: center;
    padding: 20px;
    color: #6c757d;
    font-style: italic;
}

.chunks-error {
    color: #dc3545;
}

/* Responsive design for audio files */
@media (max-width: 768px) {
    .session-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .session-info {
        justify-content: space-between;
    }
    
    .chunk-item {
        flex-direction: column;
        align-items: stretch;
        text-align: left;
    }
    
    .chunk-item span {
        margin-bottom: 5px;
    }
    
    .delete-chunk-btn {
        align-self: flex-end;
        margin-top: 10px;
    }
    
    .audio-link-btn, .audio-chunks-btn {
        font-size: 0.8em;
        padding: 5px 10px;
        margin-right: 5px;
        margin-bottom: 5px;
    }
    
    .notes-header h3 {
        font-size: 1.1em;
    }
    
    .note-audio {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .chunks-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .chunks-summary {
        flex-direction: column;
        gap: 5px;
    }
    
    .chunk-item-inline {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .chunk-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .chunk-controls {
        align-self: flex-end;
    }
}

/* Auto-save Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--background-color);
    border-radius: 8px;
    min-width: 400px;
    max-width: 500px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
}

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

.modal-header h3 {
    margin: 0;
    color: var(--primary-color);
}

.modal-close {
    font-size: 24px;
    cursor: pointer;
    color: var(--text-color);
    transition: color 0.2s;
}

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

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.setting-group {
    margin-bottom: 15px;
}

.setting-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-color);
}

.setting-group input[type="checkbox"] {
    margin-right: 8px;
}

.setting-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    background: var(--secondary-color);
    color: var(--text-color);
}

.setting-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(97, 218, 251, 0.2);
}

.text-muted {
    color: var(--placeholder-color);
    font-size: 12px;
    line-height: 1.4;
}

/* Auto-save indicator */
#autoSaveIndicator {
    position: fixed;
    top: 10px;
    right: 10px;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 1000;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}
