@import url('/shared/tokens.css');
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;700;900&family=DM+Sans:wght@400;500;700&family=DM+Mono:wght@400;500&display=swap');

:root {
  --blue: #0047AB;
  --gold: #C9A227;
  --bg: #FAFAF8;
  --white: #ffffff;
  --dark: #0A0A0A;
  --sidebar-bg: #001540;
  --sidebar-text: #E0E7FF;
  --sidebar-active: rgba(255, 255, 255, 0.1);
  --shadow: 0 8px 16px -4px rgba(0, 0, 0, 0.1);
  --border-radius: 16px;
  --font-h: 'Playfair Display', serif;
  --font-b: 'DM Sans', sans-serif;
  --font-m: 'DM Mono', monospace;
}

* { margin:0; padding:0; box-sizing:border-box; }
body { font-family: var(--font-b); background: var(--bg); color: var(--dark); overflow-x: hidden; line-height: 1.6; }

h1, h2, h3, h4 { font-family: var(--font-h); color: var(--blue); }
a { text-decoration: none; color: var(--blue); transition: color 0.3s; }
a:hover { color: var(--gold); }
button { font-family: var(--font-b); cursor: pointer; transition: all 0.3s; border: none; }

/* Compact Brand Header for Login Pages */
.portal-header {
  text-align: center;
  padding: 2rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
}
.portal-header img { width: 64px; height: 64px; object-fit: contain; }
.portal-header h2 { font-size: 1.8rem; font-family: var(--font-b); font-weight: 800; color: var(--blue); letter-spacing: 0.15em; text-transform: uppercase; }
.portal-header > p { display: none; } /* Hide verbose address block on login */
.dashboard-info { display: flex; justify-content: center; align-items: center; gap: 0.5rem; font-size: 1.1rem; color: #555; font-weight: 600; font-family: var(--font-b); letter-spacing: 0.1em; text-transform: uppercase; }

/* Layout Structure */
.author-layout {
  display: flex;
  min-height: 100vh;
}

.author-sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 2rem 1.5rem;
  z-index: 100;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 3rem;
  color: #fff;
  font-family: var(--font-h);
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: 0.05em;
  text-decoration: none;
}
.sidebar-logo img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}
.sidebar-logo:hover {
  color: #fff;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--sidebar-text);
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.2s;
  text-decoration: none;
}
.nav-item svg { width: 20px; height: 20px; opacity: 0.8; }
.nav-item:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; font-weight: 700; }
.nav-item.active svg { opacity: 1; color: var(--gold); }

.sidebar-footer {
  margin-top: auto;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.sidebar-footer .nav-item { padding: 10px 16px; }

.main-content {
  flex: 1;
  margin-left: 240px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 3rem;
  background: var(--bg);
  border-bottom: 1px solid rgba(0,0,0,0.05);
  position: sticky;
  top: 0;
  z-index: 90;
}
.topbar-title {
  font-size: 1.5rem;
  margin: 0;
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: 15px;
  font-weight: 500;
}
.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.2rem;
}

.page-body {
  padding: 2.5rem 3rem;
  flex: 1;
}

/* Dashboard Body */
.welcome-card {
  background: #fff;
  border-radius: var(--border-radius);
  padding: 2.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}
.welcome-text h1 { font-size: 2.2rem; margin-bottom: 10px; color: var(--dark); }
.welcome-text p { color: #555; font-size: 1.1rem; }

/* Stats Strip (Task 35) */
.stats-strip {
  display: flex;
  gap: 20px;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}
.stat-pill {
  flex: 1;
  min-width: 200px;
  background: #fff;
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sp-num { font-size: 2rem; font-weight: 700; color: var(--blue); line-height: 1; }
.sp-label { font-size: 0.85rem; color: #666; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }

/* Actions */
.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 3rem;
}
.action-card {
  background: #fff;
  border-radius: var(--border-radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  transition: transform 0.3s;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 15px;
}
.action-card:hover { transform: translateY(-5px); box-shadow: 0 12px 24px -4px rgba(0, 0, 0, 0.15); border-color: var(--gold); }
.ac-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(0, 71, 171, 0.05);
  color: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
}
.ac-icon svg { width: 24px; height: 24px; }
.action-card h3 { font-family: var(--font-b); font-size: 1.2rem; margin: 0; color: var(--dark); }
.action-card p { color: #666; font-size: 0.95rem; margin: 0; flex: 1; }

/* Books Grid */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 25px;
}
.book-card {
  background: #fff;
  border-radius: var(--border-radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 20px;
  transition: transform 0.3s;
}
.book-card:hover { transform: translateY(-4px); }
.book-header { display: flex; gap: 20px; }
.book-cover { width: 100px; height: 140px; object-fit: cover; border-radius: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
.book-info { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.book-info h3 { font-size: 1.25rem; line-height: 1.3; margin: 0; color: var(--dark); }
.book-isbn { font-family: var(--font-m); font-size: 0.8rem; color: #888; }
.book-status { display: flex; flex-direction: column; gap: 10px; margin-top: 15px; background: #f8f9fa; padding: 15px; border-radius: 8px; }
.status-row { display: flex; justify-content: space-between; font-size: 0.9rem; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: #ccc; }
.status-dot.active { background: #10B981; }

/* Buttons */
.btn-primary { background: var(--blue); color: #fff; padding: 12px 24px; border-radius: 8px; font-weight: 600; font-size: 0.95rem; display: inline-flex; justify-content: center; align-items: center; gap: 8px; }
.btn-primary:hover { background: #003380; transform: translateY(-1px); }
.btn-outline { background: transparent; color: var(--blue); border: 1.5px solid var(--blue); padding: 10px 24px; border-radius: 8px; font-weight: 600; font-size: 0.95rem; display: inline-flex; justify-content: center; align-items: center; gap: 8px; }
.btn-outline:hover { background: var(--blue); color: #fff; }

/* Login Page Splitting */
.main-container { display: flex; align-items: center; justify-content: center; gap: 2rem; max-width: 1100px; margin: 4rem auto 2rem; padding: 0 1rem; }
.carousel-container { width: clamp(280px, 40vw, 440px); aspect-ratio: 1; border-radius: var(--border-radius); box-shadow: var(--shadow); overflow: hidden; background: #fff; position: relative; flex-shrink: 0; }
.form-container { flex: 1; min-width: 280px; max-width: 420px; background: #fff; border-radius: var(--border-radius); box-shadow: var(--shadow); display: flex; flex-direction: column; justify-content: center; padding: 2.5rem; position: relative; z-index: 1; }
.carousel-image { width: 100%; height: 100%; object-fit: cover; position: absolute; top:0; left:0; transition: opacity 0.8s ease-in-out; }
.carousel-image.hidden { opacity: 0; pointer-events: none; }
.form-group { margin-bottom: 1.5rem; width: 100%; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 0.9rem; color: #444; }
.form-group input { width: 100%; padding: 0.85rem 1rem; font-size: 1rem; border: 1px solid #ddd; border-radius: 8px; font-family: var(--font-b); transition: border-color 0.2s; }
.form-group input:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px rgba(0,71,171,0.1); }
.form-links { display: flex; justify-content: space-between; margin-top: 1rem; font-size: 0.9rem; }

/* Royalties */
.filters { display: flex; gap: 15px; flex-wrap: wrap; margin-bottom: 20px; }
.profit-container { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 30px; }
.profit-box { flex: 1; min-width: 200px; padding: 1.5rem; border-radius: 12px; background: #fff; box-shadow: var(--shadow); }
.profit-box h4 { margin-bottom: 5px; font-family: var(--font-b); font-size: 0.9rem; color: #666; text-transform: uppercase; letter-spacing: 0.05em; }
.profit-box p { font-size: 2rem; font-weight: 700; color: var(--blue); margin: 0; line-height: 1; }

.table-wrap { overflow-x: auto; background: #fff; border-radius: 12px; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { padding: 1rem 1.5rem; text-align: left; border-bottom: 1px solid #eee; }
th { background: #f8f9fa; color: var(--dark); font-family: var(--font-b); font-weight: 600; text-transform: uppercase; font-size: 0.85rem; letter-spacing: 0.05em; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }

/* Utils */
.toast { position: fixed; bottom: 20px; right: 20px; padding: 15px 25px; border-radius: 8px; color: #fff; z-index: 9999; transform: translateY(100px); opacity: 0; transition: all 0.3s; font-weight: 500; box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: #e74c3c; }
.toast.success { background: #10B981; }

.skeleton { background: linear-gradient(90deg, #FAFAF8 25%, #E0DDD8 50%, #FAFAF8 75%); background-size: 200% 100%; animation: loading 1.5s infinite; border-radius: 8px; color: transparent !important; }
.skeleton * { visibility: hidden; }
@keyframes loading { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.mono { font-family: var(--font-m); font-size: 0.8rem; letter-spacing: 0.1em; text-transform: uppercase; }

/* Responsive */
@media (max-width: 900px) {
  .author-sidebar { transform: translateX(-100%); transition: transform 0.3s; }
  .author-sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .topbar { padding: 1rem 1.5rem; }
  .page-body { padding: 1.5rem; }
  .main-container { flex-direction: column; }
  .carousel-container { width: min(80vw, 320px); }
  .form-container { width: 100%; max-width: 400px; }
}

@media (max-width: 768px) {
  .welcome-card { flex-direction: column; align-items: flex-start; }
  .profit-container { flex-direction: column; }
}


/* ── SIDEBAR TOGGLE BUTTON (Upgrade 2, Fix 2 Part D) ──────────── */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  color: var(--dark);
  border-radius: 6px;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: #E2E8F0; }
@media (max-width: 900px) {
  .sidebar-toggle { display: flex; }
}

/* ── ACTION CARD IMPROVEMENTS (Upgrade 2, Fix 1) ──────────────── */
.action-card {
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.action-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 30px rgba(0, 71, 171, 0.12);
}
.action-card .ac-arrow {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  color: var(--blue);
  transition: transform 0.2s ease;
  display: flex;
  align-items: center;
}
.action-card:hover .ac-arrow {
  transform: translateX(4px);
}
