/* ==========================================================================
   Mobile-First Native App Styles - Buch App
   ========================================================================== */

:root {
  --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  
  --bg-app: #080c16;
  --bg-surface: #111a2e;
  --bg-surface-elevated: #1a2642;
  
  --border-subtle: rgba(56, 189, 248, 0.12);
  --border-blue: rgba(59, 130, 246, 0.35);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;

  --blue-primary: #2563eb;
  --blue-hover: #1d4ed8;
  --blue-light: #3b82f6;
  --cyan-glow: #38bdf8;

  --star-color: #fbbf24;
  --star-empty: #2e3c54;

  --danger-color: #ef4444;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;

  --shadow-sheet: 0 -10px 40px rgba(0, 0, 0, 0.7);
  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.35);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-family);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

/* LOGIN OVERLAY */
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-app);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-blue);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0,0,0,0.6);
}

.login-avatar img {
  width: 68px;
  height: 68px;
  border-radius: var(--radius-md);
  box-shadow: 0 0 20px rgba(37, 99, 235, 0.4);
  margin-bottom: 12px;
}

.login-card h2 {
  font-size: 1.4rem;
  font-weight: 800;
}

.login-sub {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.input-field input {
  width: 100%;
  min-height: 48px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: #fff;
  padding: 0 16px;
  font-size: 0.95rem;
  margin-bottom: 12px;
  font-family: inherit;
}

.input-field input:focus {
  outline: none;
  border-color: var(--blue-light);
  background: rgba(37, 99, 235, 0.1);
}

.login-error {
  color: #fca5a5;
  font-size: 0.85rem;
  margin-bottom: 14px;
}

.btn-primary-mobile {
  width: 100%;
  min-height: 50px;
  background: linear-gradient(135deg, var(--blue-primary) 0%, var(--blue-hover) 100%);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-primary-mobile:active {
  transform: scale(0.98);
}

/* APP MAIN WRAPPER */
.app-wrapper {
  max-width: 600px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 100px;
}

/* TOP NAVBAR */
.mobile-navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(8, 12, 22, 0.9);
  backdrop-filter: blur(16px);
  padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-app-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.nav-titles h1 {
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.1;
  background: linear-gradient(135deg, #ffffff 0%, var(--cyan-glow) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.nav-logout-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.nav-logout-btn:active {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

/* SEARCH & CATEGORY PILLS */
.mobile-search-bar {
  padding: 12px 16px 8px;
}

.search-input-wrapper {
  position: relative;
  width: 100%;
}

.search-svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--cyan-glow);
}

.search-input-wrapper input {
  width: 100%;
  min-height: 44px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: #fff;
  padding: 0 40px 0 42px;
  font-size: 0.9rem;
  font-family: inherit;
}

.search-input-wrapper input:focus {
  outline: none;
  border-color: var(--blue-light);
}

.clear-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.4rem;
}

/* Category Pills Horizontal Scroll */
.category-pills-container {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 0 4px;
  scrollbar-width: none;
}

.category-pills-container::-webkit-scrollbar {
  display: none;
}

.pill-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pill-item.active {
  background: var(--blue-primary);
  color: white;
  border-color: var(--blue-light);
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.4);
}

/* SORT SELECTOR BAR */
.mobile-sort-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 16px 12px;
}

.sort-label {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  font-weight: 600;
  text-transform: uppercase;
}

.mobile-sort-bar select {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--cyan-glow);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-family: inherit;
  font-weight: 600;
}

.mobile-sort-bar select option {
  background: #0f172a;
  color: #fff;
}

/* BOOKS LIST / FEED */
.mobile-feed {
  padding: 0 16px;
}

.books-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.book-card-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  gap: 12px;
  position: relative;
  box-shadow: var(--shadow-card);
  transition: transform 0.2s ease;
}

.book-card-item:active {
  transform: scale(0.99);
}

.card-cover {
  width: 76px;
  height: 106px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  background: #1e293b;
}

.card-cover-placeholder {
  width: 76px;
  height: 106px;
  border-radius: 10px;
  background: var(--bg-surface-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  flex-shrink: 0;
}

.card-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
}

.card-top {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.card-cat-badge {
  align-self: flex-start;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--cyan-glow);
  background: rgba(56, 189, 248, 0.1);
  padding: 2px 7px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-author {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.card-stars {
  color: var(--star-color);
  font-size: 0.95rem;
  margin-top: 2px;
}

.card-review-quote {
  font-size: 0.78rem;
  color: #cbd5e1;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 4px;
}

.card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.action-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.action-btn.delete {
  color: rgba(239, 68, 68, 0.8);
}

/* FAB BUTTON */
.mobile-fab {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  right: 20px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue-primary) 0%, var(--blue-hover) 100%);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 8px 25px rgba(37, 99, 235, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 200;
}

.mobile-fab:active {
  transform: scale(0.92);
}

/* EMPTY STATE */
.mobile-empty-state {
  text-align: center;
  padding: 60px 20px;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-subtle);
  margin-top: 12px;
}

.empty-emoji {
  font-size: 3.5rem;
  margin-bottom: 12px;
}

.mobile-empty-state h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.mobile-empty-state p {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* iOS BOTTOM SHEET MODAL */
.bottom-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 15, 0.85);
  backdrop-filter: blur(12px);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.bottom-sheet-card {
  background: #0d1424;
  border-top: 1px solid var(--border-blue);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 12px 20px 24px;
  box-shadow: var(--shadow-sheet);
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-handle {
  width: 38px;
  height: 5px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 99px;
  margin: 0 auto 14px;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.sheet-header h2 {
  font-size: 1.2rem;
  font-weight: 800;
}

.sheet-close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.8rem;
  cursor: pointer;
  line-height: 1;
}

.sheet-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.field-group input,
.field-group select,
.field-group textarea {
  width: 100%;
  min-height: 46px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: white;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.92rem;
}

.field-group select option {
  background: #0f172a;
}

.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus {
  outline: none;
  border-color: var(--blue-light);
}

.custom-cat-input {
  margin-top: 8px;
}

/* Mobile Star Rating */
.mobile-star-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.mobile-star-picker .star-item {
  font-size: 1.8rem;
  color: var(--star-empty);
  cursor: pointer;
}

.mobile-star-picker .star-item.active {
  color: var(--star-color);
}

.star-count-label {
  margin-left: auto;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.btn-sheet-cancel {
  flex: 1;
  min-height: 48px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: white;
  border-radius: var(--radius-md);
  font-weight: 600;
}

/* Detail Sheet */
.detail-sheet {
  padding-bottom: 30px;
}

.detail-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* TOAST */
.mobile-toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  background: #111a2e;
  border: 1px solid var(--blue-light);
  color: white;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 700;
  z-index: 3000;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  transition: all 0.25s ease;
}

.mobile-toast.hidden {
  opacity: 0;
  transform: translate(-50%, 20px);
  pointer-events: none;
}
