/* Main Layout */
.ehsan-clearfix:before,
.ehsan-clearfix:after {
    content: " ";
    display: table;
}

.ehsan-clearfix:after { clear: both; }
.ehsan-hidden { display: none !important; }

/* Course Grid */
.ehsan-courses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
    margin: 0 0 30px;
}

.ehsan-course-card {
    border: 1px solid #e9ecef;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.ehsan-course-thumbnail {
    position: relative;
    padding-top: 56.25%;
    background: #f8f9fa;
}

/* Quiz Attempts */
.ehsan-quiz-attempts {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.ehsan-attempts-header {
    margin-bottom: 30px;
    text-align: center;
}

.ehsan-attempts-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.ehsan-stat-box {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    border: 1px solid #e9ecef;
}

.ehsan-stat-box h3 {
    margin: 0 0 10px;
    font-size: 14px;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ehsan-stat-box .stat-value {
    font-size: 32px;
    font-weight: 700;
    color: #333;
    line-height: 1.2;
}

.ehsan-attempts-list {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    margin-bottom: 30px;
}

.ehsan-attempts-list table {
    width: 100%;
    border-collapse: collapse;
}

.ehsan-attempts-list th,
.ehsan-attempts-list td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

.ehsan-attempts-list th {
    background: #f8f9fa;
    font-weight: 600;
    color: #495057;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

.ehsan-attempts-list tr:last-child td {
    border-bottom: none;
}

.ehsan-attempts-list .score {
    min-width: 150px;
}

.ehsan-attempts-list .score-bar {
    display: block;
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
    margin-top: 5px;
    overflow: hidden;
}

.ehsan-attempts-list .score-fill {
    display: block;
    height: 100%;
    background: #28a745;
    transition: width 0.6s ease;
}

.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.passed {
    background: #d4edda;
    color: #155724;
}

.status-badge.failed {
    background: #f8d7da;
    color: #721c24;
}

.ehsan-attempts-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

.ehsan-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    background: #007bff;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.ehsan-button:hover {
    background: #0056b3;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.ehsan-button-primary {
    background: #007bff;
}

.ehsan-button-danger {
    background: #dc3545;
}

.ehsan-button-danger:hover {
    background: #bd2130;
}

.ehsan-button-small {
    padding: 5px 12px;
    font-size: 13px;
}

.ehsan-button[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Attempt Details */
.attempt-details-header {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.attempt-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 15px;
    color: #6c757d;
    font-size: 14px;
}

.attempt-certificate {
    background: #e7f5ff;
    border-left: 4px solid #4dabf7;
    padding: 15px 20px;
    margin: 20px 0;
    border-radius: 0 4px 4px 0;
}

.attempt-answers {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.answer-item {
    padding: 15px 0;
    border-bottom: 1px solid #e9ecef;
}

.answer-item:last-child {
    border-bottom: none;
}

.answer-question {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    font-weight: 500;
}

.answer-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: #f8f9fa;
    border-radius: 50%;
    margin-right: 10px;
    font-size: 12px;
    font-weight: 600;
}

.answer-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin-right: 10px;
    font-size: 10px;
    font-weight: bold;
}

.answer-status.correct {
    background: #d4edda;
    color: #155724;
}

.answer-status.incorrect {
    background: #f8d7da;
    color: #721c24;
}

.answer-details {
    padding-left: 34px;
    font-size: 14px;
    color: #495057;
}

.answer-feedback {
    margin-top: 8px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 4px;
    border-left: 3px solid #6c757d;
}

/* Responsive */
@media (max-width: 768px) {
    .ehsan-attempts-stats {
        grid-template-columns: 1fr 1fr;
    }
    
    .ehsan-attempts-list {
        overflow-x: auto;
    }
    
    .ehsan-attempts-list table {
        min-width: 700px;
    }
    
    .ehsan-attempts-actions {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .attempt-meta {
        flex-direction: column;
        gap: 8px;
    }
}

/* Loading State */
.loading {
    position: relative;
    opacity: 0.7;
    pointer-events: none;
}

.loading:after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.ehsan-course-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.ehsan-course-card:hover .ehsan-course-thumbnail img {
    transform: scale(1.05);
}

.ehsan-course-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    padding: 4px 10px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    z-index: 1;
}

.ehsan-course-badge-free { background-color: #28a745; }
.ehsan-course-badge-enrolled { background-color: #007bff; }

.ehsan-course-content {
    padding: 20px;
}

.ehsan-course-title {
    margin: 0 0 10px;
    font-size: 1.1rem;
}

.ehsan-course-title a {
    color: #212529;
    text-decoration: none;
}

.ehsan-course-meta {
    display: flex;
    justify-content: space-between;
    margin: 15px 0;
    font-size: 14px;
    color: #6c757d;
}

.ehsan-course-price {
    font-weight: 600;
    color: #28a745;
}

/* Single Lesson */
.ehsan-lesson-single {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
}

.ehsan-lesson-sidebar {
    flex: 0 0 300px;
}

.ehsan-lesson-content {
    flex: 1;
    min-width: 0;
    line-height: 1.7;
}

/* Progress Bar */
.progress-bar-container {
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
    margin: 10px 0;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: #007bff;
    width: 0%;
    transition: width 0.6s ease;
}

/* Responsive */
@media (max-width: 768px) {
    .ehsan-lesson-single {
        flex-direction: column;
    }
    
    .ehsan-lesson-sidebar {
        flex: 0 0 100%;
    }
}

/* Buttons */
.button {
    display: inline-block;
    padding: 8px 16px;
    background: #007bff;
    color: #fff;
    border: none;
    border-radius: 4px;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.button:hover {
    background: #0056b3;
    color: #fff;
}

/* Forms */
.ehsan-courses-search {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.ehsan-courses-search input[type="text"] {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* --------------------------------------------------
   Design Tokens and Base Styles
   -------------------------------------------------- */
:root {
  --eh-color-primary: #007bff;
  --eh-color-primary-dark: #0056b3;
  --eh-color-secondary: #6c757d;
  --eh-color-success: #28a745;
  --eh-color-danger: #dc3545;
  --eh-color-warning: #ffb900;
  --eh-color-info: #17a2b8;
  --eh-color-light: #f8f9fa;
  --eh-color-muted: #6c757d;
  --eh-color-border: #e9ecef;
  --eh-color-text: #2c3338;
  --eh-shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --eh-shadow-md: 0 2px 10px rgba(0,0,0,0.08);
  --eh-radius: 8px;
  --eh-radius-sm: 4px;
  --eh-space-1: 4px;
  --eh-space-2: 8px;
  --eh-space-3: 12px;
  --eh-space-4: 16px;
  --eh-space-5: 20px;
  --eh-space-6: 24px;
}

.ehsan-text-muted { color: var(--eh-color-muted); }
.ehsan-text-center { text-align: center; }
.ehsan-text-right { text-align: right; }
.ehsan-text-left { text-align: left; }
.ehsan-fw-600 { font-weight: 600; }

.d-flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.align-center { align-items: center; }
.gap-10 { gap: 10px; }
.gap-15 { gap: 15px; }
.gap-20 { gap: 20px; }

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

/* Focus Outline Utility */
.ehsan-focusable:focus { outline: 3px solid rgba(0,123,255,.35); outline-offset: 2px; }

/* --------------------------------------------------
   Generic Card Component
   -------------------------------------------------- */
.ehsan-card {
  background: #fff;
  border: 1px solid var(--eh-color-border);
  border-radius: var(--eh-radius);
  box-shadow: var(--eh-shadow-sm);
  overflow: hidden;
}
.ehsan-card__header { padding: 14px 16px; border-bottom: 1px solid var(--eh-color-border); font-weight: 600; }
.ehsan-card__body { padding: 16px; }
.ehsan-card__footer { padding: 14px 16px; border-top: 1px solid var(--eh-color-border); background: var(--eh-color-light); }

/* --------------------------------------------------
   Alerts
   -------------------------------------------------- */
.ehsan-alert {
  padding: 12px 16px;
  border-radius: var(--eh-radius-sm);
  border-left: 4px solid transparent;
  background: var(--eh-color-light);
  color: var(--eh-color-text);
  box-shadow: var(--eh-shadow-sm);
}
.ehsan-alert--success { border-left-color: var(--eh-color-success); background: #e6f7ee; }
.ehsan-alert--info { border-left-color: var(--eh-color-info); background: #e7f5ff; }
.ehsan-alert--warning { border-left-color: var(--eh-color-warning); background: #fff8e5; }
.ehsan-alert--danger { border-left-color: var(--eh-color-danger); background: #fdf0ef; }

/* --------------------------------------------------
   Badges
   -------------------------------------------------- */
.ehsan-badge {
  display: inline-block;
  padding: 3px 10px;
  font-size: 12px;
  border-radius: 999px;
  font-weight: 600;
}
.ehsan-badge--primary { background: var(--eh-color-primary); color: #fff; }
.ehsan-badge--success { background: var(--eh-color-success); color: #fff; }
.ehsan-badge--warning { background: var(--eh-color-warning); color: #2c3338; }
.ehsan-badge--danger { background: var(--eh-color-danger); color: #fff; }
.ehsan-badge--muted { background: #eceff1; color: #495057; }

/* --------------------------------------------------
   Tabs
   -------------------------------------------------- */
.ehsan-tabs { border-bottom: 1px solid var(--eh-color-border); display: flex; gap: 16px; }
.ehsan-tab {
  position: relative;
  padding: 10px 4px;
  margin-bottom: -1px;
  color: #495057;
  cursor: pointer;
}
.ehsan-tab.active { color: var(--eh-color-primary); }
.ehsan-tab.active:after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--eh-color-primary); }
.ehsan-tab-panel { display: none; padding: 16px 0; }
.ehsan-tab-panel.active { display: block; }

/* --------------------------------------------------
   Tables
   -------------------------------------------------- */
.ehsan-table-wrap { width: 100%; overflow-x: auto; background: #fff; border: 1px solid var(--eh-color-border); border-radius: var(--eh-radius); }
.ehsan-table { width: 100%; border-collapse: collapse; min-width: 680px; }
.ehsan-table th, .ehsan-table td { padding: 12px 14px; border-bottom: 1px solid var(--eh-color-border); text-align: left; }
.ehsan-table thead th { background: var(--eh-color-light); font-size: 12px; letter-spacing: .5px; text-transform: uppercase; color: #495057; }
.ehsan-table tr:last-child td { border-bottom: 0; }

/* Row states */
.ehsan-table .is-success { background: #e6f7ee; }
.ehsan-table .is-warning { background: #fff8e5; }
.ehsan-table .is-danger { background: #fdf0ef; }

/* --------------------------------------------------
   Pagination
   -------------------------------------------------- */
.ehsan-pagination { display: flex; gap: 8px; justify-content: center; align-items: center; margin: 16px 0; }
.ehsan-page { display: inline-flex; min-width: 34px; height: 34px; align-items: center; justify-content: center; padding: 0 10px; border: 1px solid var(--eh-color-border); border-radius: 6px; background: #fff; color: #333; text-decoration: none; transition: all .2s ease; }
.ehsan-page:hover { box-shadow: var(--eh-shadow-sm); transform: translateY(-1px); }
.ehsan-page.is-active { background: var(--eh-color-primary); color: #fff; border-color: var(--eh-color-primary); }
.ehsan-page.is-disabled { opacity: .5; pointer-events: none; }

/* --------------------------------------------------
   Forms
   -------------------------------------------------- */
.ehsan-input, .ehsan-select, .ehsan-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  transition: border-color .2s ease, box-shadow .2s ease;
  background: #fff;
}
.ehsan-input:focus, .ehsan-select:focus, .ehsan-textarea:focus { border-color: var(--eh-color-primary); box-shadow: 0 0 0 2px rgba(0,123,255,.15); outline: none; }
.ehsan-field { margin-bottom: 14px; }
.ehsan-label { display: block; margin-bottom: 6px; font-weight: 600; color: #2c3338; }

/* Button variants matching tokens */
.ehsan-button--secondary { background: var(--eh-color-secondary); }
.ehsan-button--success { background: var(--eh-color-success); }
.ehsan-button--warning { background: var(--eh-color-warning); color: #2c3338; }
.ehsan-button--danger { background: var(--eh-color-danger); }

/* --------------------------------------------------
   Breadcrumbs
   -------------------------------------------------- */
.ehsan-breadcrumb { display: flex; gap: 6px; flex-wrap: wrap; font-size: .95em; color: #6c757d; }
.ehsan-breadcrumb a { color: var(--eh-color-primary); text-decoration: none; }
.ehsan-breadcrumb .sep { color: #adb5bd; }

/* --------------------------------------------------
   Modal (lightweight)
   -------------------------------------------------- */
.ehsan-modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: none; align-items: center; justify-content: center; z-index: 9999; }
.ehsan-modal.is-open { display: flex; }
.ehsan-modal__dialog { background: #fff; border-radius: var(--eh-radius); width: min(600px, 92vw); box-shadow: var(--eh-shadow-md); overflow: hidden; }
.ehsan-modal__header { padding: 12px 16px; border-bottom: 1px solid var(--eh-color-border); font-weight: 600; }
.ehsan-modal__body { padding: 16px; }
.ehsan-modal__footer { padding: 12px 16px; border-top: 1px solid var(--eh-color-border); background: var(--eh-color-light); display: flex; gap: 10px; justify-content: flex-end; }

/* --------------------------------------------------
   Tooltips (attribute-based)
   -------------------------------------------------- */
[data-e-tooltip] { position: relative; }
[data-e-tooltip]:hover:after {
  content: attr(data-e-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #2c3338;
  color: #fff;
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 4px;
  white-space: nowrap;
  box-shadow: var(--eh-shadow-sm);
  z-index: 10;
}

/* --------------------------------------------------
   Responsive Helpers
   -------------------------------------------------- */
@media (max-width: 768px) {
  .hide-sm { display: none !important; }
  .ehsan-card__body { padding: 14px; }
  .ehsan-table { min-width: 560px; }
}

/* --------------------------------------------------
   Dark Mode (respects system pref)
   -------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root {
    --eh-color-text: #e6e6e6;
    --eh-color-border: #2b2f33;
    --eh-color-light: #1e2226;
  }
  body { background: #0f1214; color: var(--eh-color-text); }
  .ehsan-card,
  .ehsan-table-wrap,
  .ehsan-attempts-list,
  .attempt-details-header,
  .attempt-answers {
    background: #15181b;
    border-color: var(--eh-color-border);
    box-shadow: none;
  }
  .ehsan-table thead th { background: #1a1f23; color: #cfd3d7; }
  .ehsan-alert { background: #1a1f23; }
  .ehsan-badge--muted { background: #2b2f33; color: #cfd3d7; }
  .ehsan-input, .ehsan-select, .ehsan-textarea { background: #0f1214; color: var(--eh-color-text); border-color: var(--eh-color-border); }
  .ehsan-button,
  .button { color: #fff; }
}

/* --------------------------------------------------
   RTL Refinements
   -------------------------------------------------- */
.rtl .ehsan-text-left { text-align: right; }
.rtl .ehsan-text-right { text-align: left; }
.rtl .ehsan-breadcrumb .sep { transform: scaleX(-1); }
.rtl .ehsan-table th, .rtl .ehsan-table td { text-align: right; }
.rtl [data-e-tooltip]:hover:after { left: auto; right: 50%; transform: translateX(50%); }
