/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #4f46e5;
  --primary-hover: #4338ca;
  --secondary-color: #6b7280;
  --success-color: #10b981;
  --error-color: #ef4444;
  --warning-color: #f59e0b;
  --background-color: #f9fafb;
  --sidebar-bg: #1f2937;
  --sidebar-text: #f3f4f6;
  --card-bg: #ffffff;
  --border-color: #e5e7eb;
  --text-primary: #111827;
  --text-secondary: #6b7280;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background-color: var(--background-color);
  color: var(--text-primary);
  overflow: hidden;
}

/* Allow scrolling on mobile when sidebar is closed */
@media (max-width: 768px) {
  body {
    overflow-y: auto;
    overflow-x: hidden;
  }
}

/* Screen management */
.screen {
  display: none;
  width: 100vw;
  height: 100vh;
}

.screen.active {
  display: flex;
}

/* Login Screen */
#login-screen {
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  overflow-y: auto;
  padding: 1rem;
}

@media (min-width: 769px) {
  #login-screen {
    overflow-y: hidden;
    padding: 0;
  }
}

.login-container {
  background: var(--card-bg);
  padding: 3rem;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 400px;
}

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

.logo h1 {
  font-size: 2.5rem;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.logo p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.error-message {
  color: var(--error-color);
  font-size: 0.875rem;
  min-height: 1.25rem;
}

/* Buttons */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: var(--secondary-color);
  color: white;
}

.btn-secondary:hover:not(:disabled) {
  background-color: #4b5563;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--sidebar-text);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.btn-icon:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Main Screen Layout */
#main-screen {
  flex-direction: row;
}

@media (max-width: 768px) {
  #main-screen {
    flex-direction: column;
    width: 100%;
    height: 100vh;
    overflow: hidden;
  }
}

/* Sidebar */
.sidebar {
  width: 250px;
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 1rem;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 1rem;
}

.sidebar-header h2 {
  font-size: 1.5rem;
  color: var(--primary-color);
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: none;
  border: none;
  color: var(--sidebar-text);
  font-size: 1rem;
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
  transition: background-color 0.2s;
}

.nav-item:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.nav-item.active {
  background-color: var(--primary-color);
}

.nav-icon {
  font-size: 1.25rem;
}

.sidebar-footer {
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.875rem;
}

.user-info {
  margin-bottom: 0.5rem;
}

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

/* Main Content */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.tab-content {
  display: none;
}

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

.tab-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.tab-header h2 {
  font-size: 1.5rem;
}

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

/* Sync Tab */
.sync-area {
  min-height: 300px;
  margin-bottom: 1.5rem;
}

.file-queue {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 1rem;
  min-height: 200px;
}

.empty-state {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  min-height: 150px;
  color: var(--text-secondary);
}

.loading-state {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  min-height: 150px;
  color: var(--text-secondary);
}

.file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.file-item:last-child {
  border-bottom: none;
}

.file-item-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
}

.file-icon {
  font-size: 1.5rem;
}

.file-name {
  font-weight: 500;
}

.file-size {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.file-status {
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
}

.file-status.pending {
  background-color: #fef3c7;
  color: #92400e;
}

.file-status.syncing {
  background-color: #dbeafe;
  color: #1e40af;
}

.file-status.completed {
  background-color: #d1fae5;
  color: #065f46;
}

.file-status.error {
  background-color: #fee2e2;
  color: #991b1b;
}

.file-remove-btn {
  background: none;
  border: none;
  color: var(--error-color);
  cursor: pointer;
  font-size: 1.25rem;
  padding: 0.25rem;
}

.clear-queue-container {
  display: flex;
  justify-content: flex-end;
  padding-top: 0.5rem;
}

.btn-clear {
  background: none;
  border: 1px solid var(--error-color);
  color: var(--error-color);
  cursor: pointer;
  font-size: 0.875rem;
  padding: 0.375rem 0.75rem;
  border-radius: 4px;
  transition: all 0.2s;
}

.btn-clear:hover {
  background-color: var(--error-color);
  color: white;
}

/* Sync Progress */
.sync-progress {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 1rem;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

.progress-bar {
  height: 8px;
  background-color: var(--border-color);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.progress-fill {
  height: 100%;
  background-color: var(--primary-color);
  width: 0%;
  transition: width 0.3s;
}

/* Thumbnail loading placeholder */
.thumbnail-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: var(--card-bg);
  position: relative;
  overflow: hidden;
}

.thumbnail-placeholder::after {
  content: '';
  width: 28px;
  height: 28px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.thumbnail-placeholder img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.thumbnail-placeholder.loaded img {
  opacity: 1;
}

.thumbnail-placeholder.loaded::after {
  display: none;
}

/* Library Grid */
.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.library-item {
  background: var(--card-bg);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.library-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.library-item-thumbnail {
  width: 100%;
  height: 150px;
  object-fit: cover;
  background-color: var(--border-color);
}

.library-item-info {
  padding: 0.75rem;
}

.library-item-name {
  font-weight: 500;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.25rem;
}

.library-item-meta {
  color: var(--text-secondary);
  font-size: 0.75rem;
}

.device-badge {
  display: inline-block;
  background-color: #ede9fe;
  color: #5b21b6;
  padding: 0.125rem 0.5rem;
  border-radius: 8px;
  font-size: 0.7rem;
  font-weight: 500;
  margin-top: 0.25rem;
}

/* Library Grid - Gallery Mode (images only, compact grid) */
.library-grid.gallery-view-mode {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.library-grid.gallery-view-mode .library-item {
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  background: var(--card-bg);
}

.library-grid.gallery-view-mode .library-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.library-grid.gallery-view-mode .library-item:hover img {
  transform: scale(1.05);
}

/* Library Grid - List Mode (all files with details) */
.library-grid.library-list-mode {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.library-grid.library-list-mode .library-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  border-radius: 8px;
  background: var(--card-bg);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.library-grid.library-list-mode .library-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Thumbnail wrapper for list mode — keeps spinner in fixed size */
.library-grid.library-list-mode .thumbnail-placeholder {
  width: 64px;
  height: 64px;
  border-radius: 6px;
  flex-shrink: 0;
}

.library-grid.library-list-mode .thumbnail-placeholder img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
}

.library-grid.library-list-mode .library-item-info {
  flex: 1;
  min-width: 0;
}

.library-grid.library-list-mode .library-item-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.25rem;
}

.library-grid.library-list-mode .library-item-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Settings */
.settings-content {
  max-width: 600px;
}

.settings-section {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.settings-section h3 {
  margin-bottom: 1rem;
  font-size: 1.125rem;
}

.settings-section p {
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

#device-history-list div {
  transition: background-color 0.15s ease;
}

#device-history-list div:hover {
  background-color: rgba(255, 255, 255, 0.03);
  border-radius: 4px;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

/* Search and Filter */
.search-input {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.875rem;
  width: 200px;
}

.filter-select {
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.875rem;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0;
}

#page-info {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--card-bg);
  border-radius: 12px;
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
  position: relative;
  padding: 2rem;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
}

.preview-container {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}

.preview-container img {
  max-width: 100%;
  max-height: 60vh;
  object-fit: contain;
}

.preview-info {
  text-align: center;
}

.preview-info h3 {
  margin-bottom: 0.5rem;
}

.preview-info p {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    width: 200px;
  }
  
  .library-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

/* ============================================================
   Admin Panel Styles
   ============================================================ */

.admin-panel {
  width: 100%;
}

.admin-login-box {
  max-width: 450px;
  margin: 2rem auto;
  background: var(--card-bg);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.admin-login-box h3 {
  margin-bottom: 0.5rem;
  font-size: 1.25rem;
}

.admin-form .form-group {
  margin-bottom: 1rem;
}

.admin-toolbar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  align-items: center;
}

.users-table-container {
  background: var(--card-bg);
  border-radius: 8px;
  overflow-x: auto;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.users-table {
  width: 100%;
  border-collapse: collapse;
}

.users-table thead {
  background-color: var(--background-color);
}

.users-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border-color);
}

.users-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.875rem;
}

.users-table tbody tr:hover {
  background-color: rgba(79, 70, 229, 0.04);
}

.loading-cell,
.empty-cell {
  text-align: center !important;
  padding: 2rem !important;
  color: var(--text-secondary);
}

.actions-cell {
  white-space: nowrap;
}

.role-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.role-badge.admin {
  background-color: #ede9fe;
  color: #5b21b6;
}

.status-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-badge.active {
  background-color: #d1fae5;
  color: #065f46;
}

.status-badge.inactive {
  background-color: #fee2e2;
  color: #991b1b;
}

.btn-small {
  padding: 0.375rem 0.75rem;
  font-size: 0.8rem;
}

.btn-danger {
  background-color: var(--error-color);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background-color: #dc2626;
}

.modal-small {
  max-width: 450px;
}

/* Close modal when clicking outside */
.modal .modal-content {
  margin: auto;
  max-height: 90vh;
  overflow-y: auto;
}

/* ============================================================
   Sync Logs Styles
   ============================================================ */

.sync-logs-section {
  margin-top: 1.5rem;
}

.sync-logs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.sync-logs-header h3 {
  font-size: 1.125rem;
  color: var(--text-primary);
}

.sync-logs-table {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 0.75rem;
  max-height: 400px;
  overflow-y: auto;
}

.sync-log-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.15s;
}

.sync-log-item:last-child {
  border-bottom: none;
}

.sync-log-item:hover {
  background-color: rgba(79, 70, 229, 0.03);
}

.sync-log-info {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex: 1;
  min-width: 0;
}

.log-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.log-details {
  min-width: 0;
}

.log-filename {
  font-weight: 500;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.log-meta {
  color: var(--text-secondary);
  font-size: 0.75rem;
  margin-top: 0.125rem;
}

.sync-log-device {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.125rem;
  flex-shrink: 0;
  margin-left: 1rem;
}

.log-device {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.log-ip {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  opacity: 0.7;
  white-space: nowrap;
}

/* ============================================================
   MOBILE RESPONSIVE STYLES
   ============================================================ */

/* Mobile-first approach: Base styles are desktop, overrides for mobile */

/* Tablet and below (768px) */
@media (max-width: 768px) {
  /* Hide sidebar and show hamburger menu */
  #main-screen {
    flex-direction: column;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100vh;
    z-index: 1000;
    transition: left 0.3s ease;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
  }

  .sidebar.open {
    left: 0;
  }

  /* Add hamburger menu button */
  .mobile-menu-toggle {
    display: flex !important;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 999;
    background: var(--sidebar-bg);
    color: white;
    border: none;
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  }

  /* Overlay when sidebar is open */
  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
  }

  .sidebar-overlay.active {
    display: block;
  }

  /* Adjust main content for mobile */
  .main-content {
    padding: 1rem;
    padding-top: 4rem; /* Space for header */
    width: 100%;
  }

  /* Stack tab header elements */
  .tab-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .header-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .header-actions .btn,
  .header-actions .search-input,
  .header-actions .filter-select {
    flex: 1;
    min-width: 0;
  }

  /* Adjust login screen */
  .login-container {
    padding: 2rem 1.5rem;
    margin: 1rem;
    max-width: none;
  }

  .logo h1 {
    font-size: 2rem;
  }

  /* Library grid - fewer columns */
  .library-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
  }

  /* Gallery mode - smaller tiles */
  .library-grid.gallery-view-mode {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.5rem;
  }

  /* Settings content full width */
  .settings-content {
    max-width: none;
  }

  /* Admin table responsive */
  .users-table-container {
    font-size: 0.875rem;
  }

  .users-table th,
  .users-table td {
    padding: 0.5rem;
  }

  /* Modal adjustments */
  .modal-content {
    padding: 1.5rem;
    margin: 1rem;
    max-width: 95vw;
  }

  /* Sync progress full width */
  .sync-progress {
    flex-direction: column;
    gap: 0.75rem;
  }

  .progress-info {
    width: 100%;
  }

  #start-sync-btn {
    width: 100%;
  }
}

/* Mobile phones (480px) */
@media (max-width: 480px) {
  /* Smaller grids for mobile */
  .library-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  .library-grid.gallery-view-mode {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.25rem;
  }

  /* Stack buttons vertically */
  .header-actions {
    flex-direction: column;
  }

  .header-actions .btn,
  .header-actions .search-input,
  .header-actions .filter-select {
    width: 100%;
  }

  /* Reduce padding throughout */
  .main-content {
    padding: 0.75rem;
    padding-top: 3.5rem;
  }

  .tab-header h2 {
    font-size: 1.25rem;
  }

  /* Smaller file items */
  .file-item {
    padding: 0.5rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .file-status {
    align-self: flex-start;
  }

  /* Admin login box */
  .admin-login-box {
    padding: 1.5rem 1rem;
    margin: 1rem;
  }

  /* Pagination compact */
  .pagination {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  #page-info {
    order: -1;
    width: 100%;
    text-align: center;
  }

  /* Sync logs compact */
  .sync-log-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .sync-log-device {
    align-items: flex-start;
    margin-left: 0;
  }

  /* Admin toolbar stack */
  .admin-toolbar {
    flex-direction: column;
  }

  .admin-toolbar .search-input,
  .admin-toolbar .filter-select {
    width: 100%;
  }
}

/* Desktop-only: hide mobile elements */
@media (min-width: 769px) {
  .mobile-menu-toggle {
    display: none !important;
  }
}

/* Landscape phones - prevent too narrow */
@media (max-height: 500px) and (orientation: landscape) {
  .login-container {
    max-width: 500px;
  }

  .screen.active {
    align-items: flex-start;
    padding: 2rem;
  }

  .main-content {
    padding-top: 3rem;
  }
}

/* Print styles */
@media print {
  .sidebar,
  .sync-progress,
  .header-actions,
  .modal {
    display: none !important;
  }

  .main-content {
    padding: 0;
  }
}

/* High DPI / Retina displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .library-item-thumbnail,
  .library-grid.gallery-view-mode img {
    image-rendering: -webkit-optimize-contrast;
  }
}

/* Dark mode support (optional enhancement) */
@media (prefers-color-scheme: dark) {
  /* Can add dark mode variables here if needed */
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .btn,
  .library-item,
  .nav-item {
    transition: none;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets */
  .btn {
    min-height: 44px;
    min-width: 44px;
  }

  .nav-item {
    min-height: 48px;
  }

  .form-group input,
  .search-input,
  .filter-select {
    font-size: 16px; /* Prevents zoom on iOS */
  }

  /* Remove hover effects on touch devices */
  .library-item:hover {
    transform: none;
  }
}
