@import url('https://fonts.cdnfonts.com/css/satoshi');

:root {
    --primary: #326bca;
    --primary-dark: #2557a8;
    --primary-light: #4d82d8;
    --bg-light: #f8f9fa;
    --bg-white: #ffffff;
    --text-dark: #1a1a1a;
    --text-gray: #6c757d;
    --border: #e0e0e0;
    --success: #28a745;
    --danger: #dc3545;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Satoshi', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #fafafa;
    color: var(--text-dark);
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 40px;
}

h1 {
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--primary);
    margin-bottom: 10px;
}

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

h2 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 20px;
}

h3 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.script-section {
    background: var(--bg-white);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.script-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.script-header h2 {
    font-size: 1.3rem;
    margin-bottom: 0;
    color: var(--primary);
}

#recordBtn {
    padding: 12px;
}

.accordion-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.accordion-toggle:hover {
    background: var(--bg-light);
}

.toggle-icon {
    width: 28px;
    height: 28px;
    color: var(--primary);
    transition: transform 0.3s ease;
}

.toggle-icon.collapsed {
    transform: rotate(-90deg);
}

.script-description {
    font-size: 1.1rem;
    color: var(--text-gray);
    font-weight: 500;
    margin-top: 8px;
    line-height: 1.6;
}

.script-content {
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.3s ease, margin-top 0.3s ease;
    max-height: 1000px;
    opacity: 1;
    margin-top: 16px;
}

.script-content.collapsed {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
}

.script-pills {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.pill {
    font-family: 'Satoshi', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 8px 16px;
    border: 2px solid var(--border);
    border-radius: 50px;
    background: var(--bg-white);
    color: var(--text-gray);
    cursor: pointer;
    transition: all 0.3s ease;
}

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

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

.script-box {
    background: var(--bg-light);
    border-left: 4px solid var(--primary);
    padding: 20px;
    border-radius: 8px;
    font-size: 1rem;
    line-height: 1.7;
}

.script-box p {
    margin-bottom: 16px;
}

.script-box p:last-child {
    margin-bottom: 0;
}

.highlight {
    background: #ffd93d;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
}

.controls-section {
    background: var(--bg-white);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 30px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.timer-display {
    margin-bottom: 16px;
}

.timer {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.timer.recording {
    color: var(--danger);
}

.timer.warning {
    color: #ff9800;
    animation: pulse 1s infinite;
}

.timer.danger {
    color: var(--danger);
    animation: pulse 0.5s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

.timer-label {
    font-size: 1rem;
    color: var(--text-gray);
    font-weight: 500;
}

.btn {
    font-family: 'Satoshi', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    width: 80px;
    height: 80px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(50, 107, 202, 0.3);
}

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

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(108, 117, 125, 0.3);
}

.try-again-btn {
    margin-top: 20px;
    width: auto;
    height: auto;
    border-radius: 12px;
    padding: 14px 28px;
    font-size: 1rem;
    display: inline-flex;
    gap: 8px;
}

.btn-primary.recording {
    background: var(--danger);
    animation: recording-pulse 2s infinite;
}

@keyframes recording-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7);
    }
    50% {
        box-shadow: 0 0 0 20px rgba(220, 53, 69, 0);
    }
}

.btn-icon {
    width: 32px;
    height: 32px;
}

.audio-player-section {
    background: var(--bg-white);
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.audio-player-section h2 {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--primary);
    margin-bottom: 24px;
}

.audio-player {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px 24px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
}

.play-pause-btn {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.play-pause-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(50, 107, 202, 0.3);
}

.play-pause-icon {
    width: 40px;
    height: 40px;
    color: white;
}

.audio-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
}

.time-display {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-dark);
    min-width: 45px;
}

.progress-bar-container {
    flex: 1;
    height: 40px;
    display: flex;
    align-items: center;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    position: relative;
    cursor: pointer;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    width: 0%;
    transition: width 0.1s linear;
}

.progress-handle {
    width: 20px;
    height: 20px;
    background: var(--primary);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    left: 0%;
    cursor: grab;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.progress-handle:active {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(1.1);
}

.download-btn {
    width: 28px;
    height: 28px;
    padding: 4px;
    border: none;
    background: transparent;
    color: #9e9e9e;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
}

.download-btn:hover {
    background: #f5f5f5;
    color: var(--primary);
    opacity: 1;
}

.download-btn svg {
    width: 20px;
    height: 20px;
}

.status-message {
    margin-top: 20px;
    font-size: 1rem;
    font-weight: 500;
    min-height: 24px;
}

.status-message.recording {
    color: var(--danger);
}

.status-message.success {
    color: var(--success);
}

.results-section {
    background: var(--bg-white);
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.result-card {
    background: var(--bg-light);
    border-radius: 12px;
    padding: 24px;
    border-top: 4px solid var(--primary);
}

.result-description {
    font-size: 0.9rem;
    color: var(--text-gray);
    margin-bottom: 16px;
}

.emotion-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.emotion-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-white);
    border-radius: 6px;
    font-size: 0.95rem;
}

.emotion-name {
    font-weight: 600;
    color: var(--text-dark);
    text-transform: capitalize;
}

.emotion-score {
    font-weight: 700;
    color: var(--primary);
}

.emotion-bar {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 4px;
}

.emotion-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.5s ease;
}

.loading {
    text-align: center;
    padding: 60px 20px;
    background: var(--bg-white);
    border-radius: 16px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.spinner {
    width: 60px;
    height: 60px;
    border: 6px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.loading p {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-gray);
}

.transcription {
    background: var(--bg-light);
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-style: italic;
    color: var(--text-gray);
}

.debug-section {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 12px;
    border: 2px solid #e0e0e0;
}

.debug-section h3 {
    color: #6c757d;
    font-size: 1.1rem;
    margin-bottom: 12px;
}

.debug-json {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    max-height: 500px;
    overflow-y: auto;
}

/* Coaching Section */
.coaching-section {
    padding-bottom: 30px;
}

.coaching-section h2 {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--primary);
    margin-bottom: 24px;
}

.section-icon {
    width: 32px;
    height: 32px;
}

.coaching-grid {
    display: grid;
    gap: 24px;
    margin-top: 20px;
}

.coaching-card {
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.coaching-card h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tip-icon {
    width: 24px;
    height: 24px;
    color: #ffc107;
}

.tone-card {
    background: linear-gradient(135deg, #e3f2fd 0%, #f1f8ff 100%);
    border-left: 4px solid var(--primary);
}

.tone-summary {
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--primary);
    text-align: center;
    padding: 16px;
}

.emotions-card {
    background: linear-gradient(135deg, #f3e5f5 0%, #fce4ec 100%);
    border-left: 4px solid #9c27b0;
}

.emotions-chart-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: white;
    border-radius: 12px;
    margin-bottom: 16px;
    min-height: 350px;
    width: 100%;
    max-width: 100%;
    overflow: visible;
}

#emotionsChart {
    width: 100% !important;
    max-width: 800px;
    height: 300px !important;
}

.emotion-legend {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: white;
    border-radius: 8px;
    transition: transform 0.2s ease;
}

.legend-item:hover {
    transform: translateX(4px);
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    flex-shrink: 0;
}

.legend-emoji {
    font-size: 1.4rem;
    flex-shrink: 0;
}

.legend-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-dark);
    flex: 1;
}

.tip-card {
    background: linear-gradient(135deg, #fff8e1 0%, #fffde7 100%);
    border-left: 4px solid #ffc107;
}

.coaching-tip {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-dark);
    line-height: 1.7;
    padding: 16px;
    background: white;
    border-radius: 12px;
}

@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }
    
    .timer {
        font-size: 3rem;
    }
    
    .script-box {
        font-size: 1rem;
        padding: 20px;
    }
    
    .results-grid {
        grid-template-columns: 1fr;
    }
    
    .coaching-grid {
        grid-template-columns: 1fr;
    }
    
    .tone-summary {
        font-size: 1.5rem;
    }
}

/* Email Section */
.email-section {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 2px solid var(--border);
}

.email-section h2 {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--primary);
    margin-bottom: 24px;
}

.email-form {
    background: white;
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

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

.form-group input {
    font-family: 'Satoshi', sans-serif;
    font-size: 1rem;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    transition: border-color 0.3s ease;
}

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

.submit-btn {
    width: auto;
    height: auto;
    border-radius: 12px;
    padding: 14px 28px;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-icon-small {
    width: 20px;
    height: 20px;
}

.email-status {
    margin-top: 16px;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    text-align: center;
}

.email-status.success {
    background: #d4edda;
    color: #155724;
}

.email-status.error {
    background: #f8d7da;
    color: #721c24;
}

/* Delivery Metrics Styles */
.metrics-card {
    background: linear-gradient(135deg, #e8f5e9 0%, #f1f8e9 100%);
    border-left: 4px solid #4caf50;
}

.delivery-metrics {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: white;
    border-radius: 8px;
}

.metric-label {
    font-size: 1rem;
    font-weight: 600;
    color: #2d3748;
}

.metric-value {
    display: flex;
    gap: 8px;
}

.metric-badge {
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-ideal {
    background: #4caf50;
    color: white;
}

.badge-fast {
    background: #ff9800;
    color: white;
}

.badge-slow {
    background: #2196f3;
    color: white;
}

.badge-balanced {
    background: #4caf50;
    color: white;
}

.badge-rushed {
    background: #ff9800;
    color: white;
}

.badge-drawn-out {
    background: #9c27b0;
    color: white;
}

.badge-unknown {
    background: #9e9e9e;
    color: white;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: white;
    padding: 32px;
    border-radius: 16px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.modal-content h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 16px;
}

.modal-content p {
    font-size: 1rem;
    color: #4a5568;
    margin-bottom: 24px;
    line-height: 1.6;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.modal-buttons .btn {
    width: auto;
    height: auto;
    border-radius: 50px;
    padding: 12px 28px;
    font-size: 0.95rem;
    font-weight: 600;
}

.btn-secondary {
    background: #9e9e9e;
}

.btn-secondary:hover {
    background: #757575;
}

@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .modal-buttons {
        flex-direction: column;
    }
    
    .modal-buttons .btn {
        width: 100%;
    }
}
