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

:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --secondary: #64748b;
  --secondary-hover: #475569;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #10b981;
  --background: #f8fafc;
  --surface: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--background);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
  padding: 2rem;
  width: 100%;
  max-width: 400px;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem;
}

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

.login-header h1 {
  font-size: 1.75rem;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.login-header p {
  color: var(--text-muted);
}

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

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

.form-group label {
  font-weight: 500;
  font-size: 0.875rem;
}

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

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

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

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

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

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

.btn-outline {
  background-color: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}

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

.btn-logout {
  background-color: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-logout:hover {
  background-color: var(--border);
  color: var(--text);
}

.btn-small {
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  white-space: nowrap;
  min-height: 2.25rem;
}

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

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

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

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

.error-message {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background-color: #fee2e2;
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  text-align: center;
  display: none;
}

.error-message.show {
  display: block;
}

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  box-shadow: var(--shadow);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-brand h1 {
  font-size: 1.25rem;
  font-weight: 600;
}

.back-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.2s;
}

.back-link:hover {
  color: var(--primary);
}

.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

.page-header {
  margin-bottom: 2rem;
}

.page-header h2 {
  font-size: 1.875rem;
  margin-bottom: 0.5rem;
}

.page-header p {
  color: var(--text-muted);
}

.folders-container {
  width: 100%;
}

.folders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}

.folder-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.folder-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.folder-icon {
  color: var(--primary);
  margin-bottom: 1rem;
}

.folder-info {
  margin-bottom: 1.5rem;
}

.folder-info h3 {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}

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

.folder-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}

.folder-actions .btn {
  width: 100%;
}

.folder-actions-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 2rem;
}

.folder-content {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

@media (min-width: 768px) {
  .folder-content {
    grid-template-columns: 350px 1fr;
  }
}

.upload-section,
.files-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.upload-section h3,
.files-section h3 {
  font-size: 1.125rem;
  margin-bottom: 1rem;
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.drop-zone:hover {
  border-color: var(--primary);
  background-color: #f8fafc;
}

.drop-zone.drag-over {
  border-color: var(--primary);
  background-color: #eef2ff;
}

.drop-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.drop-zone-content svg {
  color: var(--text-muted);
}

.drop-zone-content p {
  color: var(--text-muted);
}

.upload-progress {
  margin-top: 1rem;
}

.upload-progress.hidden {
  display: none;
}

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

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

.upload-status {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.files-container {
  width: 100%;
}

.files-grid-content {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.file-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.file-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.file-thumbnail {
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  background-color: var(--background);
}

.file-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.file-info {
  padding: 0.75rem;
}

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

.file-size {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.file-actions {
  display: flex;
  border-top: 1px solid var(--border);
}

.file-actions .btn {
  flex: 1;
  border-radius: 0;
  justify-content: center;
}

.file-actions .btn:first-child {
  border-right: 1px solid var(--border);
}

.loading,
.error,
.empty-state {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
}

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

@media (max-width: 640px) {
  .navbar {
    padding: 1rem;
  }

  .main-content {
    padding: 1rem;
  }

  .folders-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }

  .folder-content {
    grid-template-columns: 1fr;
  }
}

.files-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.files-header h3 {
  font-size: 1.125rem;
  margin-bottom: 0;
}

.bulk-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.bulk-actions .btn {
  font-size: 0.8125rem;
  padding: 0.5rem 0.875rem;
  white-space: nowrap;
  min-height: 2.25rem;
}

.bulk-actions .btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.file-card {
  position: relative;
}

.file-checkbox-wrapper {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 10;
}

.file-checkbox {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--primary);
}

.file-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.3);
}

.file-card.selected .file-thumbnail {
  opacity: 0.8;
}

.file-card.selected .file-thumbnail::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(79, 70, 229, 0.1);
  pointer-events: none;
}

@media (max-width: 640px) {
  .files-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .bulk-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .bulk-actions .btn {
    width: 100%;
    min-width: 0;
  }
}

.video-thumbnail {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background-color: var(--background);
  color: var(--text-muted);
  overflow: hidden;
}

.video-thumbnail svg {
  margin-bottom: 0.5rem;
}

.video-thumbnail span {
  font-size: 0.75rem;
  font-weight: 500;
}

.video-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 50%, rgba(0, 0, 0, 0.25) 100%);
  transition: background 0.2s ease;
}

.video-play-overlay svg {
  width: 36px;
  height: 36px;
  margin: 0;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
  opacity: 0.95;
  transition: transform 0.2s ease;
}

.file-card:hover .video-play-overlay svg {
  transform: scale(1.1);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  padding: 1rem;
  height: 100vh;
  height: 100dvh;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal:not(.hidden) {
  opacity: 1;
  visibility: visible;
}

.modal.hidden {
  display: flex;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-content {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: min(92vw, 1300px);
  max-height: 95vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 50px -20px rgba(15, 23, 42, 0.4),
              0 0 0 1px rgba(15, 23, 42, 0.05);
  animation: modalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-close-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.modal-close-btn:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
  transform: scale(1.05);
}

.modal-close-btn:active {
  transform: scale(0.95);
}

.modal-close-btn svg {
  width: 18px;
  height: 18px;
}

.modal-body {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 0;
  padding: 1.5rem;
  background: #f8fafc;
  overflow: hidden;
}

.modal-media {
  max-width: 100%;
  max-height: 82vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  display: block;
}

.modal-media.hidden {
  display: none;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 1.25rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.modal-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  margin: 0;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-footer .btn {
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  flex-shrink: 0;
}

.modal-footer .btn svg {
  width: 16px;
  height: 16px;
}

@media (max-width: 640px) {
  .modal {
    padding: 0.5rem;
  }

  .modal-content {
    max-width: 100%;
    max-height: 100%;
  }

  .modal-body {
    padding: 1rem;
  }

  .modal-media {
    max-height: 72vh;
  }

  .modal-footer {
    padding: 0.75rem 1rem;
  }

  .modal-close-btn {
    top: 0.5rem;
    right: 0.5rem;
    width: 1.875rem;
    height: 1.875rem;
  }

  .modal-close-btn svg {
    width: 16px;
    height: 16px;
  }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
  .btn {
    min-height: 44px;
    min-width: 44px;
  }

  .folder-card:hover {
    transform: none;
    box-shadow: var(--shadow);
  }

  .file-card:hover {
    transform: none;
    box-shadow: var(--shadow);
  }
}

/* Tablet and mobile responsive styles */
@media (max-width: 768px) {
  .login-container {
    padding: 1rem;
  }

  .login-card {
    padding: 1.5rem;
  }

  .navbar {
    flex-direction: column;
    gap: 0.75rem;
    align-items: stretch;
  }

  .nav-brand {
    width: 100%;
    justify-content: space-between;
  }

  .nav-brand h1 {
    font-size: 1rem;
  }

  .folder-actions-bar {
    flex-direction: column;
    gap: 0.5rem;
  }

  .folder-actions-bar .btn {
    width: 100%;
  }
}

/* Mobile responsive styles */
@media (max-width: 640px) {
  :root {
    --radius: 8px;
    --radius-sm: 6px;
  }

  body {
    font-size: 14px;
  }

  .login-page {
    padding: 1rem;
  }

  .login-card {
    padding: 1.25rem;
  }

  .login-header h1 {
    font-size: 1.25rem;
  }

  .login-header p {
    font-size: 0.875rem;
  }

  .btn {
    padding: 0.625rem 1.25rem;
    font-size: 1rem;
    min-height: 44px;
  }

  .btn svg {
    width: 18px;
    height: 18px;
  }

  .page-header {
    text-align: center;
  }

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

  .folder-card {
    padding: 1rem 0.75rem;
  }

  .folder-icon {
    margin-bottom: 0.5rem;
  }

  .folder-icon svg {
    width: 40px;
    height: 40px;
  }

  .folder-info {
    margin-bottom: 0.875rem;
  }

  .folder-info h3 {
    font-size: 1rem;
    margin-bottom: 0.125rem;
  }

  .file-count {
    font-size: 0.75rem;
  }

  .folder-actions {
    gap: 0.4rem;
  }

  .folder-card .btn {
    padding: 0.55rem 0.5rem;
    font-size: 0.8125rem;
  }

  .upload-section h3,
  .files-section h3 {
    font-size: 1rem;
  }

  .drop-zone {
    padding: 2rem 1rem;
  }

  .drop-zone-content svg {
    width: 36px;
    height: 36px;
  }

  .drop-zone-content p {
    font-size: 0.875rem;
  }

  .drop-zone-content .btn {
    margin-top: 0.75rem;
  }

  .files-grid-content {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
  }

  .file-checkbox-wrapper {
    top: 0.375rem;
    left: 0.375rem;
  }

  .file-checkbox {
    width: 22px;
    height: 22px;
  }

  .file-info {
    padding: 0.5rem;
  }

  .file-name {
    font-size: 0.875rem;
  }

  .file-size {
    font-size: 0.75rem;
  }

  .file-actions .btn {
    padding: 0.5rem;
    min-height: 40px;
  }

  .file-actions .btn svg {
    width: 16px;
    height: 16px;
  }

  .empty-state,
  .error,
  .loading {
    padding: 1.5rem;
    font-size: 0.875rem;
  }

  .bulk-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .bulk-actions .btn {
    font-size: 0.8125rem;
    padding: 0.6rem 0.5rem;
    min-width: 0;
    width: 100%;
  }

  .bulk-actions .btn svg {
    width: 14px;
    height: 14px;
  }
}

/* Small mobile phones */
@media (max-width: 375px) {
  .folders-grid-content {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }

  .files-grid-content {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }

  .drop-zone {
    padding: 1.5rem 0.75rem;
  }

  .drop-zone-content svg {
    width: 32px;
    height: 32px;
  }
}

/* Large mobile screens */
@media (min-width: 641px) and (max-width: 768px) {
  .files-grid-content {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
  .modal-media {
    max-height: 78vh;
  }

  .modal-body {
    padding: 0.75rem;
  }
}

#modalVideo:focus {
  outline: none;
}

/* Confirmation dialog */
.modal-confirm-content {
  max-width: 400px;
  width: 100%;
}

.modal-confirm-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1.75rem 1.5rem 1.25rem;
  gap: 0.75rem;
}

.modal-confirm-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background: #fee2e2;
  color: var(--danger);
  margin-bottom: 0.25rem;
}

.modal-confirm-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.modal-confirm-message {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.4;
}

.modal-confirm-actions {
  display: flex;
  gap: 0.625rem;
  padding: 1rem 1.5rem 1.5rem;
}

.modal-confirm-actions .btn {
  flex: 1;
  font-size: 0.875rem;
  padding: 0.625rem 1rem;
}

.modal-confirm-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.modal-confirm-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  transition: border-color 0.15s ease;
}

.modal-confirm-input:focus {
  outline: none;
  border-color: var(--primary);
}

.modal-confirm-input.error {
  border-color: var(--danger);
}

.modal-confirm-error {
  font-size: 0.8125rem;
  color: var(--danger);
  margin: 0;
  text-align: left;
}

@media (max-width: 480px) {
  .modal-confirm-content {
    max-width: 100%;
  }

  .modal-confirm-body {
    padding: 1.5rem 1.25rem 1rem;
  }

  .modal-confirm-actions {
    padding: 0.75rem 1.25rem 1.25rem;
  }
}

.modal-body.loading::before {
  content: '';
  position: absolute;
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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