/* =================================
   Global Styles & Variables
   ================================= */
:root {
    --color-primary: #4f46e5; /* indigo-600 */
    --color-primary-hover: #4338ca; /* indigo-700 */
    --color-secondary: #16a34a; /* green-600 */
    --color-secondary-hover: #15803d; /* green-700 */
    --color-background: #f8fafc; /* slate-50 */
    --color-surface: #ffffff;
    --color-text-primary: #1e293b; /* slate-800 */
    --color-text-secondary: #475569; /* slate-600 */
    --color-border: #e2e8f0; /* slate-200 */
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --border-radius: 0.75rem; /* 12px */
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--color-background);
    color: var(--color-text-primary);
    margin: 0;
    padding: 2rem;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1600px; /* ensure px unit present */
    margin: 0 auto;
    padding-inline: 0.5rem;
}

h1 {
    font-size: 2.25rem; /* 36px */
    font-weight: 700;
    text-align: center;
    margin-bottom: 2.5rem;
}

h2 {
    font-size: 1.25rem; /* 20px */
    font-weight: 600;
    margin: 0;
}

/* =================================
   Card Component
   ================================= */
.card {
    background-color: var(--color-surface);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--color-border);
    margin-bottom: 2rem;
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.5rem;
    background-color: #f8fafc; /* slate-50 */
    border-bottom: 1px solid var(--color-border);
}

.card-body {
    padding: 1.5rem;
}

/* =================================
   Form & Button Components
   ================================= */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--color-text-secondary);
}

.file-input-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.file-input-label {
    display: inline-block;
    padding: 0.5rem 1rem;
    background-color: #eef2ff; /* indigo-50 */
    color: var(--color-primary);
    border-radius: 9999px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s ease;
}
.file-input-label:hover {
    background-color: #e0e7ff; /* indigo-100 */
}
.file-input-wrapper input[type="file"] {
    display: none;
}
.file-name {
    color: var(--color-text-secondary);
}

.button-group {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    text-decoration: none;
    white-space: nowrap;
}
.btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--color-primary-hover);
}

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

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

#uploadStatus {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 0.5rem;
    display: none; /* Initially hidden */
}
#uploadStatus.success { background-color: #dcfce7; color: #166534; }
#uploadStatus.error { background-color: #fee2e2; color: #991b1b; }
#uploadStatus.info { background-color: #dbeafe; color: #1e40af; }


/* =================================
   Table Component
   ================================= */
.table-container {
    margin-bottom: 2rem;
}

.table-filters {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 12px;
    border: 1px solid var(--color-border);
    align-items: end;
    flex-wrap: wrap;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 140px;
}

.filter-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.filter-input {
    padding: 0.75rem 1rem;
    border: 2px solid var(--color-border);
    border-radius: 8px;
    font-size: 0.875rem;
    background-color: white;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.filter-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1), 0 1px 2px 0 rgb(0 0 0 / 0.05);
    transform: translateY(-1px);
}

.filter-buttons {
    display: flex;
    gap: 0.75rem;
    margin-left: auto;
    align-items: center;
}

.btn-filter {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    box-shadow: 0 2px 4px 0 rgb(0 0 0 / 0.1);
    position: relative;
    overflow: hidden;
}

.btn-filter:before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.btn-filter:hover:before {
    left: 100%;
}

.btn-filter:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px 0 rgb(0 0 0 / 0.15);
}

.btn-filter:active {
    transform: translateY(-1px);
}

.btn-filter {
    background: linear-gradient(135deg, var(--color-primary) 0%, #6366f1 100%);
    color: white;
    border-color: var(--color-primary);
}

.btn-filter:hover {
    background: linear-gradient(135deg, var(--color-primary-hover) 0%, #5b21b6 100%);
}

.btn-clear {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    color: white;
    border-color: #6b7280;
}

.btn-clear:hover {
    background: linear-gradient(135deg, #4b5563 0%, #374151 100%);
}

.btn-export {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: white;
    border-color: #059669;
}

.btn-export:hover {
    background: linear-gradient(135deg, #047857 0%, #065f46 100%);
}

.table-wrapper {
    overflow-x: auto;
    border-radius: 0.5rem;
    border: 1px solid var(--color-border);
}

.table {
    width: 100%;
    border-collapse: collapse;
        min-width: 950px; /* expand baseline for new duration column */
        table-layout: auto;
}

/* Column sizing & wrapping */
.table td, .table th { word-break: break-word; }
.table th:nth-child(1), .table td:nth-child(1) { /* Call ID */
    white-space: nowrap; width: 110px;
}
.table th:nth-child(2), .table td:nth-child(2) { /* Duration */
    white-space: nowrap; width: 90px; text-align: center;
}
.table th:nth-child(3), .table td:nth-child(3) { /* File name */
    max-width: 360px;
}
.table th:nth-child(4), .table td:nth-child(4) { /* Language */
    min-width: 150px;
}
.table th:nth-child(5), .table td:nth-child(5) { /* Date */
    white-space: nowrap;
}
.table th:nth-child(6), .table td:nth-child(6) { /* Score */
    white-space: nowrap;
}
.table th:nth-child(7), .table td:nth-child(7) { /* Actions */
    white-space: nowrap;
}

@media (max-width: 1400px) {
    .container { max-width: 100%; }
    .table th:nth-child(3), .table td:nth-child(3) { max-width: 300px; }
}
@media (max-width: 1100px) {
    .table th:nth-child(3), .table td:nth-child(3) { max-width: 220px; }
    .table th:nth-child(4), .table td:nth-child(4) { min-width: 130px; }
}
@media (max-width: 900px) {
    .table th:nth-child(7), .table td:nth-child(7) { position: sticky; right: 0; background: #fff; }
    .table-wrapper { box-shadow: inset -8px 0 8px -8px rgba(0,0,0,0.08); }
}

.table th, .table td {
    padding: 1rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.table thead th {
    font-size: 0.75rem; /* 12px */
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background-color: #f8fafc; /* slate-50 */
}

.table tbody tr:hover {
    background-color: var(--color-background);
}

.table td {
    color: var(--color-text-secondary);
}

.table td:first-child {
    font-weight: 500;
    color: var(--color-text-primary);
}

.table .actions-cell {
    text-align: right;
    min-width: 150px;
}

.table .actions-cell .button-group {
    justify-content: flex-end;
    margin-top: 0;
    gap: 0.5rem;
}

.table .actions-cell .btn {
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    white-space: nowrap;
}

/* Pagination Component */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 12px;
    border: 1px solid var(--color-border);
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    flex-wrap: wrap;
    gap: 1rem;
}

.pagination-info {
    color: var(--color-text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    background-color: white;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.pagination {
    display: flex;
    gap: 0.25rem;
    align-items: center;
    background-color: white;
    padding: 0.5rem;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.pagination-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.75rem;
    border: 2px solid transparent;
    background-color: transparent;
    color: var(--color-text-secondary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    min-width: 40px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.pagination-btn:before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(79, 70, 229, 0.1), transparent);
    transition: left 0.3s;
}

.pagination-btn:hover:not(:disabled):before {
    left: 100%;
}

.pagination-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-color: var(--color-primary);
    color: var(--color-primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px 0 rgb(0 0 0 / 0.1);
}

.pagination-btn.active {
    background: linear-gradient(135deg, var(--color-primary) 0%, #6366f1 100%);
    color: white;
    border-color: var(--color-primary);
    box-shadow: 0 2px 8px 0 rgba(79, 70, 229, 0.3);
    transform: translateY(-1px);
}

.pagination-btn.active:hover {
    background: linear-gradient(135deg, var(--color-primary-hover) 0%, #5b21b6 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px 0 rgba(79, 70, 229, 0.4);
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background-color: #f1f5f9;
    color: #94a3b8;
    border-color: transparent;
}

.pagination-btn:disabled:hover {
    transform: none;
    box-shadow: none;
}

.page-size-selector {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-primary);
    background-color: white;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.page-size-selector select {
    padding: 0.5rem 0.75rem;
    border: 2px solid var(--color-border);
    border-radius: 6px;
    background-color: white;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.page-size-selector select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1), 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.page-size-selector select:hover {
    border-color: var(--color-primary);
}

.pagination-ellipsis {
    padding: 0.5rem;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}


/* =================================
   Modal Component
   ================================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.7); /* slate-900 with opacity */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-content {
    background-color: var(--color-surface);
    border-radius: var(--border-radius);
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    width: 90%;
    max-width: 1000px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
}
.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
}
.modal-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-secondary);
    padding: 0.5rem;
}
.modal-close-btn:hover {
    color: var(--color-text-primary);
}
.modal-close-btn svg {
    width: 1.5rem;
    height: 1.5rem;
}
.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    overflow-x: hidden;
}
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-border);
    background-color: #f8fafc;
    text-align: right;
}
.modal-footer .btn {
    background-color: var(--color-surface);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
}
.modal-footer .btn:hover {
    background-color: var(--color-background);
}

/* =================================
   Scorecard Modal Styles
   ================================= */
.scorecard {
    padding: 0.5rem;
}
.scorecard-section {
    margin-bottom: 2.5rem;
}
.scorecard-section:last-child {
    margin-bottom: 0;
}
.scorecard-section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border);
}
.scorecard-subsection {
    margin-bottom: 1.5rem;
}
.scorecard-item {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #e0e0e0;
}
.scorecard-item:last-child {
    border-bottom: none;
}
.scorecard-reasoning {
    padding: 8px 12px;
    background-color: #f0f0f0;
    border-radius: 4px;
    margin-top: -5px;
    margin-bottom: 10px;
    font-size: 0.9em;
    color: #555;
    border-left: 3px solid #007bff;
}
.subsection-header .item-label {
    font-weight: 600;
    color: #334155; /* slate-700 */
}
.item-label {
    font-weight: 500;
    color: #333;
}
.item-value {
    font-weight: 500;
    color: var(--color-text-primary);
    text-align: right;
}
.item-value.yes {
    color: #16a34a; /* green-600 */
}
.item-value.no {
    color: #dc2626; /* red-600 */
}
.item-value .icon {
    font-size: 0.875rem;
    margin-right: 0.35rem;
}
.summary-item {
    flex-direction: column;
    align-items: flex-start;
}
.summary-box {
    width: 100%;
    margin-top: 0.5rem;
    padding: 1rem;
    background-color: #f8fafc; /* slate-50 */
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    color: #334155; /* slate-700 */
    font-size: 0.9rem;
    line-height: 1.6;
}

/* Transcript Preformatting */
.transcript-pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    background-color: #f8fafc;
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--color-border);
    max-height: 60vh;
    overflow-y: auto;
}

/* =================================
   Language Badges
   ================================= */
.lang-cell {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.lang-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border-radius: 0.375rem;
    line-height: 1;
    background: #e2e8f0;
    color: #334155;
    border: 1px solid #cbd5e1;
}

.lang-badge.effective {
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    color: #fff;
    border: 1px solid #4338ca;
}

.lang-badge.mismatch {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: #fff;
    border: 1px solid #991b1b;
}

.lang-badge.confidence {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    color: #fff;
    border: 1px solid #166534;
}

.lang-badge[title] {
    cursor: help;
}