/*
 * styles.css - Modern, Premium CSS for Student Assignment System
 * Theme: Indigo Slate & Glassmorphism
 */

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

:root {
  /* Color Tokens */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.85);
  
  --primary: #4f46e5;       /* Indigo */
  --primary-hover: #4338ca;
  --primary-light: #e0e7ff;
  
  --secondary: #0f172a;     /* Slate */
  --secondary-light: #475569;
  
  --success: #10b981;       /* Emerald */
  --success-light: #d1fae5;
  
  --warning: #f59e0b;       /* Amber */
  --warning-light: #fef3c7;
  
  --danger: #ef4444;        /* Rose */
  --danger-light: #fee2e2;
  
  --border: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #f8fafc;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 20px -2px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 10px 10px -5px rgba(15, 23, 42, 0.04);
  --shadow-inset: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);

  --font-family: 'Inter', 'Sarabun', sans-serif;
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
}

/* Dark Mode Preference */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #0b0f19;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.85);
    
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #1e1b4b;
    
    --secondary: #f8fafc;
    --secondary-light: #94a3b8;
    
    --border: #1f2937;
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-light: #111827;
    
    --shadow-md: 0 4px 20px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.4);
  }
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.08) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.05) 0px, transparent 50%);
  background-attachment: fixed;
}

header {
  background-color: rgba(255, 255, 255, 0.01);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--primary);
}

.logo svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
}

.role-switcher {
  display: flex;
  background: var(--border);
  padding: 4px;
  border-radius: var(--radius-full);
  gap: 4px;
}

.role-btn {
  border: none;
  background: transparent;
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-full);
  font-family: var(--font-family);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all var(--transition-fast);
}

.role-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.role-btn.active {
  background: var(--bg-secondary);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* Container & Main Layout */
main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
}

/* Glass Container Cards */
.view-container {
  display: none; /* Controlled by JS */
  animation: fadeIn var(--transition-normal);
}

.view-container.active {
  display: block;
}

.card {
  background: var(--bg-card);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  box-shadow: var(--shadow-lg);
  margin-bottom: 2rem;
}

h2 {
  font-size: 1.75rem;
  margin-bottom: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--secondary);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

h2 svg {
  width: 24px;
  height: 24px;
  fill: var(--primary);
}

p.subtitle {
  color: var(--text-muted);
  margin-top: -1rem;
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

/* Form Styles */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
}

input[type="text"],
input[type="datetime-local"],
select,
textarea {
  font-family: var(--font-family);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
  transition: all var(--transition-fast);
}

input[type="text"]:focus,
input[type="datetime-local"]:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* File Upload Area */
.file-upload-wrapper {
  position: relative;
  width: 100%;
  margin-top: 0.5rem;
}

.file-upload-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 3rem 1.5rem;
  cursor: pointer;
  background: rgba(255,255,255,0.02);
  transition: all var(--transition-fast);
  text-align: center;
}

.file-upload-label:hover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.02);
}

.file-upload-label svg {
  width: 48px;
  height: 48px;
  color: var(--primary);
  margin-bottom: 1rem;
  transition: transform var(--transition-fast);
}

.file-upload-label:hover svg {
  transform: translateY(-4px);
}

.file-upload-label p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.file-upload-label p strong {
  color: var(--primary);
}

.file-upload-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-preview-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  margin-top: 1rem;
  animation: slideDown var(--transition-fast);
}

.file-preview-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #312e81; /* Dark indigo */
  font-weight: 500;
  font-size: 0.9rem;
}

.file-preview-info svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.remove-file-btn {
  background: transparent;
  border: none;
  color: var(--danger);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.remove-file-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* Deadline Warning Info Card */
.deadline-status-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  font-weight: 500;
  font-size: 0.95rem;
}

.deadline-status-banner.open {
  background-color: var(--success-light);
  color: #065f46;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.deadline-status-banner.closed {
  background-color: var(--danger-light);
  color: #991b1b;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.deadline-status-banner svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  flex-shrink: 0;
}

/* Button Styles */
.btn {
  font-family: var(--font-family);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.btn-primary {
  background: var(--primary);
  color: var(--text-light);
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.btn-primary:disabled {
  background: var(--text-muted);
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background: transparent;
  color: var(--secondary-light);
  border: 1px solid var(--border);
}

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

.btn-danger {
  background: var(--danger);
  color: var(--text-light);
}

.btn-danger:hover {
  background: #dc2626;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
}

/* Student Score Search Section */
.search-box {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.search-box input {
  flex: 1;
}

/* Score Results Styles */
.score-cards-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.score-card {
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.score-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.score-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.score-title {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--secondary);
}

.score-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-warning {
  background: var(--warning-light);
  color: #92400e;
}

.badge-success {
  background: var(--success-light);
  color: #065f46;
}

.badge-info {
  background: var(--primary-light);
  color: #3730a3;
}

.score-amount {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--success);
}

.score-amount span {
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 500;
}

.score-body {
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: center;
}

.score-feedback {
  font-size: 0.9rem;
  color: var(--secondary-light);
  background: var(--bg-primary);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
}

.score-pdf-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.875rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.score-pdf-link:hover {
  text-decoration: underline;
}

.score-pdf-link svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* Empty State Styling */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 1rem;
  opacity: 0.5;
  fill: currentColor;
}

/* Teacher View Layout */
.teacher-grid {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 2rem;
}

@media (max-width: 900px) {
  .teacher-grid {
    grid-template-columns: 1fr;
  }
}

.teacher-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.teacher-content {
  display: flex;
  flex-direction: column;
}

.filter-bar {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.filter-bar select {
  min-width: 180px;
}

/* Table Style for Assignments */
.table-wrapper {
  overflow-x: auto;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th, td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

th {
  background: rgba(0, 0, 0, 0.02);
  font-weight: 700;
  color: var(--secondary);
}

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

tr:hover td {
  background: rgba(99, 102, 241, 0.01);
}

.btn-action-table {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

/* PDF Viewer and Grading Layout (Split-Screen / Full Overlay) */
.modal-overlay {
  display: none; /* Controlled by JS */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 1.5rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-container {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 1200px;
  height: 90vh;
  display: grid;
  grid-template-rows: auto 1fr;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalSlideUp var(--transition-normal);
}

.modal-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--secondary);
}

.modal-close {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-close:hover {
  color: var(--danger);
}

.modal-close svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.modal-content-grid {
  display: grid;
  grid-template-columns: 1fr 400px;
  height: 100%;
  overflow: hidden;
}

@media (max-width: 850px) {
  .modal-content-grid {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }
}

.pdf-viewer-pane {
  background: #525659; /* Default browser pdf bg */
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
}

.pdf-viewer-pane iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.grading-pane {
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  background: var(--bg-card);
}

.student-info-summary {
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  padding: 1rem;
  border: 1px solid var(--border);
}

.student-info-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.student-info-row:last-child {
  margin-bottom: 0;
}

.student-info-row span.label {
  color: var(--text-muted);
  font-weight: 600;
}

.student-info-row span.value {
  font-weight: 600;
  color: var(--secondary);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 2000;
}

.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.5rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 500;
  font-size: 0.9rem;
  animation: slideInRight var(--transition-fast);
  max-width: 350px;
}

.toast-success {
  border-left: 4px solid var(--success);
}

.toast-error {
  border-left: 4px solid var(--danger);
}

.toast svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.toast-success svg {
  fill: var(--success);
}

.toast-error svg {
  fill: var(--danger);
}

/* Keyframes & Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideDown {
  from { transform: translateY(-10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes modalSlideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Reset / Danger Zone Settings Box */
.settings-danger-box {
  border: 1px solid var(--danger);
  border-radius: var(--radius-md);
  background: rgba(239, 68, 68, 0.02);
  padding: 1.25rem;
  margin-top: 1.5rem;
}
.settings-danger-box h3 {
  color: var(--danger);
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.settings-danger-box p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
