@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600;700&family=Open+Sans:ital,wght@0,400;0,600;1,400&display=swap');

:root {
  --bg-color: #f7f9fc;
  --glass-bg: #ffffff;
  --glass-border: #e0e0e0;
  --text-main: #5a5a5a;
  --text-dim: #8b949e;
  --primary: #fcbc22;
  --primary-hover: #e5a81a;
  --success: #2ea043;
  --error: #f85149;
  --radius: 12px;
  --font-family: 'Open Sans', sans-serif;
  --font-header: 'Montserrat', sans-serif;
  --bular-light-yellow: #fff9e6;
  --bular-black: #000000;
}

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

body {
  font-family: var(--font-family);
  background: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.6;
}

h1, h2, h3, h4 {
  font-family: var(--font-header);
  color: var(--bular-black);
}

#app { width: 100%; height: 100%; display: flex; justify-content: center; align-items: flex-start; padding-top: 2rem; }

.screen { display: none; width: 100%; max-width: 1200px; padding: 0 2rem 2rem 2rem; }
.screen.active { display: block; animation: fadeIn 0.4s ease-out; }

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

.glass-panel {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

/* --- LOGIN --- */
.login-card {
  max-width: 400px;
  margin: 10vh auto 0;
  text-align: center;
}
.logo { margin-bottom: 2rem; color: var(--bular-black); }
.logo svg { margin-bottom: 0.5rem; color: var(--primary); }
form input {
  width: 100%; padding: 12px 16px; margin-bottom: 1rem;
  background: #fff; border: 1px solid var(--glass-border);
  border-radius: 8px; color: var(--text-main); font-size: 1rem;
  transition: border-color 0.2s;
}
form input:focus { outline: none; border-color: var(--primary); }
form button, .btn-primary {
  width: 100%; padding: 12px; background: var(--primary); color: #000;
  border: none; border-radius: 8px; font-weight: 600; cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
form button:hover, .btn-primary:hover:not(:disabled) { background: var(--primary-hover); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.error-msg { color: var(--error); font-size: 0.9rem; min-height: 1.5rem; margin-top: 0.5rem; }

/* --- DASHBOARD --- */
.header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 2rem; margin-bottom: 2rem;
}
.header h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: 1px; color: var(--bular-black); text-transform: uppercase; margin-bottom: 0; border-bottom: none; padding-bottom: 0;}
.user-info { display: flex; align-items: center; gap: 1rem; }
.user-stack { display: flex; flex-direction: column; align-items: center; gap: 4px; }
#user-badge { font-size: 0.8rem; color: var(--text-dim); }
.header-btn { margin-top: 0 !important; }
.btn-secondary { background: transparent; border: 1px solid var(--glass-border); color: var(--text-main); padding: 4px 12px; border-radius: 6px; cursor: pointer; transition: 0.2s; font-family: var(--font-family); font-size: 0.85rem;}
.btn-secondary:hover { background: #f0f0f0; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 2rem;
  align-items: start;
}
.main-panel h2, .sidebar-panel h2 { 
  font-size: 1.25rem; font-weight: 600; margin-bottom: 1.5rem; margin-top: 0;
  background-color: var(--bular-light-yellow);
  border-left: 5px solid var(--primary);
  padding: 10px 15px;
  border-radius: 0 4px 4px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Drop Zone */
.drop-zone {
  border: 2px dashed var(--glass-border);
  border-radius: var(--radius);
  padding: 3rem 1rem; text-align: center;
  transition: all 0.3s ease;
  background: #fafafa;
  margin-bottom: 2rem;
}
.drop-zone.dragover {
  border-color: var(--primary);
  background: var(--bular-light-yellow);
  transform: scale(1.02);
}
.drop-zone svg { color: var(--text-dim); margin-bottom: 1rem; }
.drop-zone p { color: var(--text-dim); margin-bottom: 0.5rem; }
.or-text { font-size: 0.85rem; color: var(--text-dim); margin: 0 1rem; }
.btn-outline { font-family: var(--font-family); font-weight: 600; background: transparent; border: 1px solid var(--primary); color: #000; padding: 8px 16px; border-radius: 6px; cursor: pointer; transition: 0.2s; margin-top: 1rem; }
.btn-outline:hover { background: var(--bular-light-yellow); }

.instruction-btn {
  background: transparent; border: none; font-size: 0.9rem; color: var(--primary); text-decoration: underline; cursor: pointer; float: right; font-weight: 600; margin-top: 4px; font-family: var(--font-family);
}
.instruction-btn:hover { color: var(--primary-hover); }

/* Queue */
.queue-list { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 2rem; }
.glass-card {
  background: #fff;
  border: 1px solid var(--glass-border);
  padding: 1rem; border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}
.queue-info, .history-info { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.queue-filename { font-weight: 600; font-size: 0.95rem; color: var(--bular-black); }
.queue-status { font-size: 0.85rem; color: var(--text-dim); font-weight: 600; }
.queue-status.completed { color: var(--success); }
.queue-status.error { color: var(--error); }
.queue-details { font-size: 0.85rem; color: var(--text-main); margin-top: 0.5rem; display: flex; justify-content: space-between; }
.queue-timer { font-weight: 600; color: var(--bular-black); }

.progress-bar-container { width: 100%; height: 8px; background: #e0e0e0; border-radius: 4px; overflow: hidden; margin-top: 8px; }
.progress-bar { height: 100%; width: 0%; background: var(--primary); transition: width 0.4s ease; }

.download-link {
  display: inline-block; margin-top: 0.75rem; color: var(--success);
  text-decoration: none; font-size: 0.9rem; font-weight: 600;
}
.download-link:hover { text-decoration: underline; }
.hidden { display: none !important; }

/* History */
.sidebar-panel { position: relative; }
.history-controls {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem;
}
.history-filters {
  display: flex; gap: 0.5rem;
}
.filter-btn {
  background: transparent; border: 1px solid var(--glass-border); color: var(--text-main); padding: 4px 10px; border-radius: 4px; cursor: pointer; font-size: 0.8rem;
}
.filter-btn.active {
  background: var(--primary); border-color: var(--primary); color: #000; font-weight: 600;
}
.clear-history-btn {
  background: transparent; border: none; color: var(--error); cursor: pointer; font-size: 0.8rem; text-decoration: underline;
}

.history-list { display: flex; flex-direction: column; gap: 0.75rem; max-height: 500px; overflow-y: auto; padding-right: 5px; }
.history-list::-webkit-scrollbar { width: 6px; }
.history-list::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

.history-item { padding: 0.75rem 1rem; cursor: pointer; transition: background 0.2s; }
.history-item:hover { background: #fafafa; }
.history-filename { font-size: 0.9rem; display: block; margin-bottom: 0.25rem; word-break: break-all; font-weight: 600; color: var(--bular-black) }
.history-date { font-size: 0.75rem; color: var(--text-dim); }
.history-actions { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 6px; margin-top: 0.5rem; }
.history-status { font-size: 0.8rem; font-weight: 600; color: var(--text-dim); }
.history-status.completed { color: var(--success); }
.history-status.error { color: var(--error); }
.history-actions .download-link { margin-top: 0; font-size: 0.85rem; }

/* Report Summary */
.history-report {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--glass-border);
  font-size: 0.85rem;
  display: none;
  cursor: default;
}
.history-item.expanded .history-report {
  display: block;
  animation: fadeIn 0.3s;
}

.report-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px;
}
.report-stat {
  background: #f8f9fa; padding: 6px; border-radius: 4px;
}
.report-stat-label { font-size: 0.75rem; color: var(--text-dim); display: block; }
.report-stat-val { font-weight: 600; color: var(--bular-black); font-size: 0.9rem; }

.report-system { margin-top: 8px; }
.report-warnings { margin-top: 8px; color: var(--error); background: #fff5f5; padding: 6px; border-left: 3px solid var(--error); border-radius: 4px; }
.report-tokens { margin-top: 8px; font-size: 0.75rem; color: var(--text-dim); text-align: right; }

/* Modal */
.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; opacity: 0; pointer-events: none; transition: 0.3s;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal-content {
  background: #fff; width: 90%; max-width: 600px;
  border-radius: var(--radius); padding: 2rem; position: relative;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  transform: translateY(20px); transition: 0.3s;
  max-height: 90vh; overflow-y: auto;
}
.modal-overlay.active .modal-content { transform: translateY(0); }
.modal-close {
  position: absolute; top: 1.5rem; right: 1.5rem; background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-dim);
}
.modal-close:hover { color: var(--bular-black); }

.modal-content h2 { border-left: none; background: transparent; padding: 0; margin-top: 0; }
.modal-content ul { list-style-type: none; padding-left: 0; }
.modal-content ul li { padding-left: 1.5em; position: relative; margin-bottom: 12px; }
.modal-content ul li::before { content: "■"; color: var(--primary); position: absolute; left: 0; top: 1px; font-size: 0.8em; }
.modal-content p, .modal-content li { font-size: 0.95rem; }

@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .header { padding: 1rem; flex-direction: column; gap: 1rem; align-items: flex-start; }
  .user-info { flex-wrap: wrap; width: 100%; justify-content: space-between; }
}
@media (max-width: 500px) {
  .report-grid { grid-template-columns: 1fr; }
  .history-actions { flex-direction: column; align-items: flex-start; gap: 8px; }
}
.progress-bar.error { background: var(--error); }
.queue-item.error { border-color: rgba(248,81,73,0.3); }
