/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --border-color: #cbd5e1;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --primary: #1e3a8a; /* Deep Navy */
    --primary-hover: #1e40af;
    --secondary: #0d9488; /* Teal */
    --accent: #b91c1c; /* Corporate Dark Red */
    --success: #15803d; /* Forest Green */
    --font-outfit: 'Outfit', 'Inter', sans-serif;
    --font-inter: 'Inter', sans-serif;
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-inter);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Professional Card Panel */
.glass-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease-in-out;
}

.glass-panel:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
}

/* Layout */
.app-container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid #e2e8f0;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 2rem;
    color: var(--primary);
}

.logo-text {
    font-family: var(--font-outfit);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--primary);
}

.logo-badge {
    background-color: #e2e8f0;
    border: 1px solid #cbd5e1;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* Grid Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    height: calc(100vh - 180px);
    min-height: 600px;
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        height: auto;
        gap: 1.5rem;
    }
}

.panel-col {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background-color: #f8fafc;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.panel-title {
    font-family: var(--font-outfit);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.panel-body {
    flex: 1;
    padding: 1.5rem;
    overflow: hidden; /* Changed from overflow-y: auto to prevent the whole card panel from scrolling */
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Voice Recorder Controls */
.recorder-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    margin-bottom: 1.5rem;
}

.waveform-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 40px;
    width: 100%;
    margin-bottom: 1.25rem;
}

.wave-bar {
    width: 4px;
    height: 6px;
    background-color: var(--text-muted);
    border-radius: 2px;
    transition: height 0.1s ease;
}

/* Visualizer Active Animation */
.recording .wave-bar {
    background-color: var(--primary);
}

.record-btn-wrapper {
    position: relative;
}

.btn-record {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background-color: var(--primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(30, 58, 138, 0.2);
    transition: all 0.2s ease;
    z-index: 2;
}

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

.btn-record.active {
    background-color: var(--accent);
}

.status-badge {
    margin-top: 1rem;
    font-family: var(--font-outfit);
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-muted);
}

.recording .status-indicator {
    background-color: var(--accent);
    animation: blink 1s ease-in-out infinite alternate;
}

@keyframes blink {
    0% { opacity: 0.4; }
    100% { opacity: 1; }
}

.timer-counter {
    font-family: var(--font-outfit);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.05em;
    margin-top: 0.25rem;
}

/* Action controls */
.control-buttons {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.btn {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: #ffffff;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.15s ease;
}

.btn:hover:not(:disabled) {
    background: #f1f5f9;
    border-color: #94a3b8;
}

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

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

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

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

.btn-secondary:hover:not(:disabled) {
    background-color: #0f766e;
    border-color: #0f766e;
}

/* Transcript Area */
.textarea-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Changed from min-height: 200px to allow flex shrinking */
}

.transcript-textarea {
    flex: 1;
    width: 100%;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem;
    color: var(--text-primary);
    font-family: var(--font-inter);
    line-height: 1.6;
    resize: none;
    font-size: 0.95rem;
    transition: border-color 0.2s ease;
    overflow-y: auto; /* Explicitly allow internal scrolling */
}

.transcript-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

.textarea-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Dropdowns / Selectors */
.select-wrapper {
    position: relative;
    display: inline-block;
}

.select-custom {
    appearance: none;
    -webkit-appearance: none;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.4rem 2rem 0.4rem 0.75rem;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: var(--font-inter);
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s ease;
}

.select-custom:hover {
    border-color: #94a3b8;
}

.select-custom:focus {
    border-color: var(--primary);
}

.select-wrapper::after {
    content: '\f078';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.7rem;
    pointer-events: none;
}

/* Output Box */
.ai-output-box {
    flex: 1;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1.5rem;
    overflow-y: auto; /* Internal scrolling */
    font-family: var(--font-inter);
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--text-primary);
    position: relative;
    min-height: 0; /* Changed from min-height: 300px to allow flex shrinking within the panel */
    white-space: pre-wrap;
}

.ai-output-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-muted);
    width: 80%;
}

.ai-output-placeholder i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--text-muted);
}

/* Loading Animation Overlay */
.ai-loader {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 6px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1.5rem;
    z-index: 10;
}

.ai-loader.active {
    display: flex;
}

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

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

.loader-text {
    font-family: var(--font-outfit);
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
    text-align: center;
}

.loader-subtext {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    font-weight: 400;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.history-modal {
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    transition: color 0.15s ease;
}

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

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.history-item {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-item:hover {
    border-color: var(--primary);
    background: #f8fafc;
}

.history-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

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

.history-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.history-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon-danger {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.btn-icon-danger:hover {
    color: var(--accent);
    background: #fee2e2;
}

.no-history-text {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem 0;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: #0f172a;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 6px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.2s ease-out;
    pointer-events: none;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* Print */
@media print {
    body {
        background: white !important;
        color: black !important;
    }
    .app-container {
        padding: 0 !important;
    }
    header, .recorder-box, .textarea-container, .panel-header, .control-buttons, .select-wrapper, #generate-btn {
        display: none !important;
    }
    .dashboard-grid {
        display: block !important;
    }
    .glass-panel {
        border: none !important;
        background: transparent !important;
        box-shadow: none !important;
    }
    .ai-output-box {
        background: transparent !important;
        color: black !important;
        border: none !important;
        padding: 0 !important;
    }
}
