/* ============================================================
   KonaConv — Auth, Admin, History & Modal Styles
   Uses CSS variables from style.css
   ============================================================ */

/* ----- Login Page ----- */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.login-logo .logo-icon {
  display: flex;
  align-items: center;
}

.login-logo h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.login-logo .login-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.form-group input {
  width: 100%;
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 0.65rem 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs, 6px);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s ease;
}

.form-group input:focus {
  border-color: var(--highlight);
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.login-error {
  color: var(--error);
  font-size: 0.85rem;
  font-weight: 500;
  min-height: 1.25rem;
  margin-bottom: 0.75rem;
}

.btn-login {
  width: 100%;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  padding: 0.8rem;
  background: var(--highlight);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm, 8px);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.btn-login:hover {
  background: var(--highlight-hover);
}

.btn-login:active {
  transform: scale(0.97);
}

.btn-login:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ----- User Menu (in header) ----- */
.user-menu {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.btn-logout {
  color: var(--highlight) !important;
}

.btn-logout:hover {
  color: var(--highlight-hover) !important;
}

/* ----- History Section ----- */
.history-section {
  display: none;
  margin-top: 1.5rem;
  padding: 1.5rem;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.history-section.visible {
  display: block;
  animation: fadeSlideIn 0.3s ease;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.history-header .section-title {
  margin-bottom: 0;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 400px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.85rem;
  background: var(--bg-card);
  border-radius: var(--radius-sm, 8px);
  border: 1px solid var(--border);
}

.history-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}

.history-date {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.history-files {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.history-status {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
}

.history-status.completed {
  color: var(--success);
  background: rgba(16, 185, 129, 0.12);
}

.history-status.failed {
  color: var(--error);
  background: rgba(239, 68, 68, 0.1);
}

.history-status.processing {
  color: #60a5fa;
  background: rgba(96, 165, 250, 0.12);
}

.history-saved {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--success);
}

.history-actions {
  flex-shrink: 0;
}

.history-empty {
  color: var(--text-muted);
  font-size: 0.88rem;
  text-align: center;
  padding: 1.5rem 0;
}

/* ----- Admin Badge ----- */
.admin-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.55rem;
  background: var(--highlight);
  color: #fff;
  border-radius: 20px;
  margin-left: 0.5rem;
  vertical-align: middle;
}

/* ----- Admin Navigation ----- */
.admin-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.admin-nav .btn-text {
  font-size: 0.85rem;
}

/* ----- Admin Stats ----- */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.35rem;
}

/* ----- Admin Sections ----- */
.admin-section {
  margin-top: 2rem;
}

.admin-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.admin-section-header .section-title {
  margin-bottom: 0;
}

/* ----- Admin Table ----- */
.admin-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm, 8px);
  border: 1px solid var(--border);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.admin-table th {
  background: var(--bg-input);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.75rem 1rem;
  text-align: left;
  white-space: nowrap;
}

.admin-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  white-space: nowrap;
}

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

.admin-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* ----- Role Badge ----- */
.role-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
}

.role-badge.admin {
  color: var(--highlight);
  background: rgba(233, 69, 96, 0.12);
}

.role-badge.user {
  color: var(--text-secondary);
  background: var(--bg-input);
}

/* ----- Status Badge ----- */
.status-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
}

.status-badge.completed {
  color: var(--success);
  background: rgba(16, 185, 129, 0.12);
}

.status-badge.failed {
  color: var(--error);
  background: rgba(239, 68, 68, 0.1);
}

.status-badge.processing {
  color: #60a5fa;
  background: rgba(96, 165, 250, 0.12);
}

.status-badge.pending {
  color: var(--text-secondary);
  background: var(--bg-input);
}

/* ----- Small Button ----- */
.btn-sm {
  font-size: 0.78rem;
  padding: 0.35rem 0.65rem;
}

/* ----- Danger Button ----- */
.btn-danger {
  color: var(--error) !important;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* ----- Modal Overlay ----- */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1.5rem;
}

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

.modal-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  animation: fadeSlideIn 0.25s ease;
}

.modal-card h2 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1.25rem;
}

.modal-error {
  color: var(--error);
  font-size: 0.85rem;
  font-weight: 500;
  min-height: 1.25rem;
  margin-bottom: 0.5rem;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

/* ----- Admin Header ----- */
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.admin-header .logo {
  font-size: 1.6rem;
  justify-content: flex-start;
}

.admin-main {
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
}

/* ----- Responsive: Admin ----- */
@media (max-width: 768px) {
  .admin-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .admin-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .admin-nav {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 480px) {
  .admin-stats {
    grid-template-columns: 1fr;
  }

  .login-card {
    padding: 1.5rem;
  }

  .modal-card {
    padding: 1.5rem;
  }

  .history-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .history-info {
    gap: 0.5rem;
  }
}
