/**
 * Admin Panel Styles
 * Professional admin UI for managing the Limousine Chat Widget
 * Requirements: 5.5
 * Version: 2.2 - Fixed main content width
 */

/* CSS Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-primary: #1a1a2e;
  --color-secondary: #e94560;
  --color-bg: #f5f5f7;
  --color-surface: #ffffff;
  --color-text: #1a1a2e;
  --color-text-muted: #6b7280;
  --color-border: #e5e7eb;
  --color-success: #10b981;
  --color-error: #ef4444;
  --color-warning: #f59e0b;
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --sidebar-width: 260px;
  --transition: all 0.2s ease;
}

body {
  font-family: var(--font-family);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ==================== LOGIN SECTION ==================== */
.login-section {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, var(--color-primary) 0%, #16213e 100%);
}

.login-section[hidden] {
  display: none !important;
}

/* ==================== DASHBOARD SECTION ==================== */
.dashboard-section {
  display: block;
  min-height: 100vh;
}

.dashboard-section[hidden] {
  display: none !important;
}

.login-container {
  width: 100%;
  max-width: 400px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-lg);
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.login-header .subtitle {
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.login-hint {
  text-align: center;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 16px;
}



/* ==================== SIDEBAR ==================== */
.sidebar {
  background: var(--color-primary);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  width: var(--sidebar-width);
  height: 100vh;
  overflow-y: auto;
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-header h1 {
  font-size: 1.1rem;
  font-weight: 600;
}

.badge {
  background: var(--color-secondary);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.nav-item.active {
  background: var(--color-secondary);
  color: white;
}

.nav-icon {
  font-size: 1.1rem;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* ==================== MAIN CONTENT ==================== */
.main-content {
  margin-left: var(--sidebar-width);
  padding: 32px;
  min-height: 100vh;
  width: calc(100% - var(--sidebar-width));
  overflow-x: hidden;
}

.content-header {
  margin-bottom: 24px;
}

.content-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.content-header p {
  color: var(--color-text-muted);
}

/* ==================== TAB CONTENT ==================== */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ==================== CARDS ==================== */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  margin-bottom: 24px;
}

.card h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.card-description {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card-header h3 {
  margin-bottom: 0;
}

.header-actions {
  display: flex;
  gap: 8px;
}

/* ==================== FORMS ==================== */
.form-group {
  margin-bottom: 16px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--color-text);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group input[type="date"],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.95rem;
  font-family: inherit;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  transition: var(--transition);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--color-secondary);
  box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.1);
}

.form-group textarea {
  resize: vertical;
  min-height: 120px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.char-counter {
  text-align: right;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* Color Input */
.color-input {
  display: flex;
  gap: 8px;
}

.color-input input[type="color"] {
  width: 48px;
  height: 40px;
  padding: 2px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.color-input input[type="text"] {
  flex: 1;
}

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--color-secondary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: #d63d56;
}

.btn-secondary {
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-border);
}

.btn-danger {
  background: var(--color-error);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
}

.btn-full {
  width: 100%;
}

.btn-small {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.btn-icon {
  background: none;
  border: none;
  padding: 4px 8px;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 1rem;
  transition: var(--transition);
}

.btn-icon:hover {
  color: var(--color-text);
}

.link-btn {
  background: none;
  border: none;
  color: var(--color-secondary);
  cursor: pointer;
  font-size: inherit;
  font-family: inherit;
  text-decoration: underline;
}

.link-btn:hover {
  color: #d63d56;
}

/* Spinner */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==================== MESSAGES ==================== */
.error-message {
  background: #fef2f2;
  color: var(--color-error);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  border: 1px solid #fecaca;
}

.success-message {
  background: #ecfdf5;
  color: var(--color-success);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  border: 1px solid #a7f3d0;
}

.placeholder {
  color: var(--color-text-muted);
  text-align: center;
  padding: 40px 20px;
}

/* ==================== UPLOAD AREA ==================== */
.upload-area {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 16px;
}

.upload-area:hover,
.upload-area.dragover {
  border-color: var(--color-secondary);
  background: rgba(233, 69, 96, 0.05);
}

.upload-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.upload-text {
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.upload-hint {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.selected-file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.file-name {
  font-size: 0.9rem;
  font-weight: 500;
}

/* ==================== FILES LIST ==================== */
.files-list {
  min-height: 100px;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--color-border);
}

.file-item:last-child {
  border-bottom: none;
}

.file-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-icon {
  font-size: 1.5rem;
}

.file-details h4 {
  font-size: 0.95rem;
  font-weight: 500;
  margin-bottom: 2px;
}

.file-meta {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.file-status {
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
}

.file-status.ready {
  background: #ecfdf5;
  color: var(--color-success);
}

.file-status.processing {
  background: #fef3c7;
  color: var(--color-warning);
}

.file-status.error {
  background: #fef2f2;
  color: var(--color-error);
}

.file-actions {
  display: flex;
  gap: 8px;
}

/* ==================== LOGS LIST ==================== */
.logs-list {
  min-height: 200px;
}

.log-item {
  padding: 16px;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: var(--transition);
}

.log-item:hover {
  background: var(--color-bg);
}

.log-item:last-child {
  border-bottom: none;
}

.log-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.log-session {
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.log-timestamp {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.log-preview {
  font-size: 0.9rem;
  color: var(--color-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.log-meta {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* Filter Form */
.filter-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.filter-actions {
  display: flex;
  gap: 12px;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
  margin-top: 16px;
}

.page-info {
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

/* ==================== MODAL ==================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.modal-content {
  position: relative;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-border);
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-close {
  font-size: 1.2rem;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

/* Log Detail in Modal */
.log-detail-section {
  margin-bottom: 24px;
}

.log-detail-section:last-child {
  margin-bottom: 0;
}

.log-detail-section h4 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.log-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.log-message {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.log-message.user {
  background: var(--color-secondary);
  color: white;
  margin-left: 20%;
}

.log-message.assistant {
  background: var(--color-bg);
  margin-right: 20%;
}

.log-data {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 16px;
  border-radius: var(--radius-sm);
  font-family: monospace;
  font-size: 0.85rem;
  white-space: pre-wrap;
  overflow-x: auto;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1024px) {
  .dashboard-section {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    width: 100%;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .sidebar-header {
    width: 100%;
    border-bottom: none;
    padding: 16px 24px;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0 16px 16px;
    width: 100%;
  }

  .nav-item {
    flex: 1;
    min-width: 100px;
    justify-content: center;
  }

  .nav-text {
    display: none;
  }

  .sidebar-footer {
    display: none;
  }

  .main-content {
    margin-left: 0;
    padding: 24px;
  }
}

@media (max-width: 640px) {
  .login-container {
    padding: 24px;
  }

  .main-content {
    padding: 16px;
  }

  .card {
    padding: 16px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .filter-actions {
    flex-direction: column;
  }

  .header-actions {
    flex-wrap: wrap;
  }

  .log-message.user {
    margin-left: 10%;
  }

  .log-message.assistant {
    margin-right: 10%;
  }
}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}
