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

:root {
  /* Modern Premium Palette */
  --bg: #f3f6fb;
  --surface: #ffffff;
  --line: #e2eaf1;
  --text: #1a2b4b;
  --text-light: #5c6e8c;
  --brand: #4f46e5;
  --brand-dark: #3730a3;
  --brand-light: #eef2ff;
  --success: #10b981;
  --success-light: #dcfce7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  
  /* Soft UI Shadows */
  --shadow-sm: 0 2px 4px rgba(26, 43, 75, 0.05);
  --shadow: 0 10px 25px -5px rgba(26, 43, 75, 0.1), 0 8px 10px -6px rgba(26, 43, 75, 0.1);
  --shadow-lg: 0 20px 50px -12px rgba(26, 43, 75, 0.15);
  
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; -webkit-font-smoothing: antialiased; }

body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background-color: var(--bg);
  background-image: url("../../assets/aegis-care-shield-web-bacground.webp");
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  line-height: 1.6;
}

.container { width: min(1200px, 94vw); margin: 0 auto; }

/* Header & Navigation */
.portal-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.header-wrap { display: flex; justify-content: space-between; align-items: center; min-height: 150px; gap: 20px; }

.brand-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.brand img {
  height: 100px;
  width: auto;
  display: block;
  object-fit: contain;
  transition: transform var(--transition);
}
.brand:hover img { transform: scale(1.02); }

.brand-tagline {
  font-size: 0.75rem;
  line-height: 1.2;
  color: #000;
  font-weight: 700;
  margin: 0;
  font-family: 'Inter', sans-serif;
}

.header-links { display: flex; gap: 12px; }

/* Admin Layout */
.admin-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  margin: 24px 0 40px;
  align-items: start;
.admin-main { min-width: 0; }
}

.admin-sidebar { position: sticky; top: 140px; }
.admin-nav { display: grid; gap: 6px; }

.admin-nav-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: var(--text-light);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-weight: 600;
  font-size: 0.95rem;
  transition: var(--transition);
  background: transparent;
}

.admin-nav-link:hover {
  background: var(--brand-light);
  color: var(--brand);
}

.admin-nav-link.active {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 4px 12px rgba(30, 114, 255, 0.3);
}

/* Common UI Elements */
h1, h2, h3 { color: var(--brand-dark); font-weight: 800; margin-bottom: 12px; }
h1 { font-size: 2.2rem; letter-spacing: -0.02em; }
h2 { font-size: 1.5rem; }

.card {
  background: var(--surface);
  border: 1px solid rgba(226, 234, 241, 0.5);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  transition: transform var(--transition), box-shadow var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.eyebrow {
  display: inline-flex;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--brand-light);
  color: var(--brand);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.badge.pending { background: var(--warning-light); color: var(--warning); }
.badge.signed { background: var(--success-light); color: var(--success); }
.badge.danger { background: var(--danger-light); color: var(--danger); }

/* Forms */
label { display: block; font-weight: 600; font-size: 0.9rem; color: var(--brand-dark); margin-bottom: 6px; }

input, select, textarea {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: #fff;
  color: var(--text);
  font-size: 1rem;
  transition: all var(--transition);
  appearance: none;
}

input[type="date"] {
  appearance: auto;
  -webkit-appearance: auto;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-light);
}

/* Custom Select Arrow */
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2316375f'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
    padding-right: 40px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 12px 24px;
  background: var(--brand);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 4px 6px rgba(30, 114, 255, 0.15);
}

.btn:hover {
  background: #0056e0;
  transform: translateY(-1px);
  box-shadow: 0 6px 12px rgba(30, 114, 255, 0.2);
}

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

.btn.ghost {
  background: transparent;
  color: var(--brand);
  border: 2px solid var(--brand);
  box-shadow: none;
}

.btn.ghost:hover {
  background: var(--brand-light);
  color: var(--brand);
}

/* Tables */
.table-wrap {
  margin-top: 10px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  border: 1px solid var(--line);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

.data-table th {
  background: #f8fafc;
  padding: 14px 16px;
  text-align: left;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
  border-bottom: 2px solid var(--line);
}

.data-table td {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  font-size: 0.95rem;
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: 0; }
.data-table tr:hover td { background: #fdfdfe; }

/* Visual Metrics */
.metric-card {
    border-top: 4px solid var(--brand);
    text-align: center;
    transition: transform 0.3s ease;
}
.metric-card:hover { transform: translateY(-4px); }
.metric-card.alert-red { border-top-color: var(--danger); }
.metric-card.alert-amber { border-top-color: var(--warning); }
.metric-card.alert-blue { border-top-color: #17a2b8; }

.metric-value { font-size: 2.8rem; font-weight: 900; color: var(--brand-dark); line-height: 1; }
.metric-label { font-size: 0.8rem; font-weight: 700; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 4px; }

/* Grid Utilities */
.grid { display: grid; gap: 20px; }
.grid.two { grid-template-columns: repeat(2, 1fr); }
.stack { display: grid; gap: 12px; }

/* Search Enhancements */
#adminGlobalSearch {
    padding-left: 44px;
    border-radius: var(--radius-lg);
    background: #fff;
}

.search-container::before {
    content: "🔍";
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    font-size: 1.1rem;
    opacity: 0.5;
}

/* Responsive */
@media (max-width: 980px) {
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar { position: static; }
  .grid.two { grid-template-columns: 1fr; }
  .header-wrap { min-height: auto; padding: 20px 0; flex-direction: column; text-align: center; }
  .brand-block { align-items: center; }
}

/* Custom Gold Star Animation */
.gold-star {
    display: inline-block;
    filter: drop-shadow(0 0 2px rgba(255, 215, 0, 0.5));
    animation: star-pulse 2s infinite;
}

@keyframes star-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.inline { display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }

/* Custom Premium Checkbox/Switch */
input[type="checkbox"] {
    appearance: none;
    width: 44px;
    height: 24px;
    background: #e2eaf1;
    border-radius: 20px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s;
    border: none;
    flex-shrink: 0;
}

input[type="checkbox"]::before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    top: 3px;
    left: 4px;
    background: white;
    transition: transform 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

input[type="checkbox"]:checked {
    background: var(--success);
}

input[type="checkbox"]:checked::before {
    transform: translateX(18px);
}

.data-table .inline input[type="checkbox"],
.data-table input[type="checkbox"] {
  width: 44px;
}

/* --- Phase 3: Final Polish --- */

/* Sidebar Collapse */
.sidebar-toggle {
    background: var(--brand-light); color: var(--brand);
    border: none; border-radius: 50%; width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; position: absolute; right: -14px; top: 20px;
    box-shadow: var(--shadow-sm); z-index: 10; transition: var(--transition);
    font-size: 14px; font-weight: 800;
}
.sidebar-toggle:hover { background: var(--brand); color: #fff; transform: scale(1.1); }

.admin-layout.collapsed { grid-template-columns: 80px 1fr; }
.admin-sidebar.collapsed { width: 80px; padding: 24px 10px; }
.admin-sidebar.collapsed .admin-nav-link span { display: none; }
.admin-sidebar.collapsed .admin-nav-link { justify-content: center; padding: 12px; }
.admin-sidebar.collapsed .eyebrow, .admin-sidebar.collapsed .search-container { display: none; }
.admin-sidebar.collapsed .sidebar-toggle { transform: rotate(180deg); }

/* Skeleton Loaders */
.skeleton {
    background: #e2eaf1;
    background: linear-gradient(90deg, #e2eaf1 25%, #edf2f7 50%, #e2eaf1 75%);
    background-size: 200% 100%;
    animation: skeleton-load 1.5s infinite;
    border-radius: 4px;
    display: inline-block;
    min-height: 1em;
    width: 100%;
}
@keyframes skeleton-load { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Empty States */
.empty-state {
    text-align: center; padding: 60px 24px;
    background: #fff; border-radius: var(--radius);
    border: 2px dashed var(--line);
    margin: 20px 0;
}
.empty-state-icon { font-size: 54px; margin-bottom: 20px; display: block; filter: grayscale(1) opacity(0.3); }
.empty-state h3 { margin-bottom: 10px; color: var(--brand-dark); font-size: 1.4rem; }
.empty-state p { color: var(--text-light); margin-bottom: 24px; max-width: 400px; margin-left: auto; margin-right: auto; }

/* Modal Improvements */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(13, 45, 88, 0.5);
    backdrop-filter: blur(5px); z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    animation: fade-in 0.2s ease;
}

.modal-card {
    background: #fff; width: min(440px, 90vw);
    padding: 40px; border-radius: 24px;
    box-shadow: var(--shadow-lg);
    text-align: center;
    animation: modal-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* High-visibility alert banners for errors and messages */
.error, .error-banner {
  background-color: var(--danger-light);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
  padding: 16px;
  border-radius: var(--radius-sm);
  margin: 10px 0 20px 0;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  box-shadow: var(--shadow-sm);
}

.error::before, .error-banner::before {
  content: '✕';
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--danger);
  color: #fff;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 800;
  flex-shrink: 0;
}

.success-banner, .success-message {
  background-color: var(--success-light);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
  padding: 16px;
  border-radius: var(--radius-sm);
  margin: 10px 0 20px 0;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  box-shadow: var(--shadow-sm);
}

.success-banner::before, .success-message::before {
  content: '✓';
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--success);
  color: #fff;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 800;
  flex-shrink: 0;
}

/* Footer Styles */
.site-footer {
  background: #0d2344;
  color: #d2e5ff;
  border-top: 1px solid #183662;
  margin-top: 60px;
}

.footer-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 1rem 0;
  flex-wrap: wrap;
}

.footer-wrap a {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
}

.footer-links,
.social-links {
  display: inline-flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}

.social-links a {
  color: #d8ecff;
  font-weight: 600;
}
