/* ============================================================
   BIBLIOTECA RAÍZES - Design System
   Baseado no APK da Raízes Igreja Presbiteriana (Eklesia)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;500;600;700&family=Varela+Round&display=swap');

/* ---- CSS Variables (Design Tokens) ---- */
:root {
  /* Cores primárias da igreja */
  --cor-primary: #97B816;
  --cor-primary-dark: #7A9612;
  --cor-primary-light: #A8CC2A;
  --cor-primary-rgb: 151, 184, 22;

  /* Cores do logo (barras) */
  --cor-logo-olive: #8B8B3E;
  --cor-logo-lime: #97B816;
  --cor-logo-teal: #2EA67E;

  /* Backgrounds */
  --bg-body: #13181E;
  --bg-card: #1A2028;
  --bg-card-hover: #212A35;
  --bg-navbar: #1d1d1d;
  --bg-sidebar: #161B22;
  --bg-input: #1A2028;
  --bg-modal: #1A2028;

  /* Texto */
  --cor-text-primary: #FFFFFF;
  --cor-text-secondary: #C0C4CC;
  --cor-text-muted: #8A8A8A;
  --cor-text-label: #8A8A8A;

  /* UI */
  --cor-border: #343434;
  --cor-border-light: #2A2F38;
  --cor-divider: #252B33;

  /* Status */
  --cor-success: #2dd36f;
  --cor-warning: #ffc409;
  --cor-danger: #eb445a;
  --cor-info: #3880ff;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.3);

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-pill: 35px;
  --radius-circle: 50%;

  /* Tipografia */
  --font-primary: 'Varela Round', 'Open Sans', sans-serif;
  --font-body: 'Open Sans', sans-serif;

  /* Spacing */
  --sidebar-width: 260px;
  --navbar-height: 64px;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s ease;
}

/* ---- Reset & Base ---- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-body);
  color: var(--cor-text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
  max-width: 100vw;
}

a {
  color: var(--cor-primary);
  text-decoration: none;
}

a:hover {
  color: var(--cor-primary-light);
}

img {
  max-width: 100%;
  display: block;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-body);
}

::-webkit-scrollbar-thumb {
  background: var(--cor-border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--cor-text-muted);
}

/* ---- Typography ---- */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-primary);
  color: var(--cor-text-primary);
  line-height: 1.3;
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
}

h2 {
  font-size: 1.5rem;
  font-weight: 600;
}

h3 {
  font-size: 1.25rem;
  font-weight: 600;
}

h4 {
  font-size: 1.1rem;
  font-weight: 600;
}

.text-accent {
  color: var(--cor-primary) !important;
}

.text-muted {
  color: var(--cor-text-muted) !important;
}

.text-success {
  color: var(--cor-success) !important;
}

.text-danger {
  color: var(--cor-danger) !important;
}

.text-warning {
  color: var(--cor-warning) !important;
}

/* ---- LOGIN SCREEN ---- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-body);
  position: relative;
  overflow: hidden;
}

.login-screen::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse at 30% 20%, rgba(151, 184, 22, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(46, 166, 126, 0.04) 0%, transparent 50%);
  animation: loginBgPulse 15s ease-in-out infinite alternate;
}

@keyframes loginBgPulse {
  0% {
    transform: translate(0, 0) scale(1);
  }

  100% {
    transform: translate(-2%, -2%) scale(1.05);
  }
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 40px;
  position: relative;
  z-index: 1;
  margin: 0 auto;
  text-align: left;
}

.login-logo {
  text-align: center;
  margin-bottom: 40px;
}

.login-logo .logo-bars {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 6px;
  margin-bottom: 20px;
  height: 70px;
}

.login-logo .logo-bar {
  width: 18px;
  border-radius: 4px;
  animation: barGrow 0.6s ease-out backwards;
}

.login-logo .logo-bar:nth-child(1) {
  height: 50px;
  background: var(--cor-logo-olive);
  animation-delay: 0.1s;
}

.login-logo .logo-bar:nth-child(2) {
  height: 65px;
  background: var(--cor-logo-lime);
  animation-delay: 0.2s;
}

.login-logo .logo-bar:nth-child(3) {
  height: 55px;
  background: var(--cor-logo-teal);
  animation-delay: 0.3s;
}

@keyframes barGrow {
  from {
    height: 0;
    opacity: 0;
  }
}

.login-logo .logo-name {
  font-family: var(--font-primary);
  font-size: 2rem;
  color: var(--cor-text-primary);
  letter-spacing: 3px;
  text-transform: lowercase;
  opacity: 0.9;
}

.login-logo .logo-subtitle {
  font-size: 0.7rem;
  color: var(--cor-text-muted);
  letter-spacing: 5px;
  text-transform: uppercase;
  margin-top: 2px;
}

.login-logo .logo-module {
  display: inline-block;
  margin-top: 16px;
  padding: 4px 16px;
  border: 1px solid var(--cor-primary);
  border-radius: var(--radius-pill);
  color: var(--cor-primary);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.login-form .form-group {
  margin-bottom: 20px;
}

.login-form label {
  display: block;
  font-size: 0.8rem;
  color: var(--cor-text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.login-form .input-wrapper {
  position: relative;
}

.login-form .input-wrapper ion-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--cor-text-muted);
  font-size: 1.1rem;
}

.login-form input {
  width: 100%;
  padding: 14px 14px 14px 44px;
  background: var(--bg-input);
  border: 1px solid var(--cor-border);
  border-radius: var(--radius-md);
  color: var(--cor-text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition-fast);
}

.login-form input:focus {
  border-color: var(--cor-primary);
}

.login-form input::placeholder {
  color: var(--cor-text-muted);
  opacity: 0.6;
}

.login-form .btn-login {
  width: 100%;
  margin-top: 8px;
}

.login-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 0.8rem;
  color: var(--cor-text-muted);
}

.remember-me {
  display: flex !important;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--cor-text-muted);
  margin: 12px 0 4px;
  user-select: none;
  text-transform: none !important;
  letter-spacing: normal !important;
}

.remember-me input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--cor-primary);
  cursor: pointer;
}

.btn-logout {
  background: none;
  border: none;
  color: var(--cor-text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
}

.btn-logout:hover {
  color: var(--cor-danger);
  background: rgba(235, 68, 90, 0.1);
}

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  border: none;
  border-radius: var(--radius-pill);
  font-family: var(--font-primary);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
}

.btn ion-icon {
  font-size: 1.1rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--cor-primary) 0%, var(--cor-logo-teal) 100%);
  color: #fff;
  box-shadow: 0 4px 15px rgba(151, 184, 22, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(151, 184, 22, 0.4);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--cor-text-primary);
  border: 1px solid var(--cor-border);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--cor-primary);
}

.btn-outline {
  background: transparent;
  color: var(--cor-primary);
  border: 1px solid var(--cor-primary);
}

.btn-outline:hover {
  background: rgba(151, 184, 22, 0.1);
}

.btn-danger {
  background: var(--cor-danger);
  color: #fff;
}

.btn-danger:hover {
  background: #d33b4e;
  transform: translateY(-1px);
}

.btn-success {
  background: var(--cor-success);
  color: #fff;
}

.btn-sm {
  padding: 8px 18px;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 16px 36px;
  font-size: 1rem;
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-circle);
  font-size: 1.1rem;
}

/* ---- LAYOUT ---- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--cor-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition-normal);
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--cor-border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-header .sidebar-logo-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 36px;
}

.sidebar-header .sidebar-logo-bar {
  width: 8px;
  border-radius: 2px;
}

.sidebar-header .sidebar-logo-bar:nth-child(1) {
  height: 22px;
  background: var(--cor-logo-olive);
}

.sidebar-header .sidebar-logo-bar:nth-child(2) {
  height: 30px;
  background: var(--cor-logo-lime);
}

.sidebar-header .sidebar-logo-bar:nth-child(3) {
  height: 26px;
  background: var(--cor-logo-teal);
}

.sidebar-header .sidebar-title {
  font-family: var(--font-primary);
  font-size: 1.1rem;
  color: var(--cor-text-primary);
}

.sidebar-header .sidebar-subtitle {
  font-size: 0.65rem;
  color: var(--cor-primary);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  display: block;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.sidebar-nav .nav-section {
  padding: 8px 20px 4px;
  font-size: 0.65rem;
  color: var(--cor-text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 600;
}

.sidebar-nav .nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  color: var(--cor-text-secondary);
  font-size: 0.88rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  border-left: 3px solid transparent;
  text-decoration: none;
}

.sidebar-nav .nav-item:hover {
  background: rgba(151, 184, 22, 0.08);
  color: var(--cor-text-primary);
}

.sidebar-nav .nav-item.active {
  background: rgba(151, 184, 22, 0.12);
  color: var(--cor-primary);
  border-left-color: var(--cor-primary);
  font-weight: 600;
}

.sidebar-nav .nav-item ion-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.sidebar-nav .nav-item .badge-nav {
  margin-left: auto;
  background: var(--cor-danger);
  color: #fff;
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 700;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--cor-border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-user .user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-circle);
  background: linear-gradient(135deg, var(--cor-primary), var(--cor-logo-teal));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-user .user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user .user-name {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user .user-role {
  font-size: 0.7rem;
  color: var(--cor-text-muted);
}

.sidebar-user .btn-logout {
  background: none;
  border: none;
  color: var(--cor-text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 1.1rem;
  transition: color var(--transition-fast);
}

.sidebar-user .btn-logout:hover {
  color: var(--cor-danger);
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

/* Topbar */
.topbar {
  height: var(--navbar-height);
  background: var(--bg-navbar);
  border-bottom: 1px solid var(--cor-border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 16px;
}

.topbar .btn-menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--cor-text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
}

.topbar .page-title {
  font-family: var(--font-primary);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--cor-text-primary);
}

.topbar .topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar .search-bar {
  position: relative;
}

.topbar .search-bar input {
  background: var(--bg-card);
  border: 1px solid var(--cor-border);
  border-radius: var(--radius-pill);
  padding: 8px 16px 8px 38px;
  color: var(--cor-text-primary);
  font-size: 0.85rem;
  width: 250px;
  outline: none;
  transition: border-color var(--transition-fast), width var(--transition-normal);
  font-family: var(--font-body);
}

.topbar .search-bar input:focus {
  border-color: var(--cor-primary);
  width: 300px;
}

.topbar .search-bar ion-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--cor-text-muted);
  font-size: 1rem;
}

/* Content Area */
.content-area {
  padding: 28px;
}

/* ---- CARDS ---- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--cor-border);
  overflow: hidden;
  transition: all var(--transition-normal);
}

.card:hover {
  border-color: var(--cor-border-light);
  box-shadow: var(--shadow-md);
}

.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--cor-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h3 {
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  padding: 22px;
}

.card-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--cor-border);
}

/* Stat Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--cor-border);
  padding: 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 80px;
  height: 100%;
  opacity: 0.03;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.stat-card .stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-card .stat-icon.green {
  background: rgba(151, 184, 22, 0.15);
  color: var(--cor-primary);
}

.stat-card .stat-icon.blue {
  background: rgba(56, 128, 255, 0.15);
  color: var(--cor-info);
}

.stat-card .stat-icon.orange {
  background: rgba(255, 196, 9, 0.15);
  color: var(--cor-warning);
}

.stat-card .stat-icon.red {
  background: rgba(235, 68, 90, 0.15);
  color: var(--cor-danger);
}

.stat-card .stat-icon.teal {
  background: rgba(46, 166, 126, 0.15);
  color: var(--cor-logo-teal);
}

.stat-card .stat-info h4 {
  font-size: 0.75rem;
  color: var(--cor-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
  margin-bottom: 4px;
}

.stat-card .stat-value {
  font-size: 1.7rem;
  font-weight: 700;
  font-family: var(--font-primary);
  color: var(--cor-text-primary);
}

/* ---- TABLES ---- */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-md);
}

table {
  width: 100%;
  border-collapse: collapse;
}

table thead th {
  padding: 14px 16px;
  text-align: left;
  font-size: 0.75rem;
  color: var(--cor-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  border-bottom: 1px solid var(--cor-border);
  white-space: nowrap;
}

table tbody td {
  padding: 14px 16px;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--cor-divider);
  color: var(--cor-text-secondary);
}

table tbody tr {
  transition: background var(--transition-fast);
}

table tbody tr:hover {
  background: rgba(151, 184, 22, 0.04);
}

table tbody tr:last-child td {
  border-bottom: none;
}

/* ---- BADGES ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-success {
  background: rgba(45, 211, 111, 0.15);
  color: var(--cor-success);
}

.badge-warning {
  background: rgba(255, 196, 9, 0.15);
  color: var(--cor-warning);
}

.badge-danger {
  background: rgba(235, 68, 90, 0.15);
  color: var(--cor-danger);
}

.badge-info {
  background: rgba(56, 128, 255, 0.15);
  color: var(--cor-info);
}

.badge-neutral {
  background: rgba(138, 138, 138, 0.15);
  color: var(--cor-text-muted);
}

.badge-primary {
  background: rgba(151, 184, 22, 0.15);
  color: var(--cor-primary);
}

.reserva-card {
  border-left: 3px solid var(--cor-primary);
}

.mb-16 {
  margin-bottom: 16px;
}

/* ---- FORMS ---- */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--cor-text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--cor-border);
  border-radius: var(--radius-md);
  color: var(--cor-text-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition-fast);
}

.form-control:focus {
  border-color: var(--cor-primary);
}

.form-control::placeholder {
  color: var(--cor-text-muted);
  opacity: 0.5;
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238A8A8A' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

textarea.form-control {
  min-height: 100px;
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ---- MODAL ---- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-modal);
  border-radius: var(--radius-lg);
  border: 1px solid var(--cor-border);
  width: 95%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px) scale(0.95);
  transition: transform var(--transition-normal);
  box-shadow: var(--shadow-lg);
}

.modal-overlay.active .modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--cor-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--cor-text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px;
  transition: color var(--transition-fast);
}

.modal-close:hover {
  color: var(--cor-text-primary);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--cor-border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* ---- BOOK CARDS (Catálogo) ---- */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
}

.book-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--cor-border);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition-normal);
}

.book-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--cor-primary);
}

.book-card .book-cover {
  height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.book-card .book-cover .cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
  position: relative;
}

.book-card .book-cover .cover-placeholder .book-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
  opacity: 0.9;
  color: #fff;
}

.book-card .book-cover .cover-placeholder .cover-title {
  font-family: var(--font-primary);
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.95);
  line-height: 1.3;
}

.book-card .book-cover .cover-placeholder .cover-author {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 6px;
}

.book-card .book-cover .status-badge {
  position: absolute;
  top: 10px;
  right: 10px;
}

.book-card .book-info {
  padding: 14px;
}

.book-card .book-info .book-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--cor-text-primary);
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-card .book-info .book-author {
  font-size: 0.8rem;
  color: var(--cor-text-muted);
  margin-bottom: 8px;
}

.book-card .book-info .book-category {
  font-size: 0.7rem;
  color: var(--cor-primary);
  font-weight: 600;
}

/* ---- BOOK DETAIL ---- */
.book-detail {
  display: flex;
  gap: 28px;
}

.book-detail .detail-cover {
  width: 260px;
  height: 380px;
  border-radius: var(--radius-md);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  overflow: hidden;
}

.book-detail .detail-cover .book-icon {
  font-size: 4rem;
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: 16px;
}

.book-detail .detail-cover .cover-title {
  font-family: var(--font-primary);
  font-size: 1.1rem;
  color: rgba(255, 255, 255, 0.95);
  font-weight: 600;
}

.book-detail .detail-cover .cover-author {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 8px;
}

.book-detail .detail-info {
  flex: 1;
}

.book-detail .detail-info h1 {
  font-size: 1.6rem;
  margin-bottom: 4px;
}

.book-detail .detail-info .detail-author {
  font-size: 1rem;
  color: var(--cor-text-muted);
  margin-bottom: 16px;
}

.book-detail .detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.book-detail .detail-meta .meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--cor-text-secondary);
  padding: 6px 14px;
  background: var(--bg-card);
  border-radius: var(--radius-pill);
  border: 1px solid var(--cor-border);
}

.book-detail .detail-meta .meta-item ion-icon {
  color: var(--cor-primary);
}

.book-detail .detail-description {
  color: var(--cor-text-secondary);
  line-height: 1.7;
  margin-bottom: 24px;
}

.book-detail .detail-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* ---- EMPTY STATE ---- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--cor-text-muted);
}

.empty-state ion-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 0.95rem;
  margin-bottom: 20px;
}

/* ---- FILTERS ---- */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filters-bar .filter-chip {
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--cor-border);
  background: transparent;
  color: var(--cor-text-secondary);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: var(--font-body);
}

.filters-bar .filter-chip:hover {
  border-color: var(--cor-primary);
  color: var(--cor-primary);
}

.filters-bar .filter-chip.active {
  background: rgba(151, 184, 22, 0.15);
  border-color: var(--cor-primary);
  color: var(--cor-primary);
  font-weight: 600;
}

.filters-bar .search-filter {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.filters-bar .search-filter input {
  width: 100%;
  padding: 8px 16px 8px 38px;
  background: var(--bg-card);
  border: 1px solid var(--cor-border);
  border-radius: var(--radius-pill);
  color: var(--cor-text-primary);
  font-size: 0.85rem;
  outline: none;
  transition: border-color var(--transition-fast);
  font-family: var(--font-body);
}

.filters-bar .search-filter input:focus {
  border-color: var(--cor-primary);
}

.filters-bar .search-filter ion-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--cor-text-muted);
}

/* ---- EMPRÉSTIMO CARDS ---- */
.loan-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--cor-border);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all var(--transition-fast);
  margin-bottom: 12px;
}

.loan-card:hover {
  border-color: var(--cor-border-light);
}

.loan-card .loan-book-cover {
  width: 50px;
  height: 70px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.3rem;
  color: rgba(255, 255, 255, 0.8);
}

.loan-card .loan-info {
  flex: 1;
  min-width: 0;
}

.loan-card .loan-info .loan-booktitle {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--cor-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.loan-card .loan-info .loan-dates {
  font-size: 0.78rem;
  color: var(--cor-text-muted);
  margin-top: 4px;
}

.loan-card .loan-status {
  margin-left: auto;
}

/* ---- QUICK ACTIONS ---- */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}

.quick-action-btn {
  background: var(--bg-card);
  border: 1px solid var(--cor-border);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  color: var(--cor-text-secondary);
  cursor: pointer;
  transition: all var(--transition-normal);
  font-family: var(--font-body);
  font-size: 0.82rem;
}

.quick-action-btn ion-icon {
  font-size: 1.6rem;
  color: var(--cor-primary);
}

.quick-action-btn:hover {
  border-color: var(--cor-primary);
  background: rgba(151, 184, 22, 0.06);
  transform: translateY(-2px);
}

/* ---- DASHBOARD GRID ---- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* ---- ACTIVITY LIST ---- */
.activity-list .activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--cor-divider);
}

.activity-list .activity-item:last-child {
  border-bottom: none;
}

.activity-list .activity-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-circle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.activity-list .activity-text {
  flex: 1;
  font-size: 0.85rem;
  color: var(--cor-text-secondary);
  line-height: 1.5;
}

.activity-list .activity-text strong {
  color: var(--cor-text-primary);
}

.activity-list .activity-time {
  font-size: 0.72rem;
  color: var(--cor-text-muted);
  white-space: nowrap;
}

/* ---- REPORTS ---- */
.report-chart {
  height: 250px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  display: flex;
  align-items: flex-end;
  padding: 20px;
  gap: 8px;
}

.report-bar {
  flex: 1;
  border-radius: 4px 4px 0 0;
  transition: height var(--transition-slow);
  position: relative;
  min-width: 30px;
}

.report-bar .bar-label {
  position: absolute;
  bottom: -24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  color: var(--cor-text-muted);
  white-space: nowrap;
}

.report-bar .bar-value {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--cor-text-primary);
}

/* ---- VIEW TOGGLE ---- */
.view-container {
  display: none;
}

.view-container.active {
  display: block;
}

.login-screen.active {
  display: flex;
}

/* ---- TOAST ---- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--cor-border);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  transform: translateY(100px);
  opacity: 0;
  transition: all var(--transition-normal);
}

.toast.active {
  transform: translateY(0);
  opacity: 1;
}

.toast.success {
  border-left: 3px solid var(--cor-success);
}

.toast.error {
  border-left: 3px solid var(--cor-danger);
}

.toast.warning {
  border-left: 3px solid var(--cor-warning);
}

/* ---- REGISTRATION & VERIFICATION ---- */
.login-container {
  overflow-y: auto;
  max-height: 100vh;
  scrollbar-width: none;
}

.login-container::-webkit-scrollbar {
  display: none;
}

.verify-header {
  text-align: center;
}

.verify-code-inputs {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 8px 0 16px;
}

.code-input {
  width: 48px;
  height: 56px;
  text-align: center;
  font-size: 1.75rem;
  font-weight: 700;
  font-family: monospace;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid var(--cor-border);
  border-radius: var(--radius-md);
  color: #fff;
  outline: none;
  transition: border-color var(--transition-fast);
  caret-color: var(--cor-primary);
}

.code-input:focus {
  border-color: var(--cor-primary);
  box-shadow: 0 0 0 3px rgba(151, 184, 22, 0.2);
}

.verify-actions {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 16px;
}

.btn-link {
  background: none;
  border: none;
  color: var(--cor-primary);
  font-size: 0.85rem;
  cursor: pointer;
  font-family: var(--font-body);
  transition: opacity var(--transition-fast);
}

.btn-link:hover {
  opacity: 0.7;
}

.login-footer a {
  color: var(--cor-primary);
  text-decoration: none;
}

.login-footer a:hover {
  text-decoration: underline;
}

/* ---- CEP LOOKUP ---- */
.cep-status {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  pointer-events: none;
}

.cep-status.loading {
  animation: spin 1s linear infinite;
}

.address-fields {
  animation: slideDown 0.3s ease-out;
}

.address-fields input[readonly] {
  background: rgba(151, 184, 22, 0.06);
  border-color: rgba(151, 184, 22, 0.2);
  color: var(--cor-text-secondary);
}

.input-wrapper {
  position: relative;
}

.input-wrapper .cep-status {
  z-index: 2;
}

/* ---- RESPONSIVE ---- */

/* Desktop large */
@media (min-width: 1400px) {
  .content-area {
    max-width: 1200px;
    margin: 0 auto;
  }
}

/* Tablet */
@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .book-detail {
    flex-direction: column;
  }

  .book-detail .detail-cover {
    width: 100%;
    height: 280px;
  }
}

/* Mobile */
@media (max-width: 768px) {
  :root {
    --navbar-height: 56px;
  }

  /* Sidebar — off-canvas */
  .sidebar {
    transform: translateX(-100%);
    z-index: 200;
    width: 280px;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 150;
    display: none;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
  }

  .sidebar-overlay.active {
    display: block;
  }

  .main-content {
    margin-left: 0;
  }

  /* Topbar */
  .topbar {
    padding: 0 16px;
    gap: 10px;
  }

  .topbar .btn-menu-toggle {
    display: flex;
  }

  .topbar .search-bar {
    flex: 1;
  }

  .topbar .search-bar input {
    width: 100%;
    font-size: 0.82rem;
    padding: 10px 12px 10px 36px;
  }

  .topbar .search-bar input:focus {
    width: 100%;
  }

  .topbar .page-title {
    font-size: 1rem;
  }

  /* Content */
  .content-area {
    padding: 16px;
  }

  /* Stats */
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .stat-card {
    padding: 16px;
    gap: 12px;
  }

  .stat-card .stat-icon {
    width: 44px;
    height: 44px;
    font-size: 1.2rem;
  }

  .stat-card .stat-value {
    font-size: 1.4rem;
  }

  .stat-card .stat-info h4 {
    font-size: 0.68rem;
  }

  /* Books grid */
  .books-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
  }

  .book-card .book-cover {
    height: 190px;
  }

  /* Forms */
  .form-row {
    grid-template-columns: 1fr;
  }

  .flex-between {
    flex-wrap: wrap;
    gap: 12px;
  }

  /* Quick actions */
  .quick-actions {
    grid-template-columns: 1fr 1fr;
  }

  /* Filters */
  .filters-bar {
    gap: 8px;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .filters-bar::-webkit-scrollbar {
    display: none;
  }

  .filters-bar .filter-chip {
    flex-shrink: 0;
    padding: 8px 14px;
    font-size: 0.78rem;
  }

  .filters-bar .search-filter {
    min-width: 100%;
    order: -1;
  }

  /* Tables → mobile card layout */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 600px;
  }

  table thead th {
    padding: 10px 12px;
    font-size: 0.7rem;
  }

  table tbody td {
    padding: 10px 12px;
    font-size: 0.82rem;
  }

  /* Modals — fullscreen on mobile */
  .modal {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
  }

  .modal-header {
    padding: 16px 20px;
  }

  .modal-body {
    padding: 20px;
  }

  /* Loan cards */
  .loan-card {
    padding: 14px;
    gap: 12px;
  }

  .loan-card .loan-book-cover {
    width: 42px;
    height: 58px;
  }

  .loan-card .loan-info .loan-booktitle {
    font-size: 0.85rem;
  }

  .loan-card .loan-info .loan-dates {
    font-size: 0.72rem;
  }

  /* Dashboard grid */
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  /* Buttons touch size */
  .btn {
    min-height: 44px;
  }

  .btn-sm {
    min-height: 38px;
    padding: 8px 14px;
  }

  /* Login responsive */
  .login-screen {
    width: 100vw;
    min-height: 100vh;
    padding: 16px;
  }

  .login-container {
    padding: 24px 20px;
    max-width: 100%;
    width: 100%;
  }

  .main-content {
    max-width: 100vw;
    overflow-x: hidden;
  }

  .content-area {
    max-width: 100%;
    overflow-x: hidden;
  }

  input,
  select,
  textarea {
    max-width: 100%;
  }

  .login-logo {
    margin-bottom: 28px;
  }

  .login-logo .logo-name {
    font-size: 1.7rem;
  }

  .login-form input {
    padding: 12px 12px 12px 40px;
  }

  /* Verification code inputs */
  .code-input {
    width: 42px;
    height: 50px;
    font-size: 1.3rem;
  }

  .verify-code-inputs {
    gap: 6px;
  }

  /* Toast mobile */
  .toast {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }
}

/* Small mobile */
@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .quick-actions {
    grid-template-columns: 1fr;
  }

  .books-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .book-card .book-cover {
    height: 170px;
  }

  .loan-card {
    flex-direction: column;
    text-align: center;
    gap: 10px;
  }

  .loan-card .loan-status {
    margin-left: 0;
  }

  .loan-card .loan-book-cover {
    width: 60px;
    height: 80px;
  }

  .book-detail .detail-cover {
    height: 220px;
  }

  .book-detail .detail-info h1 {
    font-size: 1.3rem;
  }

  .book-detail .detail-meta {
    flex-direction: column;
    gap: 8px;
  }

  /* Code inputs on very small screens */
  .code-input {
    width: 38px;
    height: 46px;
    font-size: 1.2rem;
  }

  .verify-code-inputs {
    gap: 4px;
  }

  /* Login adjustments */
  .login-container {
    padding: 20px 16px;
  }

  .login-logo .logo-bars {
    height: 55px;
  }

  .login-logo .logo-bar {
    width: 14px;
  }

  .login-logo .logo-bar:nth-child(1) {
    height: 40px;
  }

  .login-logo .logo-bar:nth-child(2) {
    height: 52px;
  }

  .login-logo .logo-bar:nth-child(3) {
    height: 44px;
  }

  .login-logo .logo-name {
    font-size: 1.5rem;
    letter-spacing: 2px;
  }

  .login-logo .logo-module {
    font-size: 0.7rem;
    padding: 3px 12px;
  }

  .topbar .page-title {
    font-size: 0.9rem;
  }
}

/* Safe area for notch devices */
@supports(padding: max(0px)) {
  .topbar {
    padding-top: max(0px, env(safe-area-inset-top));
  }

  .content-area {
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  .toast {
    bottom: max(16px, calc(env(safe-area-inset-bottom) + 16px));
  }

  .modal {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ---- ANIMATIONS ---- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(15px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-in {
  animation: fadeInUp 0.4s ease-out backwards;
}

.animate-in:nth-child(1) {
  animation-delay: 0.05s;
}

.animate-in:nth-child(2) {
  animation-delay: 0.1s;
}

.animate-in:nth-child(3) {
  animation-delay: 0.15s;
}

.animate-in:nth-child(4) {
  animation-delay: 0.2s;
}

.animate-in:nth-child(5) {
  animation-delay: 0.25s;
}

.animate-in:nth-child(6) {
  animation-delay: 0.3s;
}

/* Form appear animation */
.login-form {
  animation: slideDown 0.3s ease-out;
}

/* ---- MISC UTILITIES ---- */
.flex {
  display: flex;
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.gap-8 {
  gap: 8px;
}

.gap-12 {
  gap: 12px;
}

.gap-16 {
  gap: 16px;
}

.mb-8 {
  margin-bottom: 8px;
}

.mb-16 {
  margin-bottom: 16px;
}

.mb-24 {
  margin-bottom: 24px;
}

.mt-8 {
  margin-top: 8px;
}

.mt-16 {
  margin-top: 16px;
}

.mt-24 {
  margin-top: 24px;
}

/* Loading spinner */
.btn.loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn.loading::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}