/* style.css - Premium Dashboard UI for Short Link Service */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  --primary-h: 215;
  --primary: hsl(var(--primary-h), 85%, 55%);
  --primary-glow: rgba(30, 110, 255, 0.4);
  --bg: #0b0f17;
  --surface: rgba(20, 28, 45, 0.7);
  --surface-border: rgba(255, 255, 255, 0.08);
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(circle at 50% 0%, #1a233a 0%, var(--bg) 70%);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 2rem 1rem;
}

/* Header & Nav */
header {
  width: 100%;
  max-width: 1400px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--surface-border);
}

.brand {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 1rem;
}

.dashboard-top-row {
  display: flex;
  align-items: stretch;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.dashboard-main-column {
  flex: 1 1 auto;
  min-width: 0;
}

.dashboard-main-column .card {
  height: 100%;
  margin-bottom: 0;
}

.dashboard-side-column {
  display: flex;
  flex: 0 0 360px;
  width: 360px;
}

.subsidy-widget {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  justify-content: space-between;
  width: 100%;
  padding: 1rem 1.1rem;
  border-radius: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(135deg, rgba(16, 23, 40, 0.92) 0%, rgba(22, 33, 57, 0.86) 100%);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.28);
}

.subsidy-widget[data-state="available"] {
  border-color: rgba(16, 185, 129, 0.35);
}

.subsidy-widget[data-state="empty"] {
  border-color: rgba(245, 158, 11, 0.35);
}

.subsidy-widget[data-state="error"] {
  border-color: rgba(239, 68, 68, 0.35);
}

.subsidy-widget-header,
.subsidy-widget-main,
.subsidy-widget-meta,
.subsidy-widget-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.subsidy-widget-header {
  margin-bottom: 0.9rem;
}

.subsidy-widget-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.subsidy-widget-title {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #93c5fd;
}

.subsidy-widget-subtitle {
  margin-top: 0.2rem;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.subsidy-refresh-btn {
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  box-shadow: none;
}

.subsidy-refresh-btn:disabled {
  opacity: 0.7;
  cursor: wait;
}

.subsidy-test-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: none;
}

.subsidy-test-btn:hover {
  box-shadow: none;
}

.subsidy-widget-main {
  margin-bottom: 0.75rem;
}

.subsidy-metric-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.subsidy-metric-value {
  margin-top: 0.15rem;
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
}

.subsidy-status-badge {
  flex-shrink: 0;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #dbeafe;
  background: rgba(59, 130, 246, 0.18);
  border: 1px solid rgba(59, 130, 246, 0.32);
}

.subsidy-widget[data-state="available"] .subsidy-status-badge {
  color: #bbf7d0;
  background: rgba(16, 185, 129, 0.16);
  border-color: rgba(16, 185, 129, 0.32);
}

.subsidy-widget[data-state="empty"] .subsidy-status-badge {
  color: #fde68a;
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(245, 158, 11, 0.32);
}

.subsidy-widget[data-state="error"] .subsidy-status-badge {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.32);
}

.subsidy-widget-meta {
  margin-bottom: 0.6rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.subsidy-widget-meta strong {
  color: var(--text-primary);
  font-size: 0.92rem;
}

.subsidy-widget-footer {
  font-size: 0.76rem;
  color: #94a3b8;
  flex-wrap: wrap;
}

.subsidy-refresh-countdown {
  margin-top: 0.65rem;
  font-size: 0.78rem;
  color: #93c5fd;
}

.subsidy-notify-status {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.subsidy-notify-status[data-type="success"] {
  color: #86efac;
}

.subsidy-notify-status[data-type="error"] {
  color: #fca5a5;
}

.subsidy-records-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.85rem;
}

.subsidy-records-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  font-size: 0.78rem;
  font-weight: 600;
  box-shadow: none;
}

.subsidy-records-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  box-shadow: none;
}

.subsidy-records-count {
  min-width: 1.35rem;
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.24);
  color: #bfdbfe;
  text-align: center;
  font-size: 0.72rem;
}

.subsidy-history-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-height: 460px;
  overflow-y: auto;
  padding-right: 0.35rem;
}

.subsidy-history-empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 2rem 1rem;
}

.subsidy-history-item {
  padding: 1rem;
  border-radius: 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}

.subsidy-history-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.subsidy-history-item-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
}

.subsidy-history-item-time {
  margin-top: 0.15rem;
  font-size: 0.75rem;
  color: #94a3b8;
}

.subsidy-history-result {
  flex-shrink: 0;
  padding: 0.26rem 0.6rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
}

.subsidy-history-result.success {
  color: #86efac;
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.24);
}

.subsidy-history-result.error {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.24);
}

.subsidy-history-item-project {
  font-size: 0.82rem;
  color: #dbeafe;
  margin-bottom: 0.55rem;
}

.subsidy-history-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.9rem;
  font-size: 0.76rem;
  color: var(--text-secondary);
  margin-bottom: 0.55rem;
}

.subsidy-history-item-message {
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--text-primary);
  word-break: break-word;
}

@media (max-width: 1180px) {
  .dashboard-top-row {
    flex-direction: column;
  }

  .dashboard-main-column,
  .dashboard-side-column {
    width: 100%;
    flex: 1 1 auto;
  }
}

.btn-nav {
  padding: 0.5rem 1.25rem;
  border-radius: 0.5rem;
  font-weight: 500;
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.2s;
  color: var(--text-secondary);
  border: 1px solid transparent;
}

.btn-nav.active, .btn-nav:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--surface-border);
}

/* Containers & Layout */
.container {
  width: 100%;
  max-width: 1400px;
  animation: fadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--surface-border);
  border-radius: 1.25rem;
  padding: 2.25rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  margin-bottom: 2rem;
}

/* Stats Summary */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.stat-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--surface-border);
  border-radius: 1rem;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--primary);
}

.stat-card.total::before { background: var(--primary); }
.stat-card.active::before { background: var(--success); }
.stat-card.expired::before { background: var(--danger); }

.stat-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Forms */
h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  text-align: center;
  background: linear-gradient(135deg, #93c5fd 0%, #3b82f6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

h2 {
  font-size: 1.35rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.form-group {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

input[type="url"], input[type="text"].form-input, input.form-input {
  flex: 1;
  padding: 0.875rem 1.25rem;
  border: 1px solid var(--surface-border);
  border-radius: 0.75rem;
  background: rgba(15, 23, 42, 0.6);
  color: var(--text-primary);
  font-size: 1rem;
  transition: all 0.2s;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

input[type="url"]:focus, input[type="text"].form-input:focus, input.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

button, .btn {
  cursor: pointer;
  padding: 0.875rem 1.75rem;
  border: none;
  border-radius: 0.75rem;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(29, 78, 216, 0.3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-decoration: none;
}

button:hover, .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(29, 78, 216, 0.4);
}

button:active, .btn:active {
  transform: translateY(1px);
}

/* Success Card details */
.result-box {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  align-items: center;
  text-align: center;
  padding: 1.5rem;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 1rem;
  border: 1px solid var(--surface-border);
}

.url-display {
  width: 100%;
  text-align: left;
}

.url-row {
  margin-bottom: 1rem;
}

.url-row span {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
}

.url-row code {
  display: block;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  font-family: monospace;
  font-size: 0.95rem;
  word-break: break-all;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.qr-box {
  background: white;
  padding: 1rem;
  border-radius: 1rem;
  display: inline-flex;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  margin: 1rem 0;
}

/* Table Responsive wrapper */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: 0.75rem;
  border: 1px solid var(--surface-border);
  background: rgba(15, 23, 42, 0.3);
}

.links-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  table-layout: fixed;
}

.links-table th, .links-table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--surface-border);
  font-size: 0.9rem;
}

.links-table th {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

.links-table tr:hover td {
  background: rgba(255, 255, 255, 0.01);
}

/* Table columns sizes */
.col-code { width: 80px; }
.col-order { width: 110px; }
.col-remark { width: 120px; }
.col-url { width: 310px; }
.col-time { width: 110px; }
.col-clicks { width: 80px; text-align: center; }
.col-status { width: 90px; text-align: center; }
.col-actions { width: 180px; text-align: right; }

.links-table td.col-clicks { text-align: center; }
.links-table td.col-status { text-align: center; }

.td-truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-active {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-expired {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Action buttons inside table */
.action-group {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.btn-icon {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--surface-border);
  padding: 0.4rem;
  border-radius: 0.5rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
}

.btn-icon:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.2);
  transform: none;
  box-shadow: none;
}

.btn-icon.btn-delete:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-icon.btn-extend:hover {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.3);
}

/* Custom Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: #111827;
  border: 1px solid var(--surface-border);
  border-radius: 1.25rem;
  max-width: 400px;
  width: 90%;
  padding: 2rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  transform: translateY(20px);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.modal-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  word-break: break-all;
}

.modal-close {
  margin-top: 1.5rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--surface-border);
  color: var(--text-primary);
  width: 100%;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  box-shadow: none;
}

/* Error message styling */
.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #f87171;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  margin-bottom: 1.25rem;
  text-align: center;
  font-size: 0.95rem;
}

/* Responsive tweaks */
@media (max-width: 768px) {
  body {
    padding: 1rem 0.5rem;
  }
  header {
    flex-direction: row;
    align-items: center;
  }
  .dashboard-top-row {
    width: 100%;
    flex-direction: column;
  }
  .dashboard-main-column,
  .dashboard-side-column {
    width: 100%;
    flex: 1 1 auto;
  }
  .subsidy-widget {
    max-width: none;
  }
  .nav-links {
    flex-wrap: wrap;
  }
  .card {
    padding: 1.25rem;
  }
  .form-group {
    flex-direction: column;
  }
  .links-table th, .links-table td {
    padding: 0.75rem 0.5rem;
  }
}

/* QR Card Layout matching user screenshot */
.qr-card-container {
  background: #ffffff;
  padding: 1.5rem;
  border-radius: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
  margin: 1.5rem 0;
  width: auto;
  max-width: 280px;
}

.qr-order-badge {
  font-size: 1.4rem;
  font-weight: 700;
  color: #0f172a;
  border: 2px solid #ef4444; /* red border as in user's screenshot */
  padding: 0.25rem 1.25rem;
  border-radius: 0.25rem;
  background: #ffffff;
  min-width: 100px;
  text-align: center;
}

.qr-expiry-text {
  font-size: 0.85rem;
  color: #64748b;
  font-weight: 500;
}
