/* ===== Global Reset & Variables ===== */
:root {
  --primary: #00d4ff;
  --primary-light: #66e5ff;
  --primary-dark: #0099cc;
  --accent: #a855f7;
  --bg: #0a0e1a;
  --bg-elevated: #0f1525;
  --card-bg: #141927;
  --card-bg-hover: #1a2138;
  --text: #e2e8f0;
  --text-light: #94a3b8;
  --text-muted: #64748b;
  --border: #2a3650;
  --border-light: #1e293b;
  --success: #00e676;
  --danger: #ff4757;
  --warning: #ffab00;
  --shadow: 0 2px 12px rgba(0,212,255,0.08);
  --shadow-lg: 0 4px 24px rgba(0,212,255,0.15);
  --glow: 0 0 20px rgba(0,212,255,0.25);
  --radius: 8px;
}

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

body {
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  background-image:
    linear-gradient(rgba(0,212,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,212,255,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-elevated); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-dark); }

/* ===== Login Page ===== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #050810;
  position: relative;
  overflow: hidden;
}

.login-page #particleCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: auto;
}

.login-card {
  position: relative;
  z-index: 1;
  background: rgba(20,25,39,0.85);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 380px;
  box-shadow: 0 8px 40px rgba(0,212,255,0.12), inset 0 1px 0 rgba(255,255,255,0.05);
}

.login-card h1 {
  text-align: center;
  color: var(--primary);
  font-size: 24px;
  margin-bottom: 8px;
  text-shadow: 0 0 20px rgba(0,212,255,0.4);
}

.login-card .subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 32px;
}

.login-form .form-group {
  margin-bottom: 20px;
}

.login-form label {
  display: block;
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 6px;
  font-weight: 500;
}

.login-form input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  background: var(--bg-elevated);
  color: var(--text);
}

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

.login-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 12px rgba(0,212,255,0.2);
}

.login-form .btn-login {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #0a0e1a;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 0 20px rgba(0,212,255,0.3);
}

.login-form .btn-login:hover {
  box-shadow: 0 0 30px rgba(0,212,255,0.5);
  transform: translateY(-1px);
}

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

.login-error {
  color: var(--danger);
  font-size: 14px;
  text-align: center;
  margin-top: 12px;
  min-height: 20px;
}

/* ===== Dashboard ===== */
.dashboard {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

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

.dashboard-header h1 {
  font-size: 24px;
  color: var(--primary);
  text-shadow: 0 0 16px rgba(0,212,255,0.3);
}

.dashboard-header .header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn {
  padding: 8px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-block;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #0a0e1a;
  font-weight: 600;
  box-shadow: 0 0 12px rgba(0,212,255,0.2);
}

.btn-primary:hover {
  box-shadow: 0 0 20px rgba(0,212,255,0.4);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn-outline:hover {
  background: var(--primary);
  color: #0a0e1a;
  box-shadow: 0 0 16px rgba(0,212,255,0.3);
}

.btn-sm {
  padding: 4px 12px;
  font-size: 13px;
}

/* Stats Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.stat-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 20px rgba(0,212,255,0.1);
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
}

.stat-card .stat-value.cost {
  color: var(--danger);
}

.stat-card .stat-value.profit {
  color: var(--success);
  text-shadow: 0 0 12px rgba(0,230,118,0.3);
}

/* Search */
.search-bar {
  margin-bottom: 16px;
}

.search-bar input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  outline: none;
  background: var(--card-bg);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-bar input::placeholder { color: var(--text-muted); }

.search-bar input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 12px rgba(0,212,255,0.15);
}

/* Orders Table */
.orders-table {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--border);
}

.orders-table table {
  width: 100%;
  border-collapse: collapse;
}

.orders-table th {
  background: linear-gradient(180deg, #1a2138 0%, #141927 100%);
  color: var(--primary);
  padding: 12px 16px;
  text-align: left;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 1px solid var(--primary-dark);
}

.orders-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  color: var(--text);
}

.orders-table tr:hover {
  background: var(--card-bg-hover);
}

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

.order-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.order-link:hover {
  text-decoration: underline;
  text-shadow: 0 0 8px rgba(0,212,255,0.3);
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.badge-success {
  background: rgba(0,230,118,0.12);
  color: var(--success);
  border: 1px solid rgba(0,230,118,0.3);
}

.badge-muted {
  background: rgba(100,116,139,0.15);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* ===== Order Detail ===== */
.order-detail {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px;
}

.order-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.back-link {
  color: var(--text-light);
  text-decoration: none;
  font-size: 14px;
}

.back-link:hover {
  color: var(--primary);
}

.detail-actions {
  display: flex;
  gap: 12px;
}

/* Order Info Card */
.info-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  border: 1px solid var(--border);
}

.info-card h2 {
  font-size: 18px;
  color: var(--primary);
  margin-bottom: 16px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 8px;
  text-shadow: 0 0 12px rgba(0,212,255,0.2);
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.info-grid .info-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.info-grid .info-label {
  color: var(--text-muted);
  font-size: 14px;
  min-width: 70px;
}

.info-grid .info-value {
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
}

/* Curtain Items Table */
.items-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

.items-table th {
  background: var(--bg-elevated);
  padding: 10px 12px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.items-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  color: var(--text);
}

.items-table tfoot td {
  font-weight: 700;
  background: var(--bg-elevated);
  border-top: 2px solid var(--border);
  color: var(--primary);
}

/* Cost Section (Admin Only) */
.cost-section {
  background: rgba(255,71,87,0.05);
  border: 2px solid rgba(255,71,87,0.3);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.cost-section h2 {
  color: var(--danger);
  font-size: 16px;
  margin-bottom: 12px;
  text-shadow: 0 0 10px rgba(255,71,87,0.3);
}

.cost-section .cost-warning {
  font-size: 12px;
  color: var(--danger);
  margin-bottom: 12px;
  padding: 6px 10px;
  background: rgba(255,71,87,0.1);
  border-radius: 4px;
  border: 1px solid rgba(255,71,87,0.2);
}

/* Total Amount */
.total-amount {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: var(--radius);
  color: #0a0e1a;
  margin-bottom: 16px;
  box-shadow: 0 0 24px rgba(0,212,255,0.2);
}

.total-amount .total-label {
  font-size: 16px;
  font-weight: 600;
}

.total-amount .total-value {
  font-size: 32px;
  font-weight: 700;
}

/* ===== Share Page (PDF-like) — keep white for customer print ===== */
.share-page {
  background: #1a1a2e;
  min-height: 100vh;
  padding: 40px 20px;
  display: flex;
  justify-content: center;
}

.pdf-container {
  width: 210mm;
  max-width: 100%;
  background: #fff;
  box-shadow: 0 4px 30px rgba(0,212,255,0.15);
  padding: 40px 35px;
  font-size: 14px;
  color: #333;
}

.pdf-header {
  text-align: center;
  margin-bottom: 24px;
  border-bottom: 3px solid var(--primary);
  padding-bottom: 16px;
}

.pdf-header h1 {
  font-size: 24px;
  color: var(--primary);
  letter-spacing: 4px;
}

.pdf-header .pdf-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.pdf-info-section {
  margin-bottom: 20px;
  border: 1px solid #ddd;
  border-radius: 4px;
  overflow: hidden;
}

.pdf-info-section table {
  width: 100%;
  border-collapse: collapse;
}

.pdf-info-section td {
  padding: 8px 12px;
  font-size: 13px;
  border-bottom: 1px solid #eee;
}

.pdf-info-section .info-key {
  background: #f0f8fc;
  color: #666;
  white-space: nowrap;
  width: 90px;
}

.pdf-section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  margin: 20px 0 8px;
  padding-left: 10px;
  border-left: 4px solid var(--primary);
}

.pdf-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
}

.pdf-table th {
  background: var(--primary);
  color: #0a0e1a;
  padding: 8px 10px;
  font-size: 13px;
  text-align: center;
  font-weight: 600;
}

.pdf-table td {
  padding: 7px 10px;
  border: 1px solid #ddd;
  font-size: 13px;
  text-align: center;
}

.pdf-table tbody tr:nth-child(even) {
  background: #f5fafc;
}

.pdf-table tfoot td {
  background: #f0f8fc;
  font-weight: 700;
  font-size: 15px;
  border-top: 2px solid var(--primary);
}

.pdf-total-box {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.pdf-total-box:has(.total-inner:only-child) {
  justify-content: stretch;
}

.pdf-total-box .total-inner {
  flex: 1;
  border: 2px solid var(--primary);
  border-radius: 8px;
  padding: 16px 24px;
  text-align: right;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 16px;
}

.pdf-total-box .total-inner .label {
  font-size: 14px;
  color: #666;
}

.pdf-total-box .total-inner .amount {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}

.pdf-footer {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid #ddd;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #999;
}

.pdf-footer .seal {
  width: 100px;
  height: 100px;
  border: 3px solid var(--danger);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--danger);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  line-height: 1.3;
  transform: rotate(-15deg);
  opacity: 0.8;
}

/* Share toolbar (floating) */
.share-toolbar {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100;
  display: flex;
  gap: 8px;
}

.share-toolbar .btn {
  padding: 10px 20px;
  background: rgba(20,25,39,0.85);
  backdrop-filter: blur(10px);
  color: var(--primary);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.share-toolbar .btn:hover {
  background: var(--primary);
  color: #0a0e1a;
  box-shadow: 0 0 16px rgba(0,212,255,0.4);
}

/* Print styles */
@media print {
  body {
    background: #fff;
  }
  .share-page {
    padding: 0;
    background: #fff;
  }
  .pdf-container {
    box-shadow: none;
    width: 100%;
    max-width: 100%;
    padding: 20px;
  }
  .share-toolbar {
    display: none;
  }
}

/* Loading */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 16px;
}

.loading .spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
  box-shadow: 0 0 12px rgba(0,212,255,0.15);
}

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

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

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

.modal {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 440px;
  max-width: 90%;
  box-shadow: 0 8px 40px rgba(0,212,255,0.15);
}

.modal h3 {
  font-size: 18px;
  color: var(--primary);
  margin-bottom: 16px;
  text-shadow: 0 0 12px rgba(0,212,255,0.2);
}

.modal .share-url-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  word-break: break-all;
  font-size: 14px;
  color: var(--text);
}

.modal .modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.modal .modal-note {
  font-size: 13px;
  color: var(--success);
  margin-top: 12px;
  padding: 8px 12px;
  background: rgba(0,230,118,0.08);
  border: 1px solid rgba(0,230,118,0.2);
  border-radius: 4px;
}

/* Responsive */
@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .dashboard {
    padding: 16px;
  }
  .orders-table {
    overflow-x: auto;
  }
  .pdf-container {
    padding: 20px 15px;
  }
}

/* ===== Fee detail grid (order-detail page) ===== */
.fee-detail-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.fee-detail-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 16px;
  background: rgba(0,212,255,0.05);
  border: 1px solid rgba(0,212,255,0.2);
  border-radius: 6px;
}
.fee-detail-label {
  font-size: 13px;
  color: var(--primary);
  font-weight: 600;
}
.fee-detail-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

@media (max-width: 768px) {
  .fee-detail-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
