/* DocScAndroid Styles */
:root {
  --primary-color: #2196F3;
  --primary-dark: #1976D2;
  --primary-light: #BBDEFB;
  --accent-color: #FF4081;
  --background: #FAFAFA;
  --surface: #FFFFFF;
  --error: #F44336;
  --on-primary: #FFFFFF;
  --on-surface: #000000;
  --text-primary: rgba(0, 0, 0, 0.87);
  --text-secondary: rgba(0, 0, 0, 0.54);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Roboto', sans-serif;
  background-color: var(--background);
  overflow-x: hidden;
}

.main-content {
  min-height: 100vh;
  position: relative;
}

/* Top App Bar Customization */
.mdc-top-app-bar {
  background-color: var(--primary-color);
}

.mdc-top-app-bar__title {
  font-weight: 500;
}

/* Clickable app title for home navigation */
.app-title-home {
  cursor: pointer;
  transition: opacity 0.2s ease;
  user-select: none;
}

.app-title-home:hover {
  opacity: 0.8;
}

.app-title-home:active {
  opacity: 0.6;
}

/* Welcome Screen */
.welcome-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 64px);
  padding: 24px;
  text-align: center;
}

.welcome-content {
  max-width: 400px;
}

.welcome-icon {
  font-size: 72px;
  color: var(--primary-color);
  margin-bottom: 24px;
}

.welcome-title {
  font-size: 32px;
  font-weight: 400;
  margin: 0 0 16px 0;
  color: var(--text-primary);
}

.welcome-description {
  font-size: 16px;
  color: var(--text-secondary);
  margin: 0 0 32px 0;
  line-height: 1.5;
}

/* Camera Section */
.camera-container {
  position: relative;
  width: 100%;
  height: calc(100vh - 64px);
  background: #000;
  overflow: hidden;
}

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

.camera-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  pointer-events: none;
}

#edge-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.camera-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 300px;
  padding: 32px;
  pointer-events: all;
  z-index: 2;
}

.capture-btn {
  background-color: var(--surface) !important;
  color: var(--primary-color) !important;
  width: 64px !important;
  height: 64px !important;
}

.capture-btn .mdc-fab__icon {
  font-size: 32px;
}

.mdc-fab--mini {
  background-color: rgba(255, 255, 255, 0.9) !important;
  color: var(--text-primary) !important;
}

/* Editor Section */
.editor-container {
  width: 100%;
  height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  background: var(--background);
}

.editor-header {
  display: flex;
  align-items: center;
  padding: 16px;
  background: var(--surface);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.editor-title {
  flex: 1;
  font-size: 20px;
  font-weight: 500;
  text-align: center;
  color: var(--text-primary);
}

.editor-canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f5f5;
}

#editor-canvas {
  max-width: 100%;
  max-height: 100%;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.corner-handle {
  position: absolute;
  width: 24px;
  height: 24px;
  border: 2px solid var(--primary-color);
  background: var(--surface);
  border-radius: 50%;
  cursor: pointer;
  transform: translate(-50%, -50%);
  z-index: 10;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.corner-handle:hover {
  background: var(--primary-light);
}

.editor-controls {
  display: flex;
  justify-content: space-around;
  padding: 16px;
  background: var(--surface);
  box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.1);
}

/* Pages Management */
.pages-container {
  width: 100%;
  min-height: calc(100vh - 64px);
  background: var(--background);
  padding: 16px;
}

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

.pages-title {
  font-size: 24px;
  font-weight: 400;
  margin: 0;
  color: var(--text-primary);
}

.pages-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.pages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.page-item {
  position: relative;
  background: var(--surface);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: box-shadow 0.2s;
}

.page-item:hover {
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.page-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: #f5f5f5;
}

.page-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px;
}

.page-number {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

.page-delete {
  color: var(--error) !important;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.mdc-circular-progress {
  width: 48px;
  height: 48px;
}

.loading-text {
  color: var(--surface);
  font-size: 16px;
  margin-top: 16px;
  font-weight: 500;
}

/* Material Design Button Customizations */
.mdc-button--raised {
  background-color: var(--primary-color) !important;
}

.mdc-button--outlined {
  border-color: var(--primary-color) !important;
  color: var(--primary-color) !important;
}

/* Responsive Design */
@media (max-width: 480px) {
  .pages-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
  }
  
  .pages-header {
    flex-direction: column;
    align-items: stretch;
  }
  
  .pages-actions {
    justify-content: center;
  }
  
  .camera-controls {
    max-width: 280px;
    padding: 24px;
  }
  
  .welcome-content {
    padding: 0 16px;
  }
  
  .welcome-icon {
    font-size: 64px;
  }
  
  .welcome-title {
    font-size: 28px;
  }
}

@media (max-width: 360px) {
  .camera-controls {
    max-width: 260px;
    padding: 20px;
  }
  
  .capture-btn {
    width: 56px !important;
    height: 56px !important;
  }
  
  .capture-btn .mdc-fab__icon {
    font-size: 28px;
  }
}

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

.fade-in {
  animation: fadeIn 0.3s ease-in;
}

.fade-out {
  animation: fadeOut 0.3s ease-out;
}

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

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

/* Custom scrollbar for webkit browsers */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--background);
}

::-webkit-scrollbar-thumb {
  background: var(--primary-light);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-color);
}