/**
 * Brain Assessment Suite - Frontend Styles
 * Unified styles for test grid and shared components
 */

/* ========== Test Suite Container ========== */
.bas-test-suite {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background: #f5f7fa;
    color: #1e293b;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ========== Welcome Section ========== */
.bas-welcome {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px 20px;
    background: linear-gradient(135deg, #ffffff 0%, #ffffff 100%);
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.bas-title {
    font-size: 2.5em;
    margin: 0 0 10px;
    color: #2563eb!important;
    font-weight: 700;
}

.bas-description {
    font-size: 1.1em;
    color: #64748b!important;
    margin: 0;
    line-height: 1.6;
}

.bas-user-greeting {
    margin-top: 15px;
    padding: 10px 20px;
    background: rgba(37, 99, 235, 0.1);
    border-radius: 8px;
    display: inline-block;
}

.bas-user-greeting strong {
    color: #1e293b !important;
}

.bas-user-role {
    color: #2563eb;
    font-weight: 700!important;
    font-size: 0.9em;
}

/* ========== Test Grid ========== */
.bas-test-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

@media (max-width: 768px) {
    .bas-test-grid {
        grid-template-columns: 1fr;
    }
}

/* ========== Test Cards ========== */
.bas-test-card {
    background: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 30px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.bas-test-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #2563eb, #3b82f6);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.bas-test-card:hover {
    border-color: #2563eb;
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.2);
}

.bas-test-card:hover::before {
    opacity: 1;
}

/* ========== Test Icon ========== */
.bas-test-icon {
    font-size: 3em;
    margin-bottom: 15px;
    text-align: center;
    line-height: 1;
}

/* ========== Test Content ========== */
.bas-test-title {
    font-size: 1.4em;
    margin: 0 0 12px;
    color: #1e293b!important;
    font-weight: 600;
    text-align: center;
}

.bas-test-desc {
    font-size: 0.95em;
    color: #64748b;
    line-height: 1.6;
    margin: 0 0 20px;
    text-align: center;
    min-height: 48px;
}

/* ========== Test Meta ========== */
.bas-test-meta {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
    padding: 12px 0;
    border-top: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
}

.bas-test-questions,
.bas-test-time {
    font-size: 0.9em;
    color: #888888;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ========== Start Button ========== */
.bas-start-test {
    width: 100%;
    padding: 14px 28px;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.bas-start-test:hover {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

.bas-start-test:active {
    transform: translateY(0);
}

/* ========== Test Container ========== */
.bas-test-container {
    background: #f5f7fa;
    padding: 20px;
    border-radius: 12px;
    min-height: 500px;
}

/* ========== Back Button ========== */
.bas-back-to-tests {
    display: inline-block;
    padding: 10px 20px;
    background: #e2e8f0;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.95em;
}

.bas-back-to-tests:hover {
    background: #2563eb;
    border-color: #2563eb;
}

/* ========== Error Message ========== */
.bas-error-message {
    padding: 40px;
    text-align: center;
    color: #e74c3c;
    background: #ffffff;
    border-radius: 12px;
    border: 2px solid #e74c3c;
}

.bas-error-message h3 {
    margin-top: 0;
    font-size: 1.8em;
}

.bas-error-message p {
    font-size: 1.1em;
    margin: 15px 0;
}

/* ========== Responsive Design ========== */
@media (max-width: 768px) {
    .bas-test-suite {
        padding: 15px;
    }

    .bas-title {
        font-size: 2em;
    }

    .bas-test-card {
        padding: 20px;
    }

    .bas-test-icon {
        font-size: 2.5em;
    }

    .bas-test-title {
        font-size: 1.2em;
    }

    .bas-test-meta {
        flex-direction: column;
        gap: 8px;
        align-items: center;
    }
}

/* ========== Loading State ========== */
.bas-loading {
    text-align: center;
    padding: 40px;
    color: #888888;
}

.bas-loading::after {
    content: '...';
    animation: loading-dots 1.5s infinite;
}

@keyframes loading-dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* ========== Common Test Styles ========== */
.test-instructions {
    background: #ffffff;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #2563eb;
}

.test-instructions h3 {
    margin-top: 0;
    color: #2563eb;
}

.test-instructions ul {
    margin: 10px 0;
    padding-left: 25px;
}

.test-instructions li {
    margin: 8px 0;
    color: #64748b;
    line-height: 1.6;
}

/* Button styles for individual tests */
.btn,
.btn-primary {
    padding: 12px 24px;
    background: #2563eb;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn:hover,
.btn-primary:hover {
    background: #3b82f6;
    transform: translateY(-2px);
}

/* Progress indicators */
.progress-bar {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    margin: 10px 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #2563eb, #3b82f6);
    transition: width 0.3s ease;
}


/* ========== Responsive tables (User dashboard widget) ========== */
.bas-table-scroll{width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;}
.bas-table-scroll .bas-results-table{width:100%;border-collapse:separate;border-spacing:0;min-width:720px;}
.bas-table-scroll .bas-results-table th,.bas-table-scroll .bas-results-table td{padding:12px 10px;vertical-align:middle;}
.bas-table-scroll .bas-results-table th{white-space:nowrap;}
.bas-table-scroll .bas-results-table td{word-break:break-word;}
.bas-table-scroll .bas-results-table td.bas-col-date{white-space:nowrap;}

@media (max-width:768px){
  .bas-table-scroll .bas-results-table{min-width:820px;}
}


/* Sticky columns (checkbox, Date & Time, Test Type) inside horizontal scroll */
.bas-table-scroll{position:relative;}
.bas-table-scroll .bas-results-table{
  --bas-sticky-check: 52px;
  --bas-sticky-date: 190px;
}

/* Base backgrounds for sticky */
.bas-table-scroll .bas-results-table th,
.bas-table-scroll .bas-results-table td{background:#ffffff;}

/* Sticky checkbox column */
.bas-table-scroll .bas-results-table th.bas-sticky-check,
.bas-table-scroll .bas-results-table td.bas-sticky-check{
  position: sticky;
  left: 0;
  z-index: 6;
  min-width: var(--bas-sticky-check);
  width: var(--bas-sticky-check);
  text-align: center;
}

/* Sticky Date column */
.bas-table-scroll .bas-results-table th.bas-sticky-date,
.bas-table-scroll .bas-results-table td.bas-sticky-date{
  position: sticky;
  left: var(--bas-sticky-check);
  z-index: 5;
  min-width: var(--bas-sticky-date);
  white-space: nowrap;
}

/* Sticky Test Type column */
.bas-table-scroll .bas-results-table th.bas-sticky-type,
.bas-table-scroll .bas-results-table td.bas-sticky-type{
  position: sticky;
  left: calc(var(--bas-sticky-check) + var(--bas-sticky-date));
  z-index: 4;
  min-width: 170px;
  white-space: nowrap;
  box-shadow: 6px 0 10px rgba(15, 23, 42, 0.06);
}

/* Keep header above body + slightly different background */
.bas-table-scroll .bas-results-table thead th{
  background:#f7f7f7;
  z-index: 10;
}

/* Mobile: hide checkbox column to save space */
@media (max-width:768px){
  .bas-table-scroll .bas-results-table th.bas-sticky-check,
  .bas-table-scroll .bas-results-table td.bas-sticky-check{
    display:none;
  }
  .bas-table-scroll .bas-results-table{
    --bas-sticky-check: 0px;
  }
}



/* ===== JS Sticky Columns Fallback (iOS/table-cell sticky issues) ===== */
.bas-table-scroll{position:relative;}
.bas-table-scroll.bas-js-sticky-active .bas-results-table th.bas-sticky-date,
.bas-table-scroll.bas-js-sticky-active .bas-results-table td.bas-sticky-date,
.bas-table-scroll.bas-js-sticky-active .bas-results-table th.bas-sticky-type,
.bas-table-scroll.bas-js-sticky-active .bas-results-table td.bas-sticky-type{
  visibility:hidden; /* hide original; overlay will display */
}

.bas-sticky-overlay{
  position:absolute;
  top:0;
  left:0;
  z-index:25;
  pointer-events:none;
  background:transparent;
}

.bas-sticky-overlay table{
  border-collapse:separate;
  border-spacing:0;
}

.bas-sticky-overlay th,
.bas-sticky-overlay td{
  background:#ffffff;
  padding:12px 10px;
  vertical-align:middle;
  white-space:nowrap;
}

.bas-sticky-overlay thead th{
  background:#f7f7f7;
}

.bas-sticky-overlay{
  box-shadow: 6px 0 10px rgba(15, 23, 42, 0.06);
  border-right:1px solid rgba(15, 23, 42, 0.06);
}


/* ===== Split table (fixed first columns + horizontal scroll for the rest) ===== */
.bas-table-split .bas-split-wrap{
  display:flex;
  width:100%;
  align-items:stretch;
}

.bas-table-split .bas-split-fixed{
  flex:0 0 auto;
  background:#ffffff;
  border-right:1px solid rgba(15, 23, 42, 0.06);
  box-shadow: 6px 0 10px rgba(15, 23, 42, 0.06);
}

.bas-table-split .bas-split-scroll{
  flex:1 1 auto;
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
}

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

.bas-table-split th,
.bas-table-split td{
  padding:12px 10px;
  vertical-align:middle;
}

.bas-table-split thead th{
  background:#f7f7f7;
  white-space:nowrap;
}

.bas-table-split .bas-split-fixed table{
  width:auto;
}

.bas-table-split .bas-split-fixed th,
.bas-table-split .bas-split-fixed td{
  white-space:nowrap;
}

.bas-table-split .bas-split-fixed td.bas-col-date{
  white-space:nowrap;
}

/* ===== Modern Results Table (Elementor: user_test_stats) ===== */
.bas-results-table-modern{
  font-size:14px;
}

.bas-results-table-modern thead th{
  background:#f2f5f7;
  border-bottom:1px solid rgba(15, 23, 42, 0.06);
  font-weight:600;
}

.bas-results-table-modern tbody tr:nth-child(even) td,
.bas-results-table-modern tbody tr:nth-child(even) th{
  background:#fafafa;
}

.bas-results-table-modern td,
.bas-results-table-modern th{
  border-bottom:1px solid rgba(15, 23, 42, 0.06);
}

.bas-test-type{
  display:flex;
  align-items:center;
  gap:8px;
  min-width:220px;
}

.bas-test-icon{
  display:inline-flex;
  width:20px;
  height:20px;
  align-items:center;
  justify-content:center;
  font-size:16px;
  line-height:1;
}

.bas-test-label{
  font-weight:500;
}

.bas-results-table-modern td.bas-col-date{
  white-space:nowrap;
}

.bas-progress{
  position:relative;
  height:28px;
  border-radius:999px;
  background:#e9eef1;
  overflow:hidden;
  min-width:140px;
}

.bas-progress__bar{
  height:100%;
  width:0;
  background:linear-gradient(90deg, #2bdc7e, #2ce6c8);
}

.bas-progress__text{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:600;
  color:#1f2d3d;
  font-size:12px;
}

.bas-pill{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:6px 12px;
  border-radius:999px;
  font-weight:700;
  font-size:12px;
  letter-spacing:.2px;
  white-space:nowrap;
}

.bas-pill-success{background:#dff3e4;color:#1d5c2c;}
.bas-pill-danger{background:#f8d7da;color:#7a1f2a;}

.bas-btn{
  border-radius:4px;
  border:1px solid #2271b1;
  background:#ffffff;
  color:#2271b1;
  padding:6px 10px;
  line-height:1.2;
  font-size:12px;
  cursor:pointer;
}

.bas-btn:hover{background:#2271b1;color:#1e293b;}

.bas-btn-pdf{margin-left:6px;}

@media (max-width:768px){
  .bas-test-type{min-width:180px;}
  .bas-progress{min-width:120px;}
}

.bas-pill-success{background:#d9f2dc;color:#1f6b2b;}
.bas-pill-danger{background:#f8d7da;color:#8a1f2b;}

.bas-btn{
  border-radius:4px !important;
  padding:6px 10px !important;
  line-height:1.2 !important;
}

.bas-btn-view,
.bas-btn-pdf{
  border:1px solid #1e73be !important;
  color:#1e73be !important;
  background:#ffffff !important;
}

.bas-btn-view:hover,
.bas-btn-pdf:hover{
  background:#1e73be !important;
  color:#1e293b !important;
}

@media (max-width:768px){
  /* Hide checkbox column on mobile to save space */
  .bas-table-split .bas-split-fixed th.check-column,
  .bas-table-split .bas-split-fixed td.check-column{
    display:none;
  }
}

/* ===== Result Details Modal (Frontend) ===== */
.bas-modal{position:fixed;inset:0;z-index:99999;display:none;}
.bas-modal .bas-modal-overlay{position:absolute;inset:0;background:rgba(15, 23, 42, 0.08);}
.bas-modal .bas-modal-content{position:relative;z-index:2;background:#ffffff;max-width:980px;width:calc(100% - 24px);margin:40px auto;padding:18px 18px 16px;border-radius:10px;box-shadow:0 20px 60px rgba(15, 23, 42, 0.08);max-height:calc(100vh - 80px);overflow:auto;}
.bas-modal .bas-modal-close{position:absolute;right:12px;top:10px;border:0;background:transparent;font-size:28px;line-height:1;cursor:pointer;color:#e2e8f0;}
.bas-modal .bas-result-details-content{padding-top:18px;}

@media (max-width: 768px){
  .bas-modal .bas-modal-content{margin:16px auto;max-height:calc(100vh - 32px);}
}


/* ===== Mobile Accordion for candidate test results ===== */
.bas-results-accordion{display:none;}
.bas-accordion-item{
  border:1px solid rgba(15, 23, 42, 0.06);
  border-radius:14px;
  background:#ffffff;
  box-shadow:0 8px 22px rgba(15, 23, 42, 0.06);
  overflow:hidden;
}
.bas-accordion-item + .bas-accordion-item{margin-top:14px;}
.bas-accordion-trigger{
  width:100%;
  border:0;
  background:#ffffff;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:16px;
  text-align:left;
  cursor:pointer;
}
.bas-accordion-trigger__main{display:flex;flex-direction:column;gap:8px;min-width:0;flex:1 1 auto;}
.bas-accordion-trigger__main .bas-test-type{min-width:0;}
.bas-accordion-trigger__side{display:flex;align-items:center;gap:10px;flex:0 0 auto;}
.bas-accordion-date{font-size:12px;color:#667085;}
.bas-accordion-chevron{font-size:22px;line-height:1;color:#1e73be;transition:transform .2s ease;}
.bas-accordion-trigger[aria-expanded="true"] .bas-accordion-chevron{transform:rotate(45deg);}
.bas-accordion-panel{padding:0 16px 16px;border-top:1px solid rgba(15, 23, 42, 0.06);background:#fcfcfd;}
.bas-accordion-grid{display:grid;grid-template-columns:1fr;gap:10px;padding-top:14px;}
.bas-accordion-row{display:flex;justify-content:space-between;gap:14px;align-items:flex-start;}
.bas-accordion-label{font-size:12px;font-weight:700;color:#475467;min-width:110px;}
.bas-accordion-value{font-size:14px;color:#101828;text-align:right;}
.bas-accordion-actions{display:flex;gap:8px;flex-wrap:wrap;padding-top:14px;}
.bas-results-empty{padding:16px;border:1px dashed rgba(15, 23, 42, 0.06);border-radius:12px;background:#ffffff;}

@media (max-width: 768px){
  .bas-table-split{display:none;}
  .bas-results-accordion{display:block;}
  .bas-results-toolbar{align-items:flex-start !important;}
  .bas-refresh-hint{display:block;}
}

@media (min-width: 769px){
  .bas-results-accordion{display:none;}
}

/* Standalone landing, login, registration, and dashboard helpers */
.bas-front-page,
.bas-auth-box,
.bas-user-dashboard,
.bas-candidate-dashboard,
.bas-employer-dashboard {
    max-width: 1120px;
    margin: 0 auto;
}

.bas-hero {
    padding: 56px 32px;
    border-radius: 18px;
    background: linear-gradient(135deg, #f7f9fc 0%, #eef3f8 100%);
    text-align: center;
    margin-bottom: 32px;
}

.bas-hero h1 {
    font-size: clamp(32px, 5vw, 56px);
    margin: 0 0 12px;
}

.bas-hero p {
    font-size: 18px;
    max-width: 760px;
    margin: 0 auto 24px;
}

.bas-hero-actions,
.bas-auth-required p:last-child {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.bas-feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
}

.bas-feature-card,
.bas-auth-box,
.bas-dashboard-section {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 24px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.bas-auth-box {
    max-width: 520px;
}

.bas-auth-form input[type="text"],
.bas-auth-form input[type="email"],
.bas-auth-form input[type="password"],
.bas-auth-form select {
    width: 100%;
    min-height: 44px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 8px 12px;
}

.bas-alert {
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 18px;
}

.bas-alert ul {
    margin: 0 0 0 18px;
}

.bas-alert-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.bas-alert-success {
    background: #ecfdf5;
    border: 1px solid #bbf7d0;
    color: #065f46;
}

.bas-btn {
    display: inline-block;
    padding: 10px 16px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    text-decoration: none;
    font-weight: 600;
    background: #ffffff;
}

.bas-btn-primary {
    background: #2563eb;
    color: #ffffff !important;
    border-color: #2563eb;
}

.bas-results-table-wrapper {
    overflow-x: auto;
}

.bas-results-table {
    width: 100%;
    border-collapse: collapse;
}

.bas-results-table th,
.bas-results-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
}

.bas-status-passed,
.bas-status.passed {
    color: #166534;
    font-weight: 700;
}

.bas-status-failed,
.bas-status.failed {
    color: #991b1b;
    font-weight: 700;
}

/* Honeypot field: visually hidden from humans, visible to bots */
.bas-hp-field { position: absolute !important; left: -9999px !important; top: -9999px !important; height: 0; overflow: hidden; }
