@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f0f2f7;
    min-height: 100vh;
    color: #1a1a2e;
}

.dashboard-container {
    min-height: 100vh;
}

/* ==================== Header ==================== */

.dashboard-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 16px 20px;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.25);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dashboard-header h1 {
    color: white;
    font-size: 1.5em;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-info span {
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9em;
}

.btn-logout {
    padding: 7px 18px;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ==================== Main Content ==================== */

.dashboard-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px;
}

.welcome-card {
    background: white;
    border-radius: 12px;
    padding: 24px 28px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid #e5e7eb;
}

.welcome-card h2 {
    color: #667eea;
    margin-bottom: 6px;
    font-size: 1.25em;
    font-weight: 700;
}

.welcome-card p {
    color: #6b7280;
    font-size: 0.9em;
}

/* ==================== Action Cards ==================== */

.actions-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.action-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid #e5e7eb;
}

.action-card:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.action-icon {
    font-size: 2.5em;
    margin-bottom: 12px;
}

.action-card h3 {
    color: #1a1a2e;
    margin-bottom: 6px;
    font-size: 1em;
    font-weight: 600;
}

.action-card p {
    color: #6b7280;
    font-size: 0.85em;
}

/* ==================== Stats Grid ==================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid #e5e7eb;
    transition: box-shadow 0.2s ease;
}

.stat-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.stat-card:nth-child(1) { border-left: 4px solid #667eea; }
.stat-card:nth-child(2) { border-left: 4px solid #764ba2; }
.stat-card:nth-child(3) { border-left: 4px solid #11998e; }
.stat-card:nth-child(4) { border-left: 4px solid #4caf50; }

.stat-icon {
    font-size: 2em;
}

.stat-content h3 {
    font-size: 1.75em;
    color: #1a1a2e;
    margin-bottom: 2px;
    font-weight: 700;
}

.stat-content p {
    color: #6b7280;
    font-size: 0.85em;
}

/* ==================== Tabs ==================== */

.admin-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 0;
    border-bottom: 2px solid #e5e7eb;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.admin-tabs::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #6b7280;
    font-size: 0.88em;
    white-space: nowrap;
    margin-bottom: -2px;
}

.tab-btn:hover {
    color: #667eea;
    border-bottom-color: rgba(102, 126, 234, 0.3);
}

.tab-btn.active {
    background: transparent;
    color: #667eea;
    border-bottom-color: #667eea;
    font-weight: 600;
}

.tab-content {
    background: white;
    border-radius: 0 0 12px 12px;
    padding: 28px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    border: 1px solid #e5e7eb;
    border-top: none;
    margin-bottom: 24px;
}

.tab-content h2 {
    color: #1a1a2e;
    margin-bottom: 16px;
    font-size: 1.15em;
    font-weight: 700;
}

/* ==================== Data Tables ==================== */

.data-table {
    overflow-x: auto;
}

.data-table table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
}

.data-table th {
    background: #f8f9fc;
    font-weight: 600;
    color: #4a5568;
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.data-table th:first-child {
    border-radius: 8px 0 0 0;
}

.data-table th:last-child {
    border-radius: 0 8px 0 0;
}

.data-table td {
    font-size: 0.9em;
    vertical-align: middle;
}

.data-table tr:hover td {
    background: #f7f8fc;
}

.data-table tr:last-child td {
    border-bottom: none;
}

/* ==================== Badges ==================== */

.role-badge {
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.8em;
    font-weight: 600;
}

.role-badge.role-user {
    background: #e8f0fe;
    color: #1a73e8;
}

.role-badge.role-admin {
    background: #fce8ec;
    color: #c2185b;
}

.role-badge.role-researcher {
    background: #fff3e0;
    color: #e65100;
}

/* Role select dropdown (admin user table) */
.role-select {
    appearance: none;
    -webkit-appearance: none;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 4px 28px 4px 10px;
    font-size: 0.82em;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}
.role-select:hover { border-color: #667eea; }
.role-select:focus { border-color: #667eea; box-shadow: 0 0 0 3px rgba(102,126,234,0.15); }
.role-select:disabled { opacity: 0.5; cursor: wait; }

.role-select.role-user {
    background-color: #e8f0fe;
    color: #1a73e8;
    border-color: #c5d7f7;
}
.role-select.role-researcher {
    background-color: #fff3e0;
    color: #e65100;
    border-color: #ffe0b2;
}
.role-select.role-admin {
    background-color: #fce8ec;
    color: #c2185b;
    border-color: #f8bbd0;
}

/* ==================== Buttons ==================== */

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: #667eea;
    color: white;
    box-shadow: 0 1px 2px rgba(102, 126, 234, 0.2);
}

.btn-primary:hover {
    background: #5a6fd6;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: white;
    color: #667eea;
    border: 1.5px solid #d1d5db;
}

.btn-secondary:hover {
    background: #f8f9fc;
    border-color: #667eea;
}

.btn-small {
    padding: 5px 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-small:hover {
    background: #5568d3;
}

.btn-view {
    padding: 7px 16px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85em;
    transition: all 0.2s ease;
}

.btn-view:hover {
    background: #5568d3;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

/* ==================== Settings ==================== */

.settings-panel {
    display: grid;
    gap: 12px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: #f8f9fc;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.setting-item label {
    font-weight: 600;
    color: #374151;
    font-size: 0.9em;
}

.setting-item span {
    color: #667eea;
    font-weight: 600;
    font-size: 0.9em;
}

/* ==================== History / Profile Sections ==================== */

.history-section,
.profile-section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin-top: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid #e5e7eb;
}

.history-section h2,
.profile-section h2 {
    color: #1a1a2e;
    margin-bottom: 16px;
    font-size: 1.15em;
    font-weight: 700;
}

.history-list {
    display: grid;
    gap: 10px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: #f8f9fc;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.history-info strong {
    display: block;
    color: #1a1a2e;
    margin-bottom: 4px;
}

.history-info small {
    color: #6b7280;
}

.profile-card {
    display: grid;
    gap: 10px;
}

.profile-item {
    display: flex;
    justify-content: space-between;
    padding: 14px 16px;
    background: #f8f9fc;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.profile-item strong {
    color: #374151;
}

.profile-item span {
    color: #667eea;
    font-weight: 600;
}

.hidden {
    display: none;
}

/* ==================== RTL Support ==================== */

html[dir="rtl"] body,
body.rtl {
    direction: rtl;
    text-align: right;
}

html[dir="rtl"] .header-content,
body.rtl .header-content {
    flex-direction: row-reverse;
}

html[dir="rtl"] .user-info,
body.rtl .user-info {
    flex-direction: row-reverse;
}

html[dir="rtl"] .stat-card,
body.rtl .stat-card {
    flex-direction: row-reverse;
}

html[dir="rtl"] .stat-card:nth-child(1),
body.rtl .stat-card:nth-child(1) { border-left: none; border-right: 4px solid #667eea; }
html[dir="rtl"] .stat-card:nth-child(2),
body.rtl .stat-card:nth-child(2) { border-left: none; border-right: 4px solid #764ba2; }
html[dir="rtl"] .stat-card:nth-child(3),
body.rtl .stat-card:nth-child(3) { border-left: none; border-right: 4px solid #11998e; }
html[dir="rtl"] .stat-card:nth-child(4),
body.rtl .stat-card:nth-child(4) { border-left: none; border-right: 4px solid #4caf50; }

html[dir="rtl"] .data-table th,
html[dir="rtl"] .data-table td,
body.rtl .data-table th,
body.rtl .data-table td {
    text-align: right;
}

html[dir="rtl"] .admin-tabs,
body.rtl .admin-tabs {
    flex-direction: row-reverse;
}

html[dir="rtl"] .modal-header,
body.rtl .modal-header {
    flex-direction: row-reverse;
}

html[dir="rtl"] .modal-actions,
body.rtl .modal-actions {
    flex-direction: row-reverse;
}

html[dir="rtl"] .form-group label,
body.rtl .form-group label {
    text-align: right;
}

html[dir="rtl"] .setting-item,
body.rtl .setting-item {
    flex-direction: row-reverse;
}

html[dir="rtl"] .profile-item,
body.rtl .profile-item {
    flex-direction: row-reverse;
}

html[dir="rtl"] .history-item,
body.rtl .history-item {
    flex-direction: row-reverse;
}

html[dir="rtl"] .btn-small,
body.rtl .btn-small {
    margin-left: 5px;
    margin-right: 0;
}

html[dir="rtl"] .response-choices,
body.rtl .response-choices {
    margin-right: 20px;
    margin-left: 0;
}

html[dir="rtl"] .response-header,
body.rtl .response-header {
    flex-direction: row-reverse;
}

html[dir="rtl"] .session-info-grid,
body.rtl .session-info-grid {
    direction: rtl;
}

html[dir="rtl"] .user-checkbox input,
body.rtl .user-checkbox input {
    margin-left: 10px;
    margin-right: 0;
}

html[dir="rtl"] .tabs-inner,
body.rtl .tabs-inner {
    flex-direction: row-reverse;
}

html[dir="rtl"] .filter-controls,
body.rtl .filter-controls {
    direction: rtl;
}

/* ==================== Utility Classes ==================== */

.flex-row {
    display: flex;
    flex-direction: row;
}

.flex-row-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flex-row-center {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.flex-wrap {
    flex-wrap: wrap;
}

.gap-15 { gap: 15px; }
.gap-10 { gap: 10px; }
.mb-20 { margin-bottom: 20px; }
.mb-15 { margin-bottom: 15px; }
.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.p-15 { padding: 15px; }
.p-10 { padding: 10px; }

.bg-filter {
    background: #f8f9fc;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.bg-feedback {
    padding: 10px;
    background: #ecfdf5;
    border-radius: 6px;
    font-size: 0.9em;
}

.text-sm { font-size: 0.9em; }
.text-xs { font-size: 0.85em; }
.text-muted { color: #6b7280; }

.text-label {
    font-weight: 600;
    margin-right: 8px;
    font-size: 0.85em;
}

html[dir="rtl"] .text-label,
body.rtl .text-label {
    margin-right: 0;
    margin-left: 8px;
}

.scrollable-list {
    max-height: 300px;
    overflow-y: auto;
}

.scrollable-question-bank {
    max-height: 400px;
    overflow-y: auto;
}

.pre-json {
    background: #f8f9fc;
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.85em;
    max-height: 400px;
    border: 1px solid #e5e7eb;
}

.modal-wide {
    max-width: 900px;
}

.input-filter {
    padding: 7px 12px;
    border: 1.5px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.88em;
    transition: border-color 0.2s;
}

.input-filter:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.pagination-info {
    padding: 8px 16px;
}

.question-bank-item {
    padding: 10px;
    border-bottom: 1px solid #f0f0f0;
}

/* ==================== Pre-defined Interviews ==================== */

.predefined-section {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    border: 1px solid #e5e7eb;
}

.section-divider {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 24px 0;
}

.category-group {
    background: #f8f9fc;
    border-radius: 10px;
    padding: 16px;
    border-left: 4px solid #667eea;
}

.category-header {
    color: #1a1a2e;
    font-size: 1em;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.category-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    font-weight: bold;
    color: white;
    font-size: 0.85em;
}

.category-A { background: linear-gradient(135deg, #667eea, #764ba2); }
.category-B { background: linear-gradient(135deg, #11998e, #38ef7d); }
.category-C { background: linear-gradient(135deg, #f093fb, #f5576c); }
.category-D { background: linear-gradient(135deg, #4facfe, #00f2fe); }
.category-E { background: linear-gradient(135deg, #fa709a, #fee140); }

.config-id {
    background: #e8f0fe;
    color: #1a73e8;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.82em;
    font-weight: 500;
}

.focus-text {
    color: #4a5568;
    line-height: 1.5;
    font-size: 0.9em;
}

.actions-cell {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
}

.btn-group {
    display: flex;
    gap: 6px;
}

.table-sm {
    font-size: 0.88em;
}

.table-sm th,
.table-sm td {
    padding: 10px 12px;
}

.empty-state {
    text-align: center;
    padding: 48px 24px;
    background: #fafbfc;
    border-radius: 12px;
    border: 2px dashed #d1d5db;
    color: #6b7280;
}

.text-error {
    color: #d32f2f;
}

.form-row {
    display: flex;
    gap: 16px;
}

.input-with-button {
    display: flex;
    gap: 8px;
}

.input-with-button input {
    flex: 1;
}

.readonly-field {
    min-height: 60px;
    line-height: 1.5;
}

/* ==================== Responsive ==================== */

@media (max-width: 1024px) {
    .dashboard-main { padding: 20px 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .admin-tabs { overflow-x: auto; }
}

@media (max-width: 640px) {
    .header-content { flex-direction: column; gap: 12px; text-align: center; }
    .user-info { flex-wrap: wrap; justify-content: center; }
    .dashboard-header h1 { font-size: 1.25em; }
    .stats-grid { grid-template-columns: 1fr; }
    .tab-btn { padding: 10px 14px; font-size: 0.82em; }
    .tab-content { padding: 16px; }
    .welcome-card { padding: 16px; }
    .data-table table { min-width: 600px; }
    .flex-row-between { flex-direction: column; gap: 12px; align-items: flex-start; }
    .actions-section { grid-template-columns: 1fr; }
}
