/* ==============================================================================
   apps/reader/portal/portal.css
   RyuRei Studio - "Rak Buku Digital" Whimsical Child-Friendly Theme
   ============================================================================== */

:root {
  --wood-dark: #3e2712;
  --wood-plank: #6f431c;
  --wood-plank-edge: #522f11;
  --wood-highlight: #915a28;
  --wood-shadow: rgba(30, 15, 5, 0.45);
  
  --bg-cream: #fbf7ee;
  --bg-card: #ffffff;
  
  --text-main: #2b1f17;
  --text-muted: #6b5749;
  --text-light: #fefdfb;
  
  --color-primary: #ff6b4a;
  --color-primary-hover: #fa5530;
  --color-secondary: #4a90e2;
  --color-secondary-hover: #357abd;
  --color-success: #27ae60;
  --color-warning: #e67e22;
  --color-danger: #d93829;
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 9999px;

  --shadow-sm: 0 2px 6px rgba(43, 31, 23, 0.08);
  --shadow-md: 0 8px 20px rgba(43, 31, 23, 0.12);
  --shadow-lg: 0 16px 36px rgba(43, 31, 23, 0.18);
  
  --font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Nunito", "Quicksand", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body.wood-theme {
  font-family: var(--font-family);
  background-color: var(--bg-cream);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ==============================================================================
   Top Header
   ============================================================================== */
.portal-header {
  background: linear-gradient(180deg, var(--wood-dark) 0%, var(--wood-plank) 100%);
  color: var(--text-light);
  box-shadow: 0 4px 12px var(--wood-shadow);
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 3px solid var(--wood-plank-edge);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.brand-badge {
  background: var(--color-primary);
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.5px;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.brand-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: #ecd9c6;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.auth-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-greeting {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-right: 0.25rem;
}

.greeting-text {
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
}

.device-badge {
  font-size: 0.7rem;
  background: rgba(255, 255, 255, 0.2);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-pill);
  color: #faeedd;
}

/* ==============================================================================
   Buttons & Micro-interactions
   ============================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0.55rem 1.15rem;
  border-radius: var(--radius-pill);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  min-height: 42px;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 4px 10px rgba(255, 107, 74, 0.35);
}

.btn-primary:hover {
  background: var(--color-primary-hover);
  box-shadow: 0 6px 14px rgba(255, 107, 74, 0.45);
}

.btn-outline {
  background: transparent;
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.8);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: #fff;
}

.btn-outline-danger {
  background: transparent;
  color: #ff9999;
  border: 1.5px solid rgba(255, 150, 150, 0.5);
  font-size: 0.8rem;
  padding: 0.4rem 0.8rem;
  min-height: 36px;
}

.btn-outline-danger:hover {
  background: rgba(217, 56, 41, 0.2);
  color: #fff;
  border-color: #ff5555;
}

.btn-subtle {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 0.8rem;
  padding: 0.4rem 0.8rem;
  min-height: 36px;
}

.btn-subtle:hover {
  background: rgba(255, 255, 255, 0.28);
}

.btn-read {
  background: linear-gradient(135deg, #27ae60 0%, #1e8449 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(39, 174, 96, 0.35);
  width: 100%;
}

.btn-read:hover {
  filter: brightness(1.08);
  box-shadow: 0 6px 16px rgba(39, 174, 96, 0.45);
}

.btn-buy {
  background: linear-gradient(135deg, #ff8c00 0%, #e65100 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(230, 81, 0, 0.35);
  width: 100%;
}

.btn-buy:hover {
  filter: brightness(1.08);
  box-shadow: 0 6px 16px rgba(230, 81, 0, 0.45);
}

.btn-warning {
  background: var(--color-warning);
  color: #fff;
}

.btn-warning:hover {
  filter: brightness(1.08);
}

.btn-danger {
  background: var(--color-danger);
  color: #fff;
}

.btn-danger:hover {
  filter: brightness(1.08);
}

.btn-block {
  width: 100%;
}

/* ==============================================================================
   Main Content & Bookshelf Presentation
   ============================================================================== */
.portal-main {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
  flex: 1;
}

.shelf-header {
  text-align: center;
  margin-bottom: 2rem;
}

.shelf-title {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--wood-dark);
  margin-bottom: 0.4rem;
}

.shelf-description {
  font-size: 0.95rem;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto;
}

/* State Containers (Loading, Error) */
.state-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 1rem;
  text-align: center;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(111, 67, 28, 0.15);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 1rem;
}

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

.state-title {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  color: var(--wood-dark);
}

.state-text {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.state-icon {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--color-danger);
  color: #fff;
  font-size: 1.75rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

/* ==============================================================================
   Responsive Book Grid
   ============================================================================== */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 2rem 1.5rem;
  position: relative;
}

/* Wooden Shelf Plank Simulation */
.book-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  position: relative;
  border: 1px solid rgba(111, 67, 28, 0.08);
}

.book-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-lg);
}

.card-cover-wrap {
  position: relative;
  width: 100%;
  padding-top: 100%; /* 1:1 Aspect Ratio round-square format */
  background: #f0e6d9;
  overflow: hidden;
}

.card-cover-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
}

.book-card:hover .card-cover-img {
  transform: scale(1.03);
}

.badge-tag {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  z-index: 2;
}

.badge-unlocked {
  background: var(--color-success);
  color: #fff;
}

.badge-locked {
  background: rgba(43, 31, 23, 0.85);
  color: #fff;
  backdrop-filter: blur(4px);
}

.card-body {
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--wood-dark);
  margin-bottom: 0.4rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.7rem;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.15rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.card-pages {
  background: #f4ecdf;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  color: var(--wood-plank);
}

.card-actions {
  margin-top: auto;
}

/* ==============================================================================
   Notification Banner
   ============================================================================== */
.notification-banner {
  max-width: 1200px;
  margin: 1rem auto 0;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
}

.notification-banner.success {
  background: #e8f8f0;
  color: #1e8449;
  border-left: 5px solid #27ae60;
}

.notification-banner.error {
  background: #fdeeee;
  color: #c0392b;
  border-left: 5px solid #d93829;
}

/* ==============================================================================
   Modals & Dialogs
   ============================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(30, 15, 5, 0.65);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  z-index: 100;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 460px;
  width: 100%;
  padding: 2rem;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid rgba(111, 67, 28, 0.1);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1.15rem;
  background: none;
  border: none;
  font-size: 1.75rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem;
}

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

.modal-tabs {
  display: flex;
  border-bottom: 2px solid #ede4d8;
  margin-bottom: 1.5rem;
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  padding: 0.65rem 0.5rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  transition: color 0.2s ease;
}

.tab-btn.active {
  color: var(--color-primary);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--color-primary);
  border-radius: var(--radius-pill);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.modal-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--wood-dark);
  margin-bottom: 0.35rem;
}

.modal-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  line-height: 1.4;
}

.modal-icon-badge {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #fef4e6;
  color: var(--color-warning);
  font-size: 1.75rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
}

.modal-icon-badge.check {
  background: #e8f8f0;
  color: var(--color-success);
}

/* ==============================================================================
   Forms
   ============================================================================== */
.form-group {
  margin-bottom: 1.15rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-family: inherit;
  font-size: 0.95rem;
  border: 1.5px solid #dccdc0;
  border-radius: var(--radius-md);
  background: #faf6f0;
  color: var(--text-main);
  transition: border-color 0.2s ease, background-color 0.2s ease;
  min-height: 46px;
}

.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255, 107, 74, 0.15);
}

.form-help {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

.form-error {
  display: block;
  font-size: 0.75rem;
  color: var(--color-danger);
  font-weight: 700;
  margin-top: 0.3rem;
}

.form-alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 1.15rem;
}

.form-alert.error {
  background: #fdeeee;
  color: #c0392b;
  border-left: 4px solid var(--color-danger);
}

.form-alert.success {
  background: #e8f8f0;
  color: #1e8449;
  border-left: 4px solid var(--color-success);
}

.form-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.form-footer-link {
  text-align: center;
  margin-top: 1rem;
}

.form-footer-link a {
  font-size: 0.82rem;
  color: var(--color-secondary);
  text-decoration: none;
  font-weight: 700;
}

.form-footer-link a:hover {
  text-decoration: underline;
}

/* ==============================================================================
   Footer
   ============================================================================== */
.portal-footer {
  background: var(--wood-dark);
  color: #baa795;
  padding: 1.75rem 1.25rem;
  text-align: center;
  font-size: 0.8rem;
  margin-top: auto;
}

.footer-copy {
  color: #fff;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

/* Utility Classes */
.hidden {
  display: none !important;
}

/* Mobile Responsiveness */
@media (max-width: 640px) {
  .header-inner {
    flex-wrap: wrap;
  }
  .brand-title {
    font-size: 1.05rem;
  }
  .book-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  .user-greeting {
    display: none; /* Compact header on small screens */
  }
}
