/* EasyCoop – mobile-first shared styles */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #059669;
  --danger: #dc2626;
  --warning: #d97706;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem;
  padding-bottom: calc(1.5rem + var(--safe-bottom));
}
.container-wide { max-width: 1100px; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}
@media (min-width: 640px) {
  .card { padding: 1.75rem; }
  .container { padding: 1.5rem 1.25rem; }
}

.logo { text-align: center; margin-bottom: 1.25rem; }
.logo h1 { font-size: 1.5rem; color: var(--primary); }
.logo p { color: var(--muted); font-size: 0.9rem; margin-top: 0.25rem; }

h1 { font-size: 1.35rem; margin-bottom: 0.5rem; }
h2 {
  font-size: 1.05rem;
  margin: 1.25rem 0 0.75rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

.form-group { margin-bottom: 0.9rem; }
.form-row {
  display: flex;
  flex-direction: column;
  gap: 0;
}
@media (min-width: 560px) {
  .form-row { flex-direction: row; gap: 0.85rem; }
  .form-row .form-group { flex: 1; }
}

label {
  display: block;
  font-weight: 500;
  font-size: 0.875rem;
  margin-bottom: 0.3rem;
}
label .req { color: var(--danger); }

input, select, textarea {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem; /* prevents iOS zoom */
  background: #fff;
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748b' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  padding-right: 2rem;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.8rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  min-height: 48px; /* touch target */
  transition: background 0.15s, opacity 0.15s;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; text-decoration: none; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-sm { width: auto; min-height: 40px; padding: 0.45rem 0.9rem; font-size: 0.875rem; }
.btn-block { width: 100%; }

.actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1rem;
}
@media (min-width: 480px) {
  .actions { flex-direction: row; flex-wrap: wrap; }
  .actions .btn { width: auto; flex: 1; }
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  display: none;
}
.alert.show { display: block; }
.alert-danger { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-pending { background: #fffbeb; color: #92400e; }
.badge-ok, .badge-approved { background: #ecfdf5; color: #065f46; }
.badge-bad, .badge-rejected { background: #fef2f2; color: #991b1b; }

/* Top nav – mobile first */
.topnav {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topnav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.65rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.topnav .brand { font-weight: 700; color: var(--primary); font-size: 1.05rem; white-space: nowrap; }
.topnav-links {
  display: none;
  gap: 1rem;
  align-items: center;
}
.topnav-links a { color: var(--muted); font-size: 0.9rem; text-decoration: none; }
.topnav-links a:hover, .topnav-links a.active { color: var(--primary); }
.nav-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 1.25rem;
}
.topnav-links.open {
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem 1rem;
  box-shadow: var(--shadow);
}
@media (min-width: 768px) {
  .nav-toggle { display: none; }
  .topnav-links { display: flex; flex-direction: row; position: static; border: none; box-shadow: none; padding: 0; }
}

/* Tables → cards on mobile */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; background: #fff; font-size: 0.875rem; }
table.data th, table.data td {
  padding: 0.65rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
table.data th { background: var(--bg); font-weight: 600; white-space: nowrap; }

@media (max-width: 639px) {
  table.data.responsive thead { display: none; }
  table.data.responsive tr {
    display: block;
    margin-bottom: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    padding: 0.5rem 0;
  }
  table.data.responsive td {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    border: none;
    padding: 0.4rem 0.85rem;
  }
  table.data.responsive td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--muted);
    flex-shrink: 0;
  }
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}
@media (min-width: 640px) {
  .stat-grid { grid-template-columns: repeat(3, 1fr); gap: 1rem; }
}
@media (min-width: 900px) {
  .stat-grid { grid-template-columns: repeat(6, 1fr); }
}
.stat {
  background: #fff;
  border-radius: 10px;
  padding: 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.stat .num { font-size: 1.5rem; font-weight: 700; }
.stat .label { font-size: 0.8rem; color: var(--muted); margin-top: 0.2rem; }
.stat.pending .num { color: var(--warning); }
.stat.approved .num { color: var(--success); }
.stat.rejected .num { color: var(--danger); }

.footer-links {
  text-align: center;
  margin-top: 1.25rem;
  font-size: 0.875rem;
  color: var(--muted);
}
.footer-links a { margin: 0 0.4rem; }

.center-page {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.center-page .card { width: 100%; max-width: 400px; }

.dl-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.35rem 0;
  font-size: 0.9rem;
}
.dl-grid dt { color: var(--muted); font-size: 0.8rem; }
.dl-grid dd { font-weight: 500; margin-bottom: 0.5rem; word-break: break-word; }
@media (min-width: 480px) {
  .dl-grid {
    grid-template-columns: 130px 1fr;
    gap: 0.4rem 0.85rem;
  }
  .dl-grid dd { margin-bottom: 0; }
}

.wizard-dots {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
}
.wizard-dots span {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
}
.wizard-dots span.done,
.wizard-dots span.active { background: var(--primary); }

/* Mobile-First Reset & Variables */
:root {
    --sidebar-width: 260px;
    --primary-color: #1a365d;
    --accent-color: #2b6cb0;
    --bg-light: #f7fafc;
    --border-color: #e2e8f0;
    --text-dark: #2d3748;
    --text-muted: #718096;
    --touch-size: 48px; /* High accessibility touch target */
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; 
    background: var(--bg-light); 
    color: var(--text-dark); 
    display: flex; 
    flex-direction: column;
    min-height: 100vh; 
}

/* Header & Mobile Navigation Toggle */
.topbar { 
    height: 60px; 
    background: #fff; 
    border-bottom: 1px solid var(--border-color); 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    padding: 0 1rem; 
    position: sticky;
    top: 0;
    z-index: 100;
}
.mobile-menu-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--primary-color);
    cursor: pointer;
    min-width: var(--touch-size);
    min-height: var(--touch-size);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Off-Canvas Mobile Drawer -> Desktop Fixed Sidebar */
.sidebar { 
    position: fixed;
    top: 0;
    left: -100%;
    width: 80%;
    max-width: 300px;
    height: 100%;
    background: var(--primary-color); 
    color: #fff; 
    z-index: 1000;
    display: flex; 
    flex-direction: column; 
    justify-content: space-between; 
    transition: left 0.3s ease-in-out;
}
.sidebar.active { left: 0; }
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    display: none;
}
.sidebar-overlay.active { display: block; }

.sidebar-brand { 
    padding: 1.25rem; 
    font-size: 1.25rem; 
    font-weight: 700; 
    border-bottom: 1px solid rgba(255,255,255,0.1); 
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.sidebar-brand span { color: #63b3ed; }
.nav-group { padding: 0.5rem 0; overflow-y: auto; flex: 1; }
.nav-section-title { font-size: 0.7rem; text-transform: uppercase; color: #a0aec0; padding: 0.75rem 1.25rem 0.25rem; font-weight: 700; }
.nav-item { 
    display: flex; 
    align-items: center; 
    padding: 0.85rem 1.25rem; 
    color: #e2e8f0; 
    text-decoration: none; 
    font-size: 0.95rem; 
    min-height: var(--touch-size);
}
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,0.1); color: #fff; border-left: 4px solid #63b3ed; }
.user-profile { padding: 1rem 1.25rem; border-top: 1px solid rgba(255,255,255,0.1); background: rgba(0,0,0,0.15); }
.role-badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 0.7rem; font-weight: 700; background: #3182ce; color: #fff; }

/* Mobile Grid Layouts */
.main-wrapper { flex: 1; display: flex; flex-direction: column; }
.content-area { padding: 1rem; flex: 1; }
.card-grid, .actions-grid { 
    display: grid; 
    grid-template-columns: 1fr; /* 1 column by default on mobile */
    gap: 1rem; 
    margin-bottom: 1.5rem; 
}

.card { background: #fff; border: 1px solid var(--border-color); border-radius: 8px; padding: 1.25rem; }
.card h3 { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; margin-bottom: 0.25rem; }
.stat-number { font-size: 1.6rem; font-weight: 700; color: var(--primary-color); }

.action-card { 
    background: #fff; 
    border: 1px solid var(--border-color); 
    border-radius: 8px; 
    padding: 1rem; 
    text-decoration: none; 
    color: var(--text-dark); 
    display: block; 
    min-height: var(--touch-size);
}
.action-title { font-weight: 600; font-size: 1rem; color: var(--accent-color); margin-bottom: 0.25rem; }
.action-desc { font-size: 0.85rem; color: var(--text-muted); }

/* Responsive Desktop Enhancements (Media Query Breakpoint: 1024px) */
@media (min-width: 1024px) {
    body { flex-direction: row; }
    .mobile-menu-btn { display: none; }
    .sidebar-overlay { display: none !important; }
    
    .sidebar { 
        position: static; 
        left: 0; 
        width: var(--sidebar-width); 
        max-width: none;
        height: 100vh;
        sticky: top;
    }
    
    .content-area { padding: 2rem; }
    .card-grid { grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
    .actions-grid { grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
}
