/* 
 * APP_Repair Modern Premium Design Stylesheet
 * Responsive glassmorphism, fluid animations, and dark/light color systems.
 */

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

:root {
  /* Design Tokens (Dark Theme Defaults) */
  --font-primary: 'Outfit', 'Sarabun', sans-serif;
  
  --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #020617 100%);
  --panel-bg: rgba(30, 41, 59, 0.45);
  --panel-border: rgba(255, 255, 255, 0.08);
  --panel-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --backdrop-blur: blur(12px);
  
  --color-primary: #3b82f6;
  --color-primary-hover: #60a5fa;
  --color-primary-grad: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  
  --color-success: #10b981;
  --color-success-grad: linear-gradient(135deg, #10b981 0%, #047857 100%);
  
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-danger-grad: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dark: #0f172a;
  
  --input-bg: rgba(15, 23, 42, 0.6);
  --input-border: rgba(255, 255, 255, 0.15);
  --input-focus-border: #3b82f6;
  
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Light Theme overrides */
[data-theme="light"] {
  --bg-gradient: linear-gradient(135deg, #f0f4f8 0%, #e2e8f0 50%, #cbd5e1 100%);
  --panel-bg: rgba(255, 255, 255, 0.7);
  --panel-border: rgba(15, 23, 42, 0.08);
  --panel-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.08);
  --text-main: #0f172a;
  --text-muted: #64748b;
  --input-bg: rgba(255, 255, 255, 0.9);
  --input-border: rgba(15, 23, 42, 0.15);
}

/* Base resets */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: var(--font-primary);
  -webkit-tap-highlight-color: transparent;
}

body {
  background: var(--bg-gradient);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  transition: background 0.5s ease;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--panel-border);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary);
}

/* Core Container & Layouts */
.app-container {
  width: 100%;
  max-width: 480px; /* Mobile focused container width */
  margin: 0 auto;
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Make container wider for Admin dashboard view */
.app-container.admin-expanded {
  max-width: 1200px;
}

/* Header Component */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  animation: fadeInDown 0.5s ease;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-section h1 {
  font-size: 24px;
  font-weight: 700;
  background: linear-gradient(to right, #60a5fa, #34d399);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--color-primary-grad);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}

.theme-toggle-btn {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-main);
  cursor: pointer;
  box-shadow: var(--panel-shadow);
  backdrop-filter: var(--backdrop-blur);
  transition: var(--transition-smooth);
}

.theme-toggle-btn:hover {
  transform: rotate(30deg) scale(1.05);
}

/* Glassmorphic Panel Wrapper */
.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--panel-shadow);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  margin-bottom: 20px;
  animation: scaleIn 0.4s var(--transition-bounce);
}

/* Page states handling */
.page-state {
  display: none;
  width: 100%;
}
.page-state.active {
  display: block;
}

/* Login Page Styling */
.login-title-section {
  text-align: center;
  margin-bottom: 28px;
}

.login-title-section h2 {
  font-size: 26px;
  font-weight: 700;
  margin-top: 10px;
}

.login-title-section p {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

/* Form Styles */
.form-group {
  margin-bottom: 20px;
  position: relative;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-control {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 15px;
  color: var(--text-main);
  outline: none;
  transition: var(--transition-smooth);
}

.input-control:focus {
  border-color: var(--input-focus-border);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.input-icon-wrapper {
  position: relative;
}

.input-icon-wrapper .input-control {
  padding-left: 44px;
}

.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  display: flex;
}

/* Action Buttons */
.btn {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 16px;
  font-weight: 600;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition-bounce);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

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

.btn-primary {
  background: var(--color-primary-grad);
}
.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.btn-success {
  background: var(--color-success-grad);
}
.btn-success:hover {
  filter: brightness(1.1);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.btn-danger {
  background: var(--color-danger-grad);
}
.btn-danger:hover {
  filter: brightness(1.1);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.btn-secondary {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Segmented steps or sections for job filling */
.section-title {
  font-size: 16px;
  font-weight: 700;
  margin: 24px 0 14px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--panel-border);
  color: var(--color-primary-hover);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title:first-of-type {
  margin-top: 0;
}

/* Checkbox Switch (iOS premium style) */
.switch-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  transition: var(--transition-smooth);
}

.switch-group:hover {
  background: rgba(255, 255, 255, 0.06);
}

.switch-label {
  font-size: 14px;
  font-weight: 500;
}

.switch-control {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 24px;
}

.switch-control input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #475569;
  transition: .3s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--color-success);
}

input:checked + .slider:before {
  transform: translateX(22px);
}

/* Segmented Buttons Selector (Warranty Status) */
.segmented-control {
  display: flex;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 4px;
}

.segmented-option {
  flex: 1;
  text-align: center;
  padding: 8px 0;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition-smooth);
  color: var(--text-muted);
}

.segmented-option.active {
  color: #ffffff;
}

.segmented-option[data-val="Intact"].active {
  background: var(--color-success);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
}
.segmented-option[data-val="Broken"].active {
  background: var(--color-warning);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}
.segmented-option[data-val="None"].active {
  background: var(--color-danger);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

/* Profile / Dashboard Head Info */
.dashboard-user-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--panel-border);
}

.user-name-title {
  display: flex;
  flex-direction: column;
}

.user-name-title span:first-child {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.user-name-title span:last-child {
  font-size: 18px;
  font-weight: 700;
}

.badge-role {
  background: rgba(59, 130, 246, 0.2);
  color: var(--color-primary-hover);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

/* Part clicking items list */
.parts-container {
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 16px;
}

.part-item-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  margin-bottom: 8px;
  animation: slideInLeft 0.3s ease;
}

.part-item-row:last-child {
  margin-bottom: 0;
}

.part-delete-btn {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--color-danger);
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.part-delete-btn:hover {
  background: var(--color-danger);
  color: #ffffff;
}

/* Photo Gallery & Thumbnail */
.photo-upload-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.photo-upload-box {
  background: rgba(255, 255, 255, 0.03);
  border: 2px dashed var(--panel-border);
  border-radius: var(--radius-sm);
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: var(--transition-smooth);
  color: var(--text-muted);
}

.photo-upload-box:hover {
  border-color: var(--color-primary);
  background: rgba(59, 130, 246, 0.05);
  color: var(--color-primary-hover);
}

.photo-preview {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  animation: zoomIn 0.3s ease;
}

.photo-delete-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(239, 68, 68, 0.9);
  color: #ffffff;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: bold;
  cursor: pointer;
  z-index: 5;
}

/* Admin Dashboard Elements */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.analytic-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.analytic-card .title {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.analytic-card .value {
  font-size: 24px;
  font-weight: 700;
}

/* Filter controls bar */
.filter-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

@media (min-width: 768px) {
  .filter-bar {
    flex-direction: row;
    align-items: center;
  }
}

/* Data List & Responsive Card layout */
.records-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.record-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: var(--transition-bounce);
}

.record-card:hover {
  transform: translateY(-2px);
  border-color: rgba(59, 130, 246, 0.3);
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.record-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.record-title {
  font-weight: 700;
  font-size: 15px;
}

.record-meta {
  display: flex;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.record-badges-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Badges */
.badge {
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
}

.badge-success {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.badge-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.badge-info {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
}

/* Modal Popup Window */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

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

.modal-content {
  background: var(--bg-gradient);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 24px;
  width: 100%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  animation: scaleIn 0.3s var(--transition-bounce);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 24px;
  display: flex;
}

.modal-close-btn:hover {
  color: var(--text-main);
}

/* Loader Widget */
.spinner-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.spinner-wrapper.active {
  display: flex;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 5px solid rgba(59, 130, 246, 0.2);
  border-radius: 50%;
  border-top-color: var(--color-primary);
  animation: spin 0.8s linear infinite;
}

/* Animations */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes scaleIn {
  from { transform: scale(0.93); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

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

@keyframes slideInLeft {
  from { transform: translateX(-15px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes zoomIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Table layout style for Desktop Admin views */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.2);
  margin-top: 10px;
  display: none; /* Only visible on larger screens */
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

.admin-table th {
  background: rgba(15, 23, 42, 0.8);
  padding: 14px 16px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--panel-border);
}

.admin-table td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  vertical-align: middle;
}

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

@media (min-width: 768px) {
  .app-container.admin-expanded {
    padding: 30px;
  }
  .table-responsive {
    display: block;
  }
  .records-container.admin-card-view {
    display: none;
  }
}
