/* ================================
   MedComms Styles
   Modern, clean, responsive design
   ================================ */

/* ====== CSS Variables ====== */
:root {
    /* Colors - VinUniversity Brand */
    --primary-color: #2E548A;        /* Blue */
    --primary-dark: #1e3a5f;
    --primary-light: #d4e0ed;

    --secondary-color: #4890BD;      /* Light Blue */
    --secondary-dark: #366d8f;

    --accent-color: #5CC6D0;         /* Turquoise */
    --error-color: #ef4444;          /* Error red */

    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;

    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --bg-pale-blue: #A7C4D2;         /* Pale Blue Gray */

    --border-color: #e5e7eb;
    --border-light: #f3f4f6;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);

    /* Transitions */
    --transition-fast: 150ms ease-in-out;
    --transition-normal: 250ms ease-in-out;
    --transition-slow: 350ms ease-in-out;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
                 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
                 sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: linear-gradient(135deg, var(--bg-pale-blue) 0%, var(--secondary-color) 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

/* ====== Container ====== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--spacing-lg);
}

/* ====== Header ====== */
.header {
    text-align: center;
    margin-bottom: var(--spacing-2xl);
    padding: var(--spacing-xl) var(--spacing-lg);
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: var(--spacing-sm);
}

.subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ====== Action Buttons ====== */
.mode-content {
    position: relative;
    margin-bottom: var(--spacing-xl);
}



@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.action-buttons {
    display: flex;
    gap: var(--spacing-md);
    justify-content: center;
    width: 100%;
    flex-wrap: wrap;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.9375rem;
    font-weight: 600;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-md);
    flex: 1;
    min-width: 140px;
}

.action-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.action-btn svg {
    stroke-width: 2.5;
}

.active-interface {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    align-items: center;
}

.back-btn {
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all var(--transition-fast);
}

.back-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

#source-output {
    width: 100%;
    text-align: left;
}

.toggle-record-btn {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-lg);
    font-size: 0.9375rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-md);
    background: var(--error-color);
    color: white;
}

.toggle-record-btn:hover:not(:disabled) {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.toggle-record-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.toggle-record-btn.recording {
    background: var(--text-secondary);
}

.toggle-record-btn.recording:hover:not(:disabled) {
    background: var(--text-primary);
}

.toggle-icon {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    transition: all var(--transition-normal);
}

.toggle-record-btn.recording .toggle-icon {
    border-radius: var(--radius-sm);
}

/* ====== Text Panel ====== */
.text-input-container {
    position: relative;
    margin-bottom: var(--spacing-lg);
    width: 100%;
}

#text-input {
    width: 100%;
    padding: var(--spacing-lg);
    font-size: 1rem;
    font-family: inherit;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    resize: vertical;
    transition: border-color var(--transition-normal);
    min-height: 250px;
}

#text-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.char-count {
    position: absolute;
    bottom: var(--spacing-sm);
    right: var(--spacing-md);
    font-size: 0.875rem;
    color: var(--text-muted);
}

.char-count.error {
    color: var(--error-color);
    font-weight: 600;
}

.translate-btn {
    width: 100%;
    padding: var(--spacing-lg);
    font-size: 1.125rem;
    font-weight: 600;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-normal);
}

.translate-btn:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.translate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ====== Output Section ====== */
.output-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
}

.output-panel {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-lg);
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--border-light);
}

.panel-title-group {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

.panel-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.language-dropdown {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.language-dropdown:hover {
    border-color: var(--primary-color);
}

.language-dropdown:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.switch-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: bold;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
}

.switch-btn:hover {
    background: var(--primary-dark);
    transform: rotate(180deg);
}

.switch-btn:active {
    transform: rotate(180deg) scale(0.95);
}

.copy-btn {
    background: transparent;
    border: none;
    padding: var(--spacing-sm);
    cursor: pointer;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.copy-btn:hover:not(:disabled) {
    background: var(--bg-tertiary);
    color: var(--primary-color);
}

.copy-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.panel-content {
    padding: var(--spacing-xl);
    min-height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-md);
    transition: all var(--transition-normal);
}

.empty-state {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
}

.output-text {
    font-size: 1.25rem;
    line-height: 1.9;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* ====== Log Section ====== */
.log-section {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.log-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    background: var(--bg-secondary);
    border: none;
    cursor: pointer;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.log-toggle:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.log-toggle svg {
    transition: transform var(--transition-normal);
}

.log-content {
    padding: var(--spacing-md);
    max-height: 300px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    background: var(--bg-primary);
    transition: max-height var(--transition-slow);
}

.log-content.collapsed {
    max-height: 0;
    padding: 0;
    overflow: hidden;
}

.log-entry {
    padding: var(--spacing-xs) 0;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-light);
}

.log-entry:last-child {
    border-bottom: none;
}

/* ====== Scrollbar Styling ====== */
.log-content::-webkit-scrollbar {
    width: 8px;
}

.log-content::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.log-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-sm);
}

.log-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

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

    .subtitle {
        font-size: 1rem;
    }

    .panel-title-group {
        gap: var(--spacing-sm);
    }

    .action-buttons {
        flex-direction: column;
    }

    .action-btn {
        width: 100%;
    }

    .toggle-record-btn {
        width: 100%;
    }

    .output-section {
        grid-template-columns: 1fr;
    }

    .container {
        padding: var(--spacing-md);
    }

    .mode-panel {
        padding: var(--spacing-lg);
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.5rem;
    }

    .header {
        padding: var(--spacing-lg) var(--spacing-md);
    }

    .mode-panel {
        padding: var(--spacing-md);
        min-height: 200px;
    }
}

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

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ====== Loading Animation ====== */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading {
    animation: spin 1s linear infinite;
}

/* ====== Accessibility ====== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ====== Dialogue History ====== */
.history-section {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    margin-bottom: var(--spacing-xl);
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-lg);
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--border-light);
}

.history-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.clear-history-btn {
    padding: var(--spacing-xs) var(--spacing-md);
    background: var(--error-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all var(--transition-fast);
}

.clear-history-btn:hover {
    background: #dc2626;
}

.history-content {
    padding: var(--spacing-md);
    max-height: 400px;
    overflow-y: auto;
}

.empty-history {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    padding: var(--spacing-lg);
}

.history-item {
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--accent-color);
}

.history-item:last-child {
    margin-bottom: 0;
}

.history-timestamp {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: var(--spacing-xs);
}

.history-text {
    margin: var(--spacing-xs) 0;
}

.history-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-xs);
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.history-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.history-value {
    font-size: 0.9375rem;
    color: var(--text-primary);
    line-height: 1.5;
}

/* ====== Star Rating ====== */
.star-rating {
    display: flex;
    gap: 2px;
    align-items: center;
}

.star {
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: all var(--transition-fast);
    user-select: none;
}

.star:hover,
.star.hover {
    color: #f59e0b;
    transform: scale(1.2);
}

.star.filled {
    color: #f59e0b;
}

/* ====== Correction Section ====== */
.correction-section {
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 1px dashed var(--border-color);
}

.correction-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xs);
}

.correction-input-wrapper {
    display: flex;
    gap: var(--spacing-sm);
    align-items: flex-start;
}

.correction-input {
    flex: 1;
    padding: var(--spacing-sm);
    font-size: 0.875rem;
    font-family: inherit;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    resize: vertical;
    min-height: 60px;
    transition: border-color var(--transition-fast);
}

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

.correction-input::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

.save-correction-btn {
    padding: var(--spacing-sm);
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
}

.save-correction-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.save-correction-btn:active {
    transform: translateY(0);
}

.correction-saved {
    font-size: 0.75rem;
    color: var(--accent-color);
    font-weight: 600;
    margin-top: var(--spacing-xs);
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.correction-saved::before {
    content: '✓';
}

/* ====== History Content Scrollbar ====== */
.history-content::-webkit-scrollbar {
    width: 8px;
}

.history-content::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.history-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-sm);
}

.history-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ====== Rating/Correction Responsive ====== */
@media (max-width: 480px) {
    .history-label-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .star-rating {
        margin-top: var(--spacing-xs);
    }

    .star {
        font-size: 1.5rem;
    }

    .correction-input-wrapper {
        flex-direction: column;
    }

    .save-correction-btn {
        width: 100%;
    }
}

/* ====== Copyright Footer ====== */
.copyright-footer {
    text-align: center;
    padding: var(--spacing-lg) var(--spacing-md);
    margin-top: var(--spacing-xl);
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.copyright-footer p {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ====== Print Styles ====== */
@media print {
    .container {
        max-width: 100%;
    }

    .mode-selector,
    .recording-controls,
    .text-input-container,
    .log-section,
    .copy-btn {
        display: none;
    }

    .output-section {
        display: block;
    }

    .output-panel {
        page-break-inside: avoid;
        margin-bottom: var(--spacing-lg);
    }
}
