/* =============================================
   Alwathaaeq POLICIES DASHBOARD
   Minimalist White & Grey Theme
   ============================================= */

/* ---------- Font ---------- */
@font-face {
  font-family: 'theSans';
  src: url('../fonts/TheSans-Plain.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'theSans';
  src: url('../fonts/TheSans-Bold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ---------- CSS Variables ---------- */
:root {
  --bg-primary: #f5f5f7;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #fafafa;
  --border-color: #e5e5e7;
  --border-light: #f0f0f2;

  --accent: #1a1a1a;
  --accent-light: #333333;
  --accent-muted: #6e6e73;

  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-muted: #aeaeb2;

  --danger: #ff3b30;
  --danger-hover: #ff453a;
  --success: #34c759;
  --info: #007aff;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.1);

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;

  --font-main: 'theSans', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-main);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------- Background Animation (subtle) ---------- */
.bg-animation { display: none; }

/* ---------- Header ---------- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
}

.header-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.logo-text h1 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.logo-text p {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.header-stats {
  display: flex;
  gap: 24px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.stat-number {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-primary);
}

.stat-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-logout:hover {
  background: var(--bg-primary);
  color: var(--danger);
  border-color: var(--danger);
}

.btn-card-update:hover {
  border-color: var(--success) !important;
  color: var(--success) !important;
}

/* ---------- Main Content ---------- */
.main-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}

/* ---------- Upload Section ---------- */
.upload-section {
  margin-bottom: 36px;
}

.upload-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-normal);
}

.upload-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.upload-card h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.upload-card > p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 20px;
}

/* ---------- Dropzone ---------- */
.upload-dropzone {
  border: 1.5px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 40px 24px;
  cursor: pointer;
  transition: var(--transition-normal);
  background: var(--bg-primary);
}

.upload-dropzone:hover,
.upload-dropzone.drag-over {
  border-color: var(--accent-muted);
  background: #f0f0f2;
}

.dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.dropzone-icon {
  color: var(--text-muted);
  transition: var(--transition-normal);
}

.upload-dropzone:hover .dropzone-icon {
  color: var(--text-secondary);
}

.dropzone-text {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.dropzone-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ---------- Upload Form ---------- */
.upload-form {
  margin-top: 20px;
  animation: slideUp 0.25s ease;
}

.selected-file {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  color: var(--text-secondary);
}

.file-info {
  flex: 1;
  text-align: left;
  display: flex;
  flex-direction: column;
}

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

.file-size {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.btn-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  transition: var(--transition-fast);
}

.btn-remove:hover {
  color: var(--danger);
}

.form-group {
  margin-bottom: 14px;
  text-align: left;
}

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

.form-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.9rem;
  transition: var(--transition-fast);
  outline: none;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

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

.btn-upload {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 28px;
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-normal);
}

.btn-upload:hover {
  background: var(--accent-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-upload:active {
  transform: translateY(0);
}

.btn-upload:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* ---------- Progress Bar ---------- */
.upload-progress {
  margin-top: 18px;
}

.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--border-color);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s ease;
}

.progress-text {
  display: block;
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ---------- Policies Section ---------- */
.policies-section {
  animation: fadeIn 0.4s ease;
}

.section-header {
  margin-bottom: 20px;
}

.section-header h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.section-header h2 svg {
  color: var(--text-muted);
}

/* ---------- Policies Grid ---------- */
.policies-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

/* ---------- Policy Card ---------- */
.policy-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: var(--transition-normal);
  animation: slideUp 0.3s ease;
  box-shadow: var(--shadow-sm);
}

.policy-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: #d1d1d6;
}

.card-header {
  padding: 18px 18px 0;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.card-icon {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-secondary);
}

.card-info {
  flex: 1;
  min-width: 0;
}

.card-info h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.card-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.card-meta span {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 3px;
}

/* ---------- QR Code Section ---------- */
.card-qr {
  padding: 18px;
  display: flex;
  justify-content: center;
}

.qr-wrapper {
  width: 150px;
  height: 150px;
  padding: 8px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.qr-wrapper::after {
  content: 'Click to enlarge';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 4px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  font-size: 0.6rem;
  text-align: center;
  transform: translateY(100%);
  transition: var(--transition-fast);
}

.qr-wrapper:hover::after {
  transform: translateY(0);
}

.qr-wrapper:hover {
  box-shadow: var(--shadow-md);
}

.qr-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.qr-loading {
  width: 130px;
  height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ---------- Card Actions ---------- */
.card-actions {
  padding: 0 14px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.card-actions button {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 8px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 0.7rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.card-actions button:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.card-actions button svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.btn-card-download:hover {
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}

.btn-card-delete:hover {
  border-color: var(--danger) !important;
  color: var(--danger) !important;
}

.btn-card-copy:hover {
  border-color: var(--info) !important;
  color: var(--info) !important;
}

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-muted);
}

.empty-state svg {
  margin-bottom: 14px;
  opacity: 0.25;
}

.empty-state h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 0.85rem;
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 28px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  animation: scaleIn 0.2s ease;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
  transition: var(--transition-fast);
}

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

.modal h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 18px;
  color: var(--text-primary);
}

.modal-qr {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
}

.modal-qr img {
  width: 220px;
  height: 220px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.modal-url {
  font-size: 0.7rem;
  color: var(--text-muted);
  word-break: break-all;
  margin-bottom: 18px;
  padding: 8px 12px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.btn-copy,
.btn-download-qr {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 18px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-copy:hover {
  border-color: var(--info);
  color: var(--info);
}

.btn-download-qr:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- Delete Modal ---------- */
.delete-modal {
  max-width: 360px;
}

.delete-icon {
  color: var(--danger);
  margin-bottom: 10px;
}

.delete-modal p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 20px;
}

.btn-cancel {
  padding: 8px 22px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-cancel:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.btn-delete-confirm {
  padding: 8px 22px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--danger);
  color: white;
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-delete-confirm:hover {
  background: var(--danger-hover);
}

/* ---------- Toast Notifications ---------- */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  animation: slideInRight 0.25s ease;
  min-width: 260px;
  max-width: 380px;
}

.toast.toast-success {
  border-left: 3px solid var(--success);
}

.toast.toast-error {
  border-left: 3px solid var(--danger);
}

.toast.toast-info {
  border-left: 3px solid var(--info);
}

.toast-message {
  font-size: 0.82rem;
  color: var(--text-primary);
  flex: 1;
}

.toast-dismiss {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 2px;
}

.toast-exit {
  animation: slideOutRight 0.25s ease forwards;
}

/* ---------- Animations ---------- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(60px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideOutRight {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(60px); }
}

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

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }

  .logo-section {
    justify-content: center;
  }

  .main-content {
    padding: 20px 16px 48px;
  }

  .policies-grid {
    grid-template-columns: 1fr;
  }

  .upload-dropzone {
    padding: 28px 16px;
  }

  .modal {
    width: 95%;
    padding: 22px;
  }

  .modal-qr img {
    width: 180px;
    height: 180px;
  }

  .card-actions {
    flex-wrap: wrap;
  }

  .card-actions button {
    flex-basis: calc(50% - 3px);
  }
}

@media (max-width: 480px) {
  .logo-text h1 {
    font-size: 1rem;
  }

  .upload-card {
    padding: 18px;
  }

  .card-actions button {
    font-size: 0.7rem;
    padding: 7px 6px;
  }
}
