/* CSS Variables & Theme Setup */
:root {
  --bg-primary: #070e17;
  --bg-secondary: #0a1628;
  --bg-tertiary: #10233d;
  
  --accent-color: #3d8ef8;
  --accent-hover: #67a6f9;
  --accent-transparent: rgba(61, 142, 248, 0.15);
  
  --text-primary: #ffffff;
  --text-secondary: #8da2bb;
  --text-muted: #536b85;
  
  --card-bg: rgba(255, 255, 255, 0.03);
  --card-border: rgba(255, 255, 255, 0.05);
  --card-hover-border: rgba(61, 142, 248, 0.3);
  --card-active-border: #3d8ef8;
  
  --border-radius: 12px;
  --header-height: 70px;
  --sidebar-width: 360px;
  
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  height: var(--header-height);
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 10;
  box-shadow: var(--shadow-sm);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 24px;
  color: var(--accent-color);
}

.header-logo h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.header-logo h1 span {
  color: var(--accent-color);
  font-weight: 400;
}

.search-container {
  position: relative;
  width: 400px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
}

#search-input {
  width: 100%;
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  color: var(--text-primary);
  padding: 10px 16px 10px 40px;
  border-radius: 30px;
  font-size: 14px;
  outline: none;
  transition: all 0.3s ease;
}

#search-input:focus {
  border-color: var(--accent-color);
  background-color: rgba(255, 255, 255, 0.07);
  box-shadow: 0 0 0 3px var(--accent-transparent);
}

/* Layout App Container */
.app-container {
  display: flex;
  flex: 1;
  height: calc(100vh - var(--header-height));
  position: relative;
}

/* Sidebar */
.app-sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Categories Filter Buttons */
.categories-nav {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid var(--card-border);
}

.category-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all 0.2s ease;
}

.category-btn:hover {
  background-color: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.category-btn.active {
  background-color: var(--accent-transparent);
  color: var(--accent-color);
  border-color: rgba(61, 142, 248, 0.2);
}

/* Documents List Area */
.documents-list-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.sidebar-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 600;
}

.documents-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Document Cards (Glassmorphism) */
.doc-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius);
  padding: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.doc-card::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 4px;
  background-color: var(--accent-color);
  transform: scaleY(0);
  transition: transform 0.2s ease;
}

.doc-card:hover {
  transform: translateY(-2px);
  background-color: rgba(255, 255, 255, 0.06);
  border-color: var(--card-hover-border);
  box-shadow: var(--shadow-sm);
}

.doc-card.active {
  background-color: rgba(61, 142, 248, 0.06);
  border-color: var(--accent-color);
}

.doc-card.active::after {
  transform: scaleY(1);
}

.doc-icon-wrap {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.doc-icon-wrap.pdf {
  background-color: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.doc-icon-wrap.image {
  background-color: rgba(16, 185, 129, 0.1);
  color: #10b981;
}

.doc-info {
  flex: 1;
  min-width: 0;
}

.doc-title {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.doc-meta {
  font-size: 11px;
  color: var(--text-muted);
}

/* Viewer Panel */
.viewer-panel {
  flex: 1;
  background-color: var(--bg-primary);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

/* Default Placeholder */
.viewer-placeholder {
  text-align: center;
  max-width: 420px;
  padding: 24px;
}

.placeholder-icon-wrap {
  width: 80px;
  height: 80px;
  background-color: var(--bg-secondary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  border: 1px solid var(--card-border);
}

.placeholder-icon {
  font-size: 32px;
  color: var(--text-muted);
}

.viewer-placeholder h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
}

.viewer-placeholder p {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
}

/* Iframe and Image Layout */
.document-frame {
  width: 100%;
  height: 100%;
  border: none;
  background-color: var(--bg-primary);
}

.image-viewer-container {
  width: 100%;
  height: 100%;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

#image-viewer {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--card-border);
}

/* Loader */
.viewer-loader {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  z-index: 5;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(61, 142, 248, 0.1);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.viewer-loader p {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Error banner */
.error-banner {
  background-color: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  padding: 16px;
  border-radius: var(--border-radius);
  text-align: center;
  max-width: 400px;
}

.error-banner i {
  color: #ef4444;
  font-size: 24px;
  margin-bottom: 10px;
}

.error-banner p {
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.retry-btn {
  background-color: #ef4444;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

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

/* Keyframe animations */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes skeleton-pulse {
  0% { background-color: rgba(255, 255, 255, 0.02); }
  50% { background-color: rgba(255, 255, 255, 0.06); }
  100% { background-color: rgba(255, 255, 255, 0.02); }
}

/* Skeletons */
.skeleton-card {
  height: 68px;
  border-radius: var(--border-radius);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

/* Mobile Close Button */
.viewer-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--card-border);
  color: white;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100;
  transition: background-color 0.2s ease;
}

.viewer-close-btn:hover {
  background-color: rgba(0, 0, 0, 0.8);
}

/* Empty State Search */
.empty-state {
  text-align: center;
  padding: 30px 10px;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 28px;
  margin-bottom: 10px;
}

.empty-state p {
  font-size: 13px;
}

/* Responsive Styles (Tablet & Mobile) */
@media (max-width: 768px) {
  body {
    overflow: auto;
  }
  
  .app-header {
    flex-direction: column;
    height: auto;
    padding: 16px;
    gap: 12px;
  }
  
  .search-container {
    width: 100%;
  }
  
  .app-container {
    flex-direction: column;
    height: auto;
  }
  
  .app-sidebar {
    width: 100%;
    border-right: none;
    height: auto;
  }
  
  .categories-nav {
    flex-direction: row;
    overflow-x: auto;
    padding: 12px 16px;
    gap: 8px;
    border-bottom: 1px solid var(--card-border);
    -webkit-overflow-scrolling: touch;
  }
  
  .categories-nav::-webkit-scrollbar {
    display: none; /* Hide scrollbar for Chrome/Safari */
  }
  
  .category-btn {
    width: auto;
    white-space: nowrap;
    padding: 8px 16px;
  }
  
  .documents-list-container {
    max-height: 400px;
  }
  
  /* Viewer Panel as a full-screen Modal on Mobile */
  .viewer-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 200;
    background-color: var(--bg-primary);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  .viewer-panel.active {
    transform: translateY(0);
  }
}
