/* 1. Import Noto Sans for English, Malayalam, and Hindi */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Devanagari:wght@400;600&family=Noto+Sans+Malayalam:wght@400;600&family=Noto+Sans:wght@400;600&display=swap');

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

body {
    /* Updated Font Stack for all scripts */
    font-family: 'Noto Sans', 'Noto Sans Malayalam', 'Noto Sans Devanagari', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

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

/* 3. Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

h1 {
    font-size: 28px;
    font-weight: 600;
    color: #2c3e50;
}

.user-info {
    color: #7f8c8d;
    font-size: 14px;
}

/* 4. Buttons */
.btn-primary, .btn-secondary, .btn-back, .btn-annotate {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    transition: all 0.2s;
}

.btn-primary { background-color: #3498db; color: white; }
.btn-primary:hover { background-color: #2980b9; }

.btn-secondary { background-color: #95a5a6; color: white; }
.btn-secondary:hover { background-color: #7f8c8d; }

.btn-back { background-color: #ecf0f1; color: #2c3e50; }
.btn-back:hover { background-color: #d5dbdb; }

.btn-annotate { background-color: #27ae60; color: white; padding: 8px 16px; font-size: 13px; }
.btn-annotate:hover { background-color: #229954; }

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

.login-box {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
}

.login-box h1 { margin-bottom: 10px; text-align: center; }
.login-box p { text-align: center; color: #7f8c8d; margin-bottom: 30px; }

.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 500; color: #2c3e50; }
.form-group input { width: 100%; padding: 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; }
.form-group input:focus { outline: none; border-color: #3498db; }

.login-box .btn-primary { width: 100%; padding: 14px; font-size: 16px; margin-top: 10px; }
.error { background-color: #e74c3c; color: white; padding: 12px; border-radius: 6px; margin-bottom: 20px; text-align: center; }

/* 6. Tasks Table */
.tasks-table {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    overflow: hidden;
}

table { width: 100%; border-collapse: collapse; }
thead { background-color: #34495e; color: white; }
thead th { padding: 15px; text-align: left; font-weight: 600; font-size: 14px; }
tbody tr { border-bottom: 1px solid #ecf0f1; }
tbody tr:hover { background-color: #f8f9fa; }
tbody td { padding: 15px; font-size: 14px; }

.status-badge { padding: 4px 12px; border-radius: 12px; font-size: 12px; font-weight: 500; text-transform: uppercase; }
.status-badge.completed { background-color: #d5f4e6; color: #27ae60; }
.status-badge.pending { background-color: #fff3cd; color: #f39c12; }

/* 7. Annotation Page */
.annotation-container { background: white; border-radius: 8px; padding: 30px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.metadata-section { margin-bottom: 30px; padding-bottom: 20px; border-bottom: 1px solid #ecf0f1; }
.metadata-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 15px; margin-top: 15px; }
.metadata-item { display: flex; gap: 10px; }
.metadata-item.full-width { grid-column: 1 / -1; flex-direction: column; }
.metadata-item .label { font-weight: 600; color: #7f8c8d; min-width: 100px; }
.metadata-item .value { color: #2c3e50; }

.task-type-segment { color: #3498db; font-weight: 600; }
.task-type-full_audio { color: #e74c3c; font-weight: 600; }

/*High z-index to stay above the scrolling table rows */
.audio-section { margin-bottom: 30px; position: sticky; top: 0; z-index: 50;}
#audio-player { width: 100%; max-width: 800px; margin-top: 15px; }

/* 8. Download Protection (Hidden for non-authorized users) */
/* This is controlled via annotate.html injection, but base rules are here */
audio::-internal-media-controls-download-button { display: none; }
audio::-webkit-media-controls-enclosure { overflow: hidden; }

/* 9. Form Sections and Indic Text Support */
.form-section { margin-bottom: 30px; }
.form-section h2 { font-size: 18px; margin-bottom: 10px; color: #2c3e50; }

textarea, select, .editable-cell {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    /* Explicitly use Noto stack for form elements as they don't always inherit from body */
    font-family: 'Noto Sans', 'Noto Sans Malayalam', 'Noto Sans Devanagari', sans-serif;
    resize: vertical;
}

#timestamp-segments {
    font-family: 'Monaco', 'Courier New', 'Noto Sans Malayalam', 'Noto Sans Devanagari', monospace;
    font-size: 13px;
}

/* 10. Timestamps Table */
.timestamps-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    background-color: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 10px;
}

.timestamps-table th { padding: 12px 10px; text-align: left; position: sticky; top: 0; z-index: 10; font-weight: 600; color: #ffffff; font-size: 14px; background-color: #34495e;}
.timestamps-table td { 
    padding: 10px; 
    vertical-align: top; 
    font-size: 14px; 
    line-height: 1.5;
    font-family: 'Noto Sans', 'Noto Sans Malayalam', 'Noto Sans Devanagari', sans-serif;
}

.timestamps-table th:nth-child(1) { width: 45px; text-align: center; } /* Seg # */
.timestamps-table th:nth-child(2),
.timestamps-table th:nth-child(3) { width: 80px; text-align: center; } /* Start / End */
.timestamps-table th:nth-child(6) { width: 50px; text-align: center; } /* Actions */

#timestamps-table-container { max-height: 500px; overflow-y: auto; border: 1px solid #dee2e6; border-radius: 4px; }

/* Audio Hours Statistics */
.audio-hours-stats {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.audio-hours-stats h3 {
    font-size: 18px;
    color: #2c3e50;
    margin-bottom: 15px;
    font-weight: 600;
}

.hours-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.project-hours {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 15px;
    background-color: #f8f9fa;
}

.project-hours-header {
    font-weight: 600;
    font-size: 16px;
    color: #34495e;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #3498db;
}

.hours-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 14px;
}

.hours-label {
    color: #7f8c8d;
    font-weight: 500;
}

.hours-value {
    font-weight: 600;
    color: #2c3e50;
}

.hours-value.completed {
    color: #27ae60;
}

.hours-value.pending {
    color: #f39c12;
}

/* 11. Waveform + Acoustic Tags */
.waveform-section {
    /* position: sticky; */
    /* top: 0; */
    /* z-index: 50; */
    background: white;
    padding: 15px 0 10px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-radius: 8px;
    padding: 20px;
}

#waveform {
    min-height: 160px;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 10px;
    cursor: crosshair;
}

.waveform-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
}

.playback-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.waveform-time {
    font-size: 13px;
    color: #7f8c8d;
    font-family: 'Monaco', 'Courier New', monospace;
}

.playback-speed {
    display: flex;
    gap: 2px;
}

.speed-btn {
    padding: 4px 8px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    color: #7f8c8d;
    transition: all 0.2s;
}

.speed-btn:hover { background: #f0f0f0; }
.speed-btn.active { background: #3498db; color: white; border-color: #3498db; }

.tag-palette {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.tag-palette-label {
    font-size: 13px;
    font-weight: 600;
    color: #7f8c8d;
}

.tag-palette-hint {
    font-size: 12px;
    color: #95a5a6;
    font-style: italic;
}

.lid-custom {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.tag-btn {
    width: 32px;
    height: 32px;
    border: 2px solid var(--tag-color);
    background: white;
    color: var(--tag-color);
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tag-btn.tag-btn-pill {
    width: auto;
    height: auto;
    padding: 5px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.tag-btn:hover { background: var(--tag-color); color: white; }
.tag-btn.active { background: var(--tag-color); color: white; box-shadow: 0 0 0 3px rgba(0,0,0,0.15); }

.acoustic-tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 30px;
    max-height: 300px;
    overflow-y: auto;
    padding: 8px 0;
    border: 1px solid #eee;
    border-radius: 4px;
}

.acoustic-tags-empty {
    font-size: 13px;
    color: #95a5a6;
    font-style: italic;
}

.acoustic-tag-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: #f8f9fa;
    border-left: 3px solid var(--tag-border-color, #ccc);
    border-radius: 0 4px 4px 0;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s;
}

.acoustic-tag-item:hover { background: #ecf0f1; }

.acoustic-tag-label {
    font-weight: 700;
    color: #2c3e50;
}

.acoustic-tag-time {
    font-family: 'Monaco', 'Courier New', monospace;
    color: #7f8c8d;
}

.acoustic-tag-name {
    color: #95a5a6;
}

.acoustic-tag-delete {
    background: none;
    border: none;
    color: #e74c3c;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    padding: 0 2px;
    line-height: 1;
    opacity: 0.5;
    transition: opacity 0.15s;
}

.acoustic-tag-delete:hover { opacity: 1; }

.tag-palette-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.mark-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
}

.btn-mark {
    padding: 8px 18px;
    border: 2px solid #3498db;
    background: white;
    color: #3498db;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-mark:hover:not(:disabled) { background: #3498db; color: white; }
.btn-mark:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-mark.marking {
    background: #e74c3c;
    border-color: #e74c3c;
    color: white;
    animation: pulse-mark 1s ease-in-out infinite;
}

@keyframes pulse-mark {
    0%, 100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(231, 76, 60, 0); }
}

.mark-status {
    font-size: 13px;
    font-weight: 600;
    color: #e74c3c;
    font-family: 'Monaco', 'Courier New', monospace;
}

.mark-controls kbd {
    display: inline-block;
    padding: 2px 6px;
    background: #ecf0f1;
    border: 1px solid #bdc3c7;
    border-radius: 3px;
    font-size: 11px;
    font-family: 'Monaco', 'Courier New', monospace;
}

.phase-header {
    font-size: 16px;
    color: #2c3e50;
    font-weight: 600;
    margin-bottom: 10px;
}

/* Active timestamp row highlight (synced with waveform playback) */
.timestamp-row-active {
    background-color: #ebf5fb !important;
    transition: background-color 0.2s;
}

/* 12. Responsive Design */
@media (max-width: 768px) {
    header { flex-direction: column; align-items: flex-start; gap: 15px; }
    .stats-bar { flex-direction: column; }
    .action-bar { flex-direction: column; gap: 15px; }
    .hours-grid { grid-template-columns: 1fr; }
}
