/* UnTedu.Web - Main Stylesheet
 * Ported from Python Flask app inline styles
 */

body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; line-height: 1.6; background-color: #e9ecef; margin: 0; color: #212529; }
.page-wrapper { display: flex; max-width: 1024px; height: 100vh; margin: 0 auto; background-color: #f8f9fa; box-shadow: 0 0 20px rgba(0, 0, 0, 0.1); overflow: hidden; }
.sidebar { width: 280px; flex-shrink: 0; background-color: #f1f3f5; border-right: 1px solid #dee2e6; display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.sidebar h2 { margin: 16px 0px 8px 0px; font-size: 1.2em; color: #495057; flex-shrink: 0; }
.sidebar h3 { margin: 0; font-size: 0.9em; color: #495057; flex-shrink: 0; }
#generateForm { display: flex; flex-direction: column; flex-grow: 1; overflow: hidden; padding: 0 25px; }
#sidebar-options { flex-grow: 1; overflow-y: auto; padding: 20px 5px 20px 0; transition: opacity 0.3s ease-in-out; opacity: 0.5; pointer-events: none; margin-right: -25px; padding-right: 25px; }
#sidebar-options.active { opacity: 1; pointer-events: auto; }
.sidebar-footer { flex-shrink: 0; padding: 15px 0 25px 0; border-top: 1px solid #dee2e6; background-color: #f1f3f5; }
.main-content { flex-grow: 1; padding: 30px 40px; background-color: #ffffff; overflow-y: auto; height: 100%; display: block; }
h1 { text-align: center; color: #343a40; margin-bottom: 30px; font-size: 1.8em; margin-top: 0; }
.container { background-color: #ffffff; padding: 25px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08); margin-bottom: 30px; }
#preview-area { margin-top: 30px; border-top: 2px solid #eee; padding-top: 20px; display: none; }
#preview-area h2 { text-align: left; margin-top: 0; }
#preview-area .group-title { color: #155724; background-color: #d4edda; padding: 1px 12px; border-radius: 3px; font-size: 1.2em; }
#preview-area .content-desc { margin-left: 15px; }
.form-group { margin-bottom: 8px; }
label { display: block; margin-bottom: 6px; font-weight: 600; color: #495057; font-size: 0.9em; }
input[type="file"], input[type="number"], input[type="text"], textarea, button { display: block; width: 100%; padding: 9px; border: 1px solid #ced4da; border-radius: 4px; box-sizing: border-box; font-size: 0.95rem; margin-top: 4px; }
select { display: block; width: 100%; padding: 9px; border: 1px solid #ced4da; border-radius: 4px; box-sizing: border-box; font-size: 0.95rem; margin-top: 4px; background-color: white; }
input[type="file"] { padding: 6px; }
input[type="checkbox"] { margin-right: 8px; vertical-align: middle; }
label.checkbox-label { display: inline-block; margin-bottom: 0; font-weight: normal; font-size: 0.95em; }
textarea { min-height: 50px; resize: vertical; }
#generateButton { background-color: #28a745; color: white; border: none; font-size: 1.1rem; font-weight: 600; cursor: pointer; transition: background-color 0.2s; margin-top: 0; padding: 12px 15px; }
#generateButton:hover:not(:disabled) { background-color: #218838; }
#generateButton:disabled { background-color: #6c757d; cursor: not-allowed; }
#previewButton { background-color: #007bff; color: white; border: none; font-size: 1.05rem; font-weight: 600; cursor: pointer; transition: background-color 0.2s; margin-top: 10px; padding: 11px 15px; }
#previewButton:hover:not(:disabled) { background-color: #0056b3; }
#previewButton:disabled { background-color: #6c757d; cursor: not-allowed; }
small { color: #6c757d; font-size: 0.85em; display: block; margin-top: 3px; }
.flash-messages { list-style: none; padding: 0; margin: 0 0 20px 0; }
.flash-messages li { padding: 12px 15px; margin-bottom: 10px; border-radius: 4px; border: 1px solid transparent; font-size: 0.95rem; }
.flash-messages .error { background-color: #f8d7da; color: #721c24; border-color: #f5c6cb; }
.flash-messages .warning { background-color: #fff3cd; color: #856404; border-color: #ffeeba; }
#loading_preview, #loading_generate { display: none; text-align: center; margin: 10px 0 0 0; padding: 8px; background-color: #e9ecef; border-radius: 4px; font-style: italic; color: #495057; font-size: 0.9em; }
.spinner { display: inline-block; border: 3px solid #f3f3f3; border-top: 3px solid #007bff; border-radius: 50%; width: 16px; height: 16px; animation: spin 1s linear infinite; vertical-align: middle; margin-right: 8px; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Preview styles */
.question-block { border: 1px solid #eee; padding: 15px; margin-bottom: 15px; border-radius: 5px; background-color: #fdfdfd; }
.options ul, .statements ul { list-style: none; padding-left: 15px; margin-top: 5px; }
.options li, .statements li { margin-bottom: 5px; }
.correct-answer-preview { color: #155724; background-color: #d4edda; padding: 1px 4px; border-radius: 3px; font-size: 0.9em; margin-left: 5px; }
.tf-answer-preview { font-weight: bold; margin-left: 5px; }
.tf-answer-preview.correct { color: #155724; }
.tf-answer-preview.incorrect { color: #721c24; }
.placeholder-preview { color: #007bff; font-style: italic; margin: 0 3px; background-color: #e9ecef; padding: 1px 4px; border: 1px dashed #adb5bd; border-radius: 3px; display: inline-block; font-size: 0.9em; }
span[style*="vertical-align: super"], span[style*="vertical-align: sub"] { font-size: smaller; line-height: normal; }

/* Table and list preview */
.preview-table {
  border-collapse: collapse;
  margin: 0.5em 0 0.8em 0;
  width: auto;
  max-width: 100%;
  border: 1px solid #ccc;
  font-size: 0.95em;
}
.preview-table td {
  border: 1px solid #ccc;
  padding: 5px 7px;
  vertical-align: top;
}
.preview-table td > div,
.preview-table td > p,
.preview-table td > table {
  margin-bottom: 0.3em;
  margin-left: 0 !important;
  text-indent: 0 !important;
}
.preview-table td > *:last-child {
  margin-bottom: 0;
}
.preview-list-item {
  display: block;
  margin-bottom: 0.3em;
}
.preview-list-marker {
  display: inline-block;
  width: 1.5em;
  text-align: right;
  margin-right: 0.5em;
  user-select: none;
  font-weight: bold;
}
.mobile-header {
  display: none;
  background-color: #08509F;
  padding: 5px 15px;
  border-bottom: 1px solid #dee2e6;
}

/* Toggle button - hidden on desktop */
.sidebar-toggle-button {
  display: none;
}

/* Responsive (mobile <= 768px) */
@media (max-width: 768px) {
  .mobile-header {
    display: block;
  }
  .mobile-header #center-logo-container {
    background-color: transparent !important;
    padding: 5px 0px 0px 0px !important;
    text-align: center;
    border: none;
  }
  .mobile-header #sidebar-logo {
    max-height: 40px !important;
    max-width: 60% !important;
  }
  #sidebar #sidebar-logo-container {
    display: none;
  }
  .main-content {
    padding-top: 15px;
  }
  .sidebar-toggle-button {
    display: block;
    position: fixed;
    bottom: 0px;
    transform: scale(0.7) translateY(10px);
    right: auto;
    z-index: 1001;
    background-color: #28a745;
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
    border-radius: 5px;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
    opacity: 0;
    pointer-events: none;
    transition: background-color 0.2s;
  }
  .sidebar-toggle-button:hover {
    background-color: #0056b3;
  }
  .sidebar-toggle-button.visible {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1) translateY(0);
  }
  body.sidebar-open .sidebar-toggle-button {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: scale(0.7) translateY(10px) !important;
  }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 280px;
    height: 100%;
    max-height: 100%;
    z-index: 1000;
    background-color: #f1f3f5;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    box-shadow: 3px 0 6px rgba(0,0,0,0.15);
    border-right: 1px solid #dee2e6;
    overflow-y: auto;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  body.sidebar-open::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 999;
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
  }
  .page-wrapper {
    flex-direction: column;
    height: auto;
    overflow: visible;
  }
  .main-content {
    padding-top: 15px;
    padding-bottom: 80px;
  }
  #sidebar-logo-container {
    position: sticky;
    top: 0;
    z-index: 10;
  }
}
