/* ============================================================
   Student Portal — Public CSS
   Design: Dark glassmorphism + vibrant accent colors
   Font: Noto Sans Thai (Google Fonts)
   ============================================================ */

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

/* ——— CSS Custom Properties ——————————————————————————————— */
:root {
  --sp-bg:           transparent;
  --sp-surface:      #ffffff;
  --sp-surface-2:    #f9fafb;
  --sp-border:       #eaecf0;
  --sp-border-hover: #d0d5dd;

  --sp-primary:      #2c3e50; /* Changed to match the dark sidebar blue-grey */
  --sp-primary-glow: rgba(44,62,80,.2);
  --sp-accent:       #f0884d;
  --sp-accent-glow:  rgba(240,136,77,.2);
  --sp-success:      #10b981;
  --sp-warning:      #f59e0b;
  --sp-danger:       #ef4444;

  --sp-text:         #334155;
  --sp-text-muted:   #64748b;
  --sp-text-dim:     #94a3b8;

  --sp-radius-sm:    6px;
  --sp-radius:       8px;
  --sp-radius-lg:    12px;
  --sp-radius-full:  9999px;

  --sp-shadow:       0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
  --sp-shadow-lg:    0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
  --sp-transition:   .2s cubic-bezier(.4,0,.2,1);

  --sp-font:         'Noto Sans Thai', 'Inter', sans-serif;
}

/* ——— Reset & Base ———————————————————————————————————————— */
.sp-portal *, .sp-portal *::before, .sp-portal *::after { box-sizing: border-box; margin: 0; padding: 0; }
.sp-portal {
  font-family: var(--sp-font);
  font-size: 15px;
  color: var(--sp-text);
  background: var(--sp-bg);
  min-height: 100vh;
  line-height: 1.6;
}

/* ——— Header ——————————————————————————————————————————————— */
.sp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--sp-surface);
  border-bottom: 1px solid var(--sp-border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}
.sp-header__logo { display: flex; align-items: center; gap: 12px; }
.sp-icon { font-size: 28px; }
.sp-header__title { font-size: 20px; font-weight: 700; background: linear-gradient(135deg,#7c6df0,#f0884d); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.sp-header__user { display: flex; align-items: center; gap: 12px; }
.sp-avatar {
  width: 36px; height: 36px;
  border-radius: var(--sp-radius-full);
  background: linear-gradient(135deg,var(--sp-primary),var(--sp-accent));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
}
.sp-username { font-size: 14px; color: var(--sp-text-muted); }

/* ——— Main Layout ———————————————————————————————————————— */
.sp-main { max-width: 1100px; margin: 0 auto; padding: 28px 20px; }

/* ——— Buttons ————————————————————————————————————————————— */
.sp-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px; border-radius: var(--sp-radius-sm);
  font-family: var(--sp-font); font-size: 14px; font-weight: 600;
  cursor: pointer; border: none; transition: all var(--sp-transition);
  text-decoration: none; line-height: 1;
}
.sp-btn--primary  { background: var(--sp-primary); color: #fff; }
.sp-btn--primary:hover  { background: #6a5ce0; box-shadow: 0 0 20px var(--sp-primary-glow); transform: translateY(-1px); }
.sp-btn--accent   { background: var(--sp-accent);  color: #fff; }
.sp-btn--accent:hover   { background: #d97840; box-shadow: 0 0 20px var(--sp-accent-glow); transform: translateY(-1px); }
.sp-btn--ghost    { background: transparent; color: var(--sp-text-muted); border: 1px solid var(--sp-border); }
.sp-btn--ghost:hover    { border-color: var(--sp-border-hover); color: var(--sp-text); }
.sp-btn--sm       { padding: 7px 14px; font-size: 13px; }
.sp-btn--full     { width: 100%; justify-content: center; }

/* ——— Student Cards ————————————————————————————————————— */
.sp-students-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill,minmax(300px,1fr));
  gap: 20px;
  margin-bottom: 32px;
}
.sp-student-card {
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius-lg);
  padding: 24px;
  transition: all var(--sp-transition);
}
.sp-student-card:hover {
  border-color: var(--sp-primary);
  box-shadow: 0 0 0 1px var(--sp-primary), var(--sp-shadow);
  transform: translateY(-2px);
}
.sp-student-card__header { display: flex; gap: 16px; margin-bottom: 16px; }
.sp-student-avatar {
  width: 54px; height: 54px; border-radius: var(--sp-radius-full);
  background: linear-gradient(135deg,var(--sp-primary),#9b8df5);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; flex-shrink: 0;
}
.sp-student-card__name { font-size: 17px; font-weight: 600; margin-bottom: 8px; }
.sp-badge {
  display: inline-block; padding: 3px 10px;
  background: var(--sp-surface-2); border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius-full); font-size: 12px; color: var(--sp-text-muted);
  margin-right: 4px;
}
.sp-badge--secondary { background: rgba(124,109,240,.15); border-color: var(--sp-primary); color: var(--sp-primary); }

/* GPA in card */
.sp-student-card__gpa {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; border-radius: var(--sp-radius-sm);
  margin-bottom: 16px;
}
.sp-gpa--excellent { background: rgba(63,185,80,.12); border: 1px solid rgba(63,185,80,.3); }
.sp-gpa--good      { background: rgba(124,109,240,.12); border: 1px solid rgba(124,109,240,.3); }
.sp-gpa--average   { background: rgba(210,153,34,.12); border: 1px solid rgba(210,153,34,.3); }
.sp-gpa--poor      { background: rgba(248,81,73,.12); border: 1px solid rgba(248,81,73,.3); }
.sp-gpa__label { font-size: 13px; color: var(--sp-text-muted); }
.sp-gpa__value { font-size: 22px; font-weight: 700; margin-left: auto; }
.sp-student-card__actions { display: flex; gap: 8px; }

/* ——— GPA Banner ——————————————————————————————————————— */
.sp-gpa-banner {
  display: flex; align-items: center; gap: 16px;
  padding: 20px 28px; border-radius: var(--sp-radius-lg);
  margin-bottom: 28px;
}
.sp-gpa-banner--excellent { background: linear-gradient(135deg,rgba(63,185,80,.15),rgba(63,185,80,.05)); border: 1px solid rgba(63,185,80,.3); }
.sp-gpa-banner--good      { background: linear-gradient(135deg,rgba(124,109,240,.15),rgba(124,109,240,.05)); border: 1px solid rgba(124,109,240,.3); }
.sp-gpa-banner--poor      { background: linear-gradient(135deg,rgba(248,81,73,.15),rgba(248,81,73,.05)); border: 1px solid rgba(248,81,73,.3); }
.sp-gpa-banner__label { font-size: 13px; color: var(--sp-text-muted); }
.sp-gpa-banner__value { font-size: 42px; font-weight: 700; }
.sp-gpa-banner__scale { font-size: 13px; color: var(--sp-text-muted); margin-left: auto; }

/* ——— Section —————————————————————————————————————— */
.sp-section { background: var(--sp-surface); border: 1px solid var(--sp-border); border-radius: var(--sp-radius-lg); padding: 20px; margin-bottom: 16px; box-shadow: var(--sp-shadow); }
.sp-section__header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.sp-section__title { font-size: 17px; font-weight: 700; }
.sp-section__subtitle { color: var(--sp-text-muted); font-size: 13px; }

/* ——— Tables ——————————————————————————————————————————— */
.sp-table-wrapper { overflow-x: auto; border-radius: var(--sp-radius-sm); }
.sp-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.sp-table thead th {
  padding: 12px 16px; text-align: left;
  background: var(--sp-surface-2); color: var(--sp-text-muted);
  font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 1px solid var(--sp-border);
}
.sp-table tbody .sp-table__row { border-bottom: 1px solid var(--sp-border); transition: background var(--sp-transition); }
.sp-table tbody .sp-table__row:hover { background: var(--sp-surface-2); }
.sp-table td { padding: 14px 16px; }
.sp-code { font-family: 'Courier New', monospace; font-size: 13px; background: var(--sp-surface-2); padding: 2px 8px; border-radius: 4px; color: var(--sp-primary); }
.sp-text-center { text-align: center; }
.sp-text-muted { color: var(--sp-text-muted); font-size: 13px; }

/* Grade badges */
.sp-grade-badge { display: inline-block; padding: 4px 12px; border-radius: var(--sp-radius-full); font-weight: 700; font-size: 13px; }
.sp-grade--a     { background: rgba(63,185,80,.2);   color: #3fb950; border: 1px solid rgba(63,185,80,.4); }
.sp-grade--bplus { background: rgba(88,166,255,.2);  color: #58a6ff; border: 1px solid rgba(88,166,255,.4); }
.sp-grade--b     { background: rgba(124,109,240,.2); color: #7c6df0; border: 1px solid rgba(124,109,240,.4); }
.sp-grade--cplus { background: rgba(210,153,34,.2);  color: #d29922; border: 1px solid rgba(210,153,34,.4); }
.sp-grade--c     { background: rgba(240,136,77,.2);  color: #f0884d; border: 1px solid rgba(240,136,77,.4); }
.sp-grade--dplus { background: rgba(248,81,73,.15);  color: #f85149; border: 1px solid rgba(248,81,73,.3); }
.sp-grade--d     { background: rgba(248,81,73,.1);   color: #f85149; border: 1px solid rgba(248,81,73,.2); }
.sp-grade--f     { background: rgba(248,81,73,.25);  color: #ff6b6b; border: 1px solid rgba(248,81,73,.5); font-weight: 800; }

/* ——— Course Groups ——————————————————————————————————— */
.sp-course-group { margin-bottom: 32px; }
.sp-course-group__header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
.sp-course-group__title { font-size: 15px; font-weight: 600; color: var(--sp-text-muted); }
.sp-semester-gpa { font-size: 13px; color: var(--sp-text-muted); }
.sp-semester-gpa strong { color: var(--sp-primary); font-size: 16px; }

/* ——— Summary Bar ——————————————————————————————————————— */
.sp-summary-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; background: var(--sp-surface-2);
  border-radius: var(--sp-radius-sm); font-size: 14px; color: var(--sp-text-muted);
  margin-top: 8px;
}
.sp-summary-bar strong { color: var(--sp-text); font-size: 18px; }

/* ——— Empty State ————————————————————————————————————— */
.sp-empty-state { text-align: center; padding: 60px 20px; color: var(--sp-text-muted); }
.sp-empty-state--sm { padding: 40px 20px; }
.sp-empty-state__icon { font-size: 48px; display: block; margin-bottom: 16px; opacity: .6; }
.sp-error { color: var(--sp-danger); padding: 12px; background: rgba(248,81,73,.1); border-radius: var(--sp-radius-sm); border: 1px solid rgba(248,81,73,.3); }

/* ——— Loading ————————————————————————————————————————— */
.sp-loading { text-align: center; padding: 40px; color: var(--sp-text-muted); }
.sp-spinner {
  width: 36px; height: 36px; margin: 0 auto 16px;
  border: 3px solid var(--sp-border);
  border-top-color: var(--sp-primary);
  border-radius: 50%;
  animation: sp-spin .8s linear infinite;
}
@keyframes sp-spin { to { transform: rotate(360deg); } }

/* ——— Content Area ————————————————————————————————————— */
.sp-content-area { margin-top: 32px; animation: sp-fade-in .3s ease; }
@keyframes sp-fade-in { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }

/* ——— Login / Auth ————————————————————————————————————— */
.sp-portal--auth {
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 60% 0%,rgba(124,109,240,.18) 0%,transparent 60%),
              radial-gradient(ellipse at 10% 90%,rgba(240,136,77,.12) 0%,transparent 50%),
              var(--sp-bg);
}
.sp-auth-card {
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius-lg);
  padding: 40px;
  width: 100%; max-width: 420px;
  box-shadow: var(--sp-shadow-lg);
}
.sp-auth-card__logo { text-align: center; margin-bottom: 32px; }
.sp-auth-logo-icon { font-size: 52px; display: block; margin-bottom: 12px; }
.sp-auth-card__title { font-size: 26px; font-weight: 700; background: linear-gradient(135deg,#7c6df0,#f0884d); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.sp-auth-card__subtitle { font-size: 14px; color: var(--sp-text-muted); margin-top: 6px; }
.sp-auth-card__footer { text-align: center; font-size: 13px; color: var(--sp-text-muted); margin-top: 20px; }

/* Form */
.sp-form-group { margin-bottom: 20px; }
.sp-label { display: block; font-size: 13px; font-weight: 600; color: var(--sp-text-muted); margin-bottom: 8px; }
.sp-input {
  width: 100%; padding: 11px 14px;
  background: var(--sp-surface-2); border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius-sm); color: var(--sp-text);
  font-family: var(--sp-font); font-size: 15px;
  transition: border-color var(--sp-transition), box-shadow var(--sp-transition);
}
.sp-input:focus { outline: none; border-color: var(--sp-primary); box-shadow: 0 0 0 3px var(--sp-primary-glow); }
.sp-input-wrapper { position: relative; }
.sp-input-wrapper .sp-input { padding-right: 44px; }
.sp-toggle-password {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; font-size: 16px; opacity: .6;
  transition: opacity var(--sp-transition);
}
.sp-toggle-password:hover { opacity: 1; }
.sp-form-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.sp-checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.sp-link { color: var(--sp-primary); text-decoration: none; font-size: 13px; }
.sp-link:hover { text-decoration: underline; }
.sp-alert { padding: 12px 16px; border-radius: var(--sp-radius-sm); margin-bottom: 20px; font-size: 14px; }
.sp-alert--error { background: rgba(248,81,73,.1); border: 1px solid rgba(248,81,73,.3); color: #f85149; }


/* ——— Student Dashboard Grid (New) ————————————————————— */
.sp-dashboard-grid {
  display: flex; gap: 24px; margin-bottom: 40px; flex-direction: column;
}
.sp-dashboard-header-card {
  display: flex; align-items: center; gap: 24px;
  background: var(--sp-surface); padding: 24px 32px; 
  border-radius: var(--sp-radius-lg); 
  border: 1px solid var(--sp-border);
  box-shadow: var(--sp-shadow);
}
.sp-profile-avatar-wrap {
  flex-shrink: 0;
}
.sp-profile-img { 
  width: 90px; height: 90px; object-fit: cover; 
  border-radius: var(--sp-radius-full); 
  border: 3px solid #fff; box-shadow: var(--sp-shadow);
}
.sp-profile-info h3 { margin: 0 0 4px 0; font-size: 20px; color: var(--sp-primary); font-weight: 700; border: none; padding: 0; }
.sp-profile-info p { margin: 0; color: var(--sp-text-muted); font-size: 15px; }

.sp-box {
  background: var(--sp-surface); padding: 32px; 
  border-radius: var(--sp-radius-lg); 
  border: 1px solid var(--sp-border);
  box-shadow: var(--sp-shadow);
}
.sp-box-title { 
  margin-top: 0; margin-bottom: 24px; font-size: 18px; 
  color: var(--sp-primary); border-bottom: 1px solid var(--sp-border); 
  padding-bottom: 12px; font-weight: 600;
}

/* ——— Lessons Grid ————————————————————————————————————— */
.sp-lesson-grid { 
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px;
}
.sp-lesson-box {
  background: var(--sp-surface);
  border-radius: var(--sp-radius);
  padding: 16px;
  border: 1px solid var(--sp-border);
  text-align: center;
  cursor: pointer;
  transition: all var(--sp-transition);
  box-shadow: var(--sp-shadow);
}
.sp-lesson-box:hover {
  transform: translateY(-4px);
  border-color: var(--sp-primary);
  box-shadow: var(--sp-shadow-lg);
}
.sp-lesson-box img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: var(--sp-radius-sm);
  margin-bottom: 12px;
}
.sp-lesson-box p {
  font-size: 15px; margin: 0; line-height: 1.4; color: var(--sp-text); font-weight: 500;
}

/* ——— Popup Modal —————————————————————————————————————— */
.sp-popup {
  display: none; position: fixed; z-index: 9999;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  padding-top: 60px; overflow-y: auto;
}
.sp-popup-content {
  background: var(--sp-surface); margin: auto; padding: 32px;
  border-radius: var(--sp-radius-lg); border: 1px solid var(--sp-border);
  box-shadow: var(--sp-shadow-lg); width: 90%; max-width: 600px;
  text-align: center; position: relative; margin-bottom: 60px;
}
.sp-popup-content h3 { font-size: 22px; color: var(--sp-text); margin-bottom: 16px; }
.sp-popup-content img { width: 100%; max-height: 300px; object-fit: contain; border-radius: var(--sp-radius); margin-bottom: 20px; }
.sp-popup-content p { color: var(--sp-text-muted); font-size: 15px; margin-bottom: 12px; }
.sp-popup-content strong { color: var(--sp-primary); }
.sp-close {
  position: absolute; right: 20px; top: 16px;
  color: var(--sp-text-muted); font-size: 28px; font-weight: bold;
  cursor: pointer; transition: color var(--sp-transition); line-height: 1;
}
.sp-close:hover { color: var(--sp-text); }


/* ——— Teacher Dashboard ————————————————————————————————— */
.sp-teacher-controls { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.sp-search-bar { flex: 1; min-width: 200px; }
.sp-search-bar input { width: 100%; padding: 9px 14px; border-radius: var(--sp-radius-sm); border: 1px solid var(--sp-border); background: var(--sp-surface-2); color: var(--sp-text); font-size: 14px; }
.sp-student-list { display: flex; flex-direction: column; gap: 8px; }

/* Teacher Student Card — override inline styles for cleaner look */
.sp-teacher-student-card {
  border: 1px solid var(--sp-border) !important;
  border-radius: var(--sp-radius) !important;
  margin-bottom: 8px !important;
  background: var(--sp-surface) !important;
  box-shadow: var(--sp-shadow) !important;
  transition: box-shadow var(--sp-transition), border-color var(--sp-transition);
}
.sp-teacher-student-card:hover {
  border-color: var(--sp-border-hover) !important;
  box-shadow: var(--sp-shadow-lg) !important;
}
.sp-student-item { 
  display: flex; align-items: center; justify-content: space-between; 
  background: var(--sp-surface); padding: 12px 16px; 
  border-radius: var(--sp-radius); border: 1px solid var(--sp-border);
  transition: border-color var(--sp-transition);
}
.sp-student-item:hover { border-color: var(--sp-border-hover); }
.sp-student-item__info { display: flex; align-items: center; gap: 12px; }
.sp-student-item__avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.sp-student-item__name { font-weight: 600; font-size: 15px; color: var(--sp-text); }
.sp-student-item__meta { font-size: 12px; color: var(--sp-text-muted); }

/* Edit Panel */
.sp-edit-panel { 
  display: none; background: var(--sp-surface-2); 
  border: 1px solid var(--sp-border); border-top: none;
  border-radius: 0 0 var(--sp-radius) var(--sp-radius);
  padding: 16px; margin-top: -8px; margin-bottom: 8px;
}
.sp-student-item.is-editing { border-radius: var(--sp-radius) var(--sp-radius) 0 0; border-bottom: none; }
.sp-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.sp-form-group input, .sp-form-group select { 
  width: 100%; padding: 8px 12px; border-radius: 4px; 
  border: 1px solid var(--sp-border); background: var(--sp-bg); color: var(--sp-text);
}
.sp-form-actions { margin-top: 16px; display: flex; gap: 8px; justify-content: flex-end; }


/* ——— Footer ——————————————————————————————————————————— */
.sp-footer { text-align: center; padding: 24px; color: var(--sp-text-dim); font-size: 13px; border-top: 1px solid var(--sp-border); margin-top: 40px; }

/* ——— Responsive ——————————————————————————————————————— */
@media (max-width: 640px) {
  .sp-header { padding: 12px 16px; }
  .sp-main { padding: 24px 16px; }
  .sp-student-card__actions { flex-direction: column; }
  .sp-gpa-banner { flex-wrap: wrap; }
  .sp-section__header { flex-direction: column; gap: 4px; }
  .sp-form-grid { grid-template-columns: 1fr; }
}

/* ——— Parent Dashboard: Student Cards ————————————————— */
.sp-student-card__header { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.sp-student-card__avatar { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; border: 2px solid var(--sp-border); flex-shrink: 0; }
.sp-student-card__name   { font-size: 16px; font-weight: 700; color: var(--sp-text); }
.sp-student-card__meta   { font-size: 13px; color: var(--sp-text-muted); margin-top: 2px; }

.sp-student-card__stats  { display: flex; gap: 16px; margin-bottom: 16px; padding: 12px; background: var(--sp-surface-2); border-radius: var(--sp-radius); }
.sp-mini-stat            { flex: 1; text-align: center; }
.sp-mini-stat__val       { display: block; font-size: 22px; font-weight: 800; line-height: 1.2; }
.sp-mini-stat__label     { font-size: 11px; color: var(--sp-text-muted); text-transform: uppercase; letter-spacing: .04em; }

/* ——— Skill Bars ————————————————————————————————————— */
.sp-skill-bars           { display: flex; flex-direction: column; gap: 8px; }
.sp-skill-bar            { display: grid; grid-template-columns: 100px 1fr 30px; align-items: center; gap: 8px; }
.sp-skill-bar__label     { font-size: 12px; color: var(--sp-text-muted); }
.sp-skill-bar__track     { height: 6px; background: var(--sp-border); border-radius: 99px; overflow: hidden; }
.sp-skill-bar__fill      { height: 100%; background: linear-gradient(90deg, var(--sp-primary), var(--sp-accent)); border-radius: 99px; transition: width .6s ease; }
.sp-skill-bar__val       { font-size: 12px; color: var(--sp-text); font-weight: 600; text-align: right; }

/* ——— WooCommerce My Account Integration Fix ———————————————
   แก้ปัญหา Layout เพี้ยนเมื่อ render ใน Elementor My Account Page
   ————————————————————————————————————————————————————————— */

/* บังคับให้ WooCommerce content area มีขนาดเต็ม */
.woocommerce-MyAccount-content,
.woocommerce-account .woocommerce-MyAccount-content {
  width: 100% !important;
  min-width: 0 !important;
  flex: 1 1 auto !important;
  overflow-x: hidden !important;
  box-sizing: border-box !important;
}

/* Portal container ปรับให้รองรับ container แคบ */
.woocommerce-MyAccount-content .sp-portal,
.woocommerce-account .sp-portal {
  min-width: 0 !important;
  width: 100% !important;
  min-height: unset !important;
}

/* sp-main ปรับ padding และ max-width ให้พอดี */
.woocommerce-MyAccount-content .sp-main,
.woocommerce-account .sp-main {
  max-width: 100% !important;
  padding: 24px 16px !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

/* ป้องกัน text wrapping แนวตั้ง */
.woocommerce-MyAccount-content .sp-section,
.woocommerce-MyAccount-content .sp-section__header,
.woocommerce-MyAccount-content h2,
.woocommerce-MyAccount-content h3 {
  word-break: keep-all !important;
  overflow-wrap: break-word !important;
  white-space: normal !important;
  min-width: 0 !important;
}

/* Header section ปรับให้ยืดหยุ่น */
.woocommerce-MyAccount-content .sp-section__header {
  flex-wrap: wrap !important;
  gap: 12px !important;
}

/* Card และ Grid ปรับให้พอดีกับ container */
.woocommerce-MyAccount-content .sp-teacher-student-card {
  overflow: hidden !important;
  min-width: 0 !important;
}

.woocommerce-MyAccount-content .sp-students-grid {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)) !important;
}

/* Input fields */
.woocommerce-MyAccount-content input[type="text"],
.woocommerce-MyAccount-content input[type="email"],
.woocommerce-MyAccount-content select,
.woocommerce-MyAccount-content textarea {
  max-width: 100% !important;
  box-sizing: border-box !important;
}

/* Responsive: หน้าจอแคบ */
@media (max-width: 768px) {
  .woocommerce-MyAccount-content .sp-main {
    padding: 16px 12px !important;
  }
}
