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

:root {
  /* Color Palette - HSL values for flexibility */
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  
  --bg-primary: #f0f2f5;
  --bg-card: rgba(255, 255, 255, 0.7);
  --bg-header: rgba(255, 255, 255, 0.8);
  --text-primary: #1f2937;
  --text-secondary: #4b5563;
  --border-color: rgba(255, 255, 255, 0.4);
  --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.08);
  --glass-border: 1px solid rgba(255, 255, 255, 0.18);
  --accent-color: #3b82f6;
  --danger-color: #ef4444;
  --success-color: #10b981;
  
  /* Category Colors */
  --clr-haus: #10b981;
  --clr-arbeit: #3b82f6;
  --clr-auto: #f59e0b;
  --clr-schule: #8b5cf6;
  --clr-versicherung: #ef4444;
  --clr-ausweise: #06b6d4;
  --clr-nummern: #ec4899;
  --clr-sonstiges: #6b7280;

  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #0b0f19;
    --bg-card: rgba(22, 28, 45, 0.7);
    --bg-header: rgba(11, 15, 25, 0.85);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --border-color: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --glass-border: 1px solid rgba(255, 255, 255, 0.05);
    --accent-color: #60a5fa;
  }
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

html {
  height: -webkit-fill-available;
}

/* App Container and Navigation Layout */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: -webkit-fill-available;
  position: relative;
  overflow: hidden;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  background-color: var(--bg-header);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: var(--glass-border);
  position: sticky;
  top: 0;
  z-index: 10;
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--accent-color), #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  cursor: pointer;
  user-select: none;
}

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

.header-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  padding: 0.5rem;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s, transform 0.1s;
  background-color: rgba(255, 255, 255, 0.05);
}

.header-btn:active {
  transform: scale(0.92);
  background-color: rgba(255, 255, 255, 0.15);
}

.header-btn svg {
  width: 1.25rem;
  height: 1.25rem;
  stroke: currentColor;
}

/* Viewport and Views transition */
main {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.view {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease;
  z-index: 1;
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
}

.view.active {
  transform: translateX(0);
  opacity: 1;
  z-index: 2;
  pointer-events: auto;
}

.view.slide-left {
  transform: translateX(-100%);
  opacity: 0;
}

/* Custom Scrollbars */
.view::-webkit-scrollbar {
  width: 6px;
}
.view::-webkit-scrollbar-track {
  background: transparent;
}
.view::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 3px;
}
@media (prefers-color-scheme: dark) {
  .view::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
  }
}

/* View Header */
.view-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  width: 100%;
}

.view-header-title-container {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.view-header .back-btn,
.view-header .edit-toggle-btn,
.view-header .share-btn {
  flex-shrink: 0;
}

.back-btn {
  background: var(--bg-card);
  border: var(--glass-border);
  color: var(--text-primary);
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--glass-shadow);
  transition: transform 0.15s, background-color 0.2s;
}

.back-btn svg {
  width: 1.35rem;
  height: 1.35rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
}

.back-btn:active {
  transform: scale(0.92);
}

.edit-toggle-btn {
  background: var(--bg-card);
  border: var(--glass-border);
  color: var(--text-primary);
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--glass-shadow);
  transition: transform 0.15s, background-color 0.2s, color 0.2s, border-color 0.2s;
  margin-left: auto;
}

.edit-toggle-btn svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
}

.edit-toggle-btn:active {
  transform: scale(0.92);
}

.share-btn {
  background: var(--bg-card);
  border: var(--glass-border);
  color: var(--text-primary);
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--glass-shadow);
  transition: transform 0.15s, background-color 0.2s, color 0.2s, border-color 0.2s;
  margin-left: auto;
}

.share-btn svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
}

.share-btn:active {
  transform: scale(0.92);
}

.view-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.title-icon-wrapper {
  display: flex;
  align-items: center;
}

.title-icon-wrapper svg {
  width: 1.5rem;
  height: 1.5rem;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
}

/* Grid layout for categories */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  padding-bottom: 2rem;
}

@media (min-width: 640px) {
  .categories-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1024px) {
  .categories-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Category Card Styling */
.category-card {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--bg-card);
  border: var(--glass-border);
  border-radius: 1.5rem;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  box-shadow: var(--glass-shadow);
  overflow: hidden;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s;
}

.category-card:active {
  transform: scale(0.95);
}

.category-icon-wrapper {
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  margin-bottom: 1rem;
  position: relative;
  z-index: 2;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
  transition: transform 0.3s ease;
}

.category-card:hover .category-icon-wrapper {
  transform: translateY(-2px) scale(1.05);
}

.category-icon-wrapper svg {
  width: 1.5rem;
  height: 1.5rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.category-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  position: relative;
  z-index: 2;
}

.category-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, transparent, rgba(255,255,255,0.03));
  pointer-events: none;
}

/* Delete button inside custom category/subcategory */
.delete-btn-bubble {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger-color);
  border: none;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.2s, background-color 0.2s;
}

.category-card:hover .delete-btn-bubble {
  opacity: 1;
}

.subcategory-item .delete-btn-bubble {
  position: static;
  opacity: 1 !important;
  display: flex;
}

/* Touch friendly delete display for mobile */
@media (max-width: 768px) {
  .delete-btn-bubble {
    opacity: 0.6;
  }
}

.delete-btn-bubble svg {
  width: 0.85rem;
  height: 0.85rem;
  stroke: currentColor;
}

.delete-btn-bubble:hover {
  background-color: var(--danger-color);
  color: white;
}

/* Add Category Card */
.category-card.add-card {
  border: 2px dashed var(--border-color);
  background: transparent;
  box-shadow: none;
  justify-content: center;
  align-items: center;
}

.category-card.add-card:active {
  background-color: rgba(255,255,255,0.02);
}

.add-card-icon {
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.add-card-icon svg {
  width: 2rem;
  height: 2rem;
}

.add-card-text {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Subcategories View */
.subcategories-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-bottom: 2rem;
}

.subcategory-item {
  position: relative;
  background: var(--bg-card);
  border: var(--glass-border);
  border-radius: 1.25rem;
  padding: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--glass-shadow);
  transition: transform 0.15s, background-color 0.2s;
}

.subcategory-item:active {
  transform: scale(0.98);
}

.subcategory-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.subcategory-bullet {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
}

.subcategory-name {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
}

.subcategory-name-input {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--accent-color);
  outline: none;
  padding: 0.1rem 0;
  width: 100%;
  font-family: inherit;
  box-sizing: border-box;
}

.category-name-input {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--accent-color);
  outline: none;
  padding: 0.1rem 0;
  width: 100%;
  font-family: inherit;
  box-sizing: border-box;
  z-index: 2;
}

.subcategory-count {
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.05);
  padding: 0.25rem 0.6rem;
  border-radius: 1rem;
}
@media (prefers-color-scheme: dark) {
  .subcategory-count {
    background: rgba(255, 255, 255, 0.05);
  }
}

.chevron-right svg {
  width: 1.25rem;
  height: 1.25rem;
  stroke: var(--text-secondary);
  fill: none;
}

/* Subcategory add button */
.add-sub-btn {
  background: none;
  border: 2px dashed var(--border-color);
  border-radius: 1.25rem;
  padding: 1.25rem;
  color: var(--text-secondary);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background-color 0.2s;
}

.add-sub-btn:active {
  background-color: rgba(255,255,255,0.02);
}

.add-sub-btn svg {
  width: 1.25rem;
  height: 1.25rem;
}

/* Documents View list */
.add-doc-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 2rem;
}

/* Large Adding Card */
.large-add-btn {
  width: 100%;
  max-width: 320px;
  aspect-ratio: 4 / 3;
  background: linear-gradient(135deg, var(--accent-color), #ec4899);
  border: none;
  border-radius: 2rem;
  color: white;
  font-family: var(--font-family);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  box-shadow: 0 10px 25px rgba(59, 130, 246, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
}

.large-add-btn:active {
  transform: scale(0.96);
  box-shadow: 0 5px 15px rgba(59, 130, 246, 0.2);
}

.large-add-icon svg {
  width: 3rem;
  height: 3rem;
  stroke: currentColor;
  stroke-width: 2.2;
}

.large-add-text {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}

/* Documents Grid */
.documents-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

@media (min-width: 640px) {
  .documents-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Document Card */
.document-card {
  position: relative;
  background: var(--bg-card);
  border: var(--glass-border);
  border-radius: 1.25rem;
  padding: 0.75rem;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--glass-shadow);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: transform 0.2s, box-shadow 0.2s;
}

.document-card:active {
  transform: scale(0.96);
}

.document-preview-thumb {
  aspect-ratio: 3 / 4;
  border-radius: 0.75rem;
  background: rgba(0, 0, 0, 0.03);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border: 1px solid rgba(0,0,0,0.05);
}
@media (prefers-color-scheme: dark) {
  .document-preview-thumb {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255,255,255,0.05);
  }
}

.document-preview-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.document-preview-thumb svg {
  width: 2.5rem;
  height: 2.5rem;
  stroke: var(--text-secondary);
}

.document-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.document-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.document-date {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-secondary);
}

.empty-state svg {
  width: 3.5rem;
  height: 3.5rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  margin-bottom: 1rem;
  opacity: 0.6;
}

.empty-state p {
  font-size: 0.95rem;
}

/* Modals Dialog Styling */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background-color: var(--bg-header);
  border-top-left-radius: 2rem;
  border-top-right-radius: 2rem;
  width: 100%;
  max-width: 500px;
  padding: 2rem;
  padding-bottom: calc(2rem + var(--safe-area-bottom));
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.2);
  transform: translateY(100%);
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.modal.active .modal-content {
  transform: translateY(0);
}

@media (min-width: 501px) {
  .modal {
    align-items: center;
  }
  
  .modal-content {
    border-radius: 2rem;
    padding-bottom: 2rem;
    transform: translateY(30px);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.25rem;
}

.modal-close svg {
  width: 1.5rem;
  height: 1.5rem;
  stroke: currentColor;
}

/* Dialog actions layout */
.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.add-choice-btn {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1.25rem;
  background: var(--bg-card);
  border: var(--glass-border);
  border-radius: 1.25rem;
  cursor: pointer;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 1.1rem;
  font-weight: 600;
  transition: background-color 0.2s, transform 0.1s;
  box-shadow: var(--glass-shadow);
}

.add-choice-btn:active {
  transform: scale(0.97);
  background-color: rgba(255,255,255,0.05);
}

.choice-icon {
  width: 3rem;
  height: 3rem;
  border-radius: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.choice-icon svg {
  width: 1.5rem;
  height: 1.5rem;
  stroke: currentColor;
  fill: none;
}

.choice-icon.camera {
  background: linear-gradient(135deg, #ec4899, #f43f5e);
}

.choice-icon.file {
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
}

.choice-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
}

.choice-subtext {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 400;
}

/* Custom categories / subcategories inputs */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input {
  width: 100%;
  padding: 1rem;
  background: var(--bg-primary);
  border: var(--glass-border);
  border-radius: 1rem;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 1rem;
  outline: none;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

.form-input:focus {
  border-color: var(--accent-color);
}

.color-picker {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.color-option {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: transform 0.15s, border-color 0.15s;
}

.color-option.selected {
  border-color: var(--text-primary);
  transform: scale(1.1);
}

.btn-submit {
  background: var(--accent-color);
  color: white;
  border: none;
  border-radius: 1rem;
  padding: 1rem;
  font-family: var(--font-family);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

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

/* Document Viewer Modal */
.doc-viewer-modal .modal-content {
  max-width: 100%;
  width: 100%;
  height: 90vh;
  padding: 1.5rem 0;
  display: flex;
  flex-direction: column;
}

@media (min-width: 768px) {
  .doc-viewer-modal .modal-content {
    max-width: 800px;
    height: 85vh;
  }
}

.doc-viewer-modal .modal-header {
  padding: 0 1.5rem 1rem 1.5rem;
}

.doc-viewer-body {
  flex: 1;
  width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  background: #000;
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-top: var(--glass-border);
  border-bottom: var(--glass-border);
  position: relative;
}

.doc-viewer-body iframe {
  width: 1px;
  min-width: 100%;
  max-width: 100%;
  height: 100%;
  border: none;
}

.doc-viewer-body img {
  width: 100%;
  height: auto;
  max-height: 80vh;
  object-fit: contain;
  border: none;
  display: block;
}

.doc-viewer-modal .doc-viewer-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  padding: 0 1.5rem;
}

.delete-doc-btn {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger-color);
  border: none;
  border-radius: 1rem;
  padding: 0.75rem 1.25rem;
  font-family: var(--font-family);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background-color 0.2s;
}

.delete-doc-btn:hover {
  background: rgba(239, 68, 68, 0.2);
}

.delete-doc-btn svg {
  width: 1.15rem;
  height: 1.15rem;
  stroke: currentColor;
}

/* Toast Notifications */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translate(-50%, 100px);
  background: rgba(0, 0, 0, 0.85);
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 2rem;
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 1000;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 5px 20px rgba(0,0,0,0.3);
  pointer-events: none;
}

.toast.active {
  transform: translate(-50%, 0);
}

#documents-container {
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* Large Document View styling */
.large-doc-viewer-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

.large-doc-viewer {
  width: calc(100% + 3rem);
  margin-left: -1.5rem;
  margin-right: -1.5rem;
  background-color: #000;
  border-left: none;
  border-right: none;
  border-top: var(--glass-border);
  border-bottom: var(--glass-border);
  position: relative;
  overflow-x: hidden;
  overflow-y: visible;
  height: auto;
  flex-shrink: 0;
}

.large-doc-viewer iframe {
  width: 1px;
  min-width: 100%;
  max-width: 100%;
  height: 85vh;
  border: none;
  display: block;
}

.large-doc-viewer img {
  width: 100%;
  height: auto;
  border: none;
  display: block;
}

.large-doc-actions {
  display: flex;
  justify-content: center;
  padding: 0.5rem 0 1rem;
}

/* Live Camera Modal Styling */
.camera-modal-content {
  max-width: 500px;
  height: 80vh;
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
}

@media (max-width: 500px) {
  .camera-modal-content {
    height: 100vh;
    border-radius: 0;
  }
}

.camera-stream-container {
  flex: 1;
  position: relative;
  background: #000;
  border-radius: 1rem;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#camera-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.camera-frame-guideline {
  width: 85%;
  height: 80%;
  border: 2px dashed rgba(255, 255, 255, 0.5);
  border-radius: 0.75rem;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.4);
}

.camera-modal-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem 0;
}

.camera-capture-btn {
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 50%;
  border: 4px solid var(--text-primary);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s;
}

.camera-capture-btn:active {
  transform: scale(0.9);
}

.camera-capture-btn .inner-circle {
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 50%;
  background-color: var(--danger-color);
  transition: background-color 0.2s;
}

.camera-capture-btn:hover .inner-circle {
  background-color: #f43f5e;
}

/* Live Camera Error Fallback */
.camera-fallback-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  background-color: #121212;
  color: #fff;
  z-index: 5;
}

.camera-fallback-container p {
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
  color: #a0aec0;
  line-height: 1.5;
}

.btn-fallback-upload {
  background-color: var(--accent-color);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-family: var(--font-family);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
  transition: transform 0.15s, background-color 0.2s;
}

.btn-fallback-upload:active {
  transform: scale(0.95);
}

/* PDF.js Canvas Rendering Layout */
.pdf-canvas-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  width: 100%;
  background-color: #121212;
  padding: 1.5rem 0;
  align-items: center;
  overflow-x: hidden;
  overflow-y: visible;
  flex-shrink: 0;
  height: auto;
}

.pdf-page-canvas {
  width: 100%;
  max-width: 100%;
  height: auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  display: block;
  border-radius: 0.25rem;
  flex-shrink: 0;
}

.pdf-loading {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 100%;
}

.pdf-loading::after {
  content: "";
  width: 2rem;
  height: 2rem;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: spinner 0.8s linear infinite;
}

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

.pdf-error {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--danger-color);
  font-size: 0.95rem;
  font-weight: 500;
  width: 100%;
}

/* ==================== ANIMATIONS & TRANSITIONS ==================== */

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes wiggle {
  0% { transform: rotate(-0.5deg); }
  50% { transform: rotate(0.5deg); }
  100% { transform: rotate(-0.5deg); }
}

/* Staggered entrance for cards & items */
.category-card {
  animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.subcategory-item {
  animation: fadeInUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.add-sub-btn {
  animation: fadeInUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.add-doc-container {
  animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.large-doc-viewer-container {
  animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Wiggle animation in category & subcategory edit mode */
.category-card.in-edit-mode {
  animation: wiggle 0.22s ease-in-out infinite;
}

.subcategory-item.in-edit-mode {
  animation: wiggle 0.22s ease-in-out infinite;
}

/* Disable wiggling when the inline edit input is active/focused */
.category-card.in-edit-mode:has(.category-name-input:focus) {
  animation: none;
}

.subcategory-item.in-edit-mode:has(.subcategory-name-input:focus) {
  animation: none;
}

/* Highlight delete bubble in edit mode */
.category-card.in-edit-mode .delete-btn-bubble {
  opacity: 1;
  transform: scale(1.1);
}

/* Hover effects for desktop users (using media queries for hover capability) */
@media (hover: hover) {
  .category-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15), var(--glass-shadow);
  }
  
  .subcategory-item:hover {
    transform: translateY(-2px);
    background-color: rgba(255, 255, 255, 0.03);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1), var(--glass-shadow);
  }
}
