/* ===== CSS Variables ===== */
:root {
  --primary-color: #f6821f;
  --primary-hover: #e57316;
  --secondary-color: #404040;
  --secondary-hover: #333333;
  --danger-color: #dc3545;
  --danger-hover: #c82333;
  --success-color: #28a745;
  --warning-color: #ffc107;
  --info-color: #17a2b8;
  
  --bg-color: #f5f5f5;
  --card-bg: #ffffff;
  --border-color: #e0e0e0;
  --text-color: #333333;
  --text-muted: #666666;
  --text-light: #999999;
  
  --header-height: 60px;
  --sidebar-width: 250px;
  --border-radius: 8px;
  --box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --transition: all 0.2s ease;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

/* ===== Screen Management ===== */
.screen {
  display: none !important;
  min-height: 100vh;
}

.screen.active {
  display: block !important;
}

/* ===== Login Screen ===== */
#login-screen {
  align-items: center;
  justify-content: center;
  background-color: var(--bg-color);
}

#login-screen.active {
  display: flex !important;
}

.login-container {
  background: var(--card-bg);
  padding: 40px;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  width: 100%;
  max-width: 400px;
}

.login-header {
  text-align: center;
  margin-bottom: 30px;
}

.login-header i {
  font-size: 48px;
  color: var(--primary-color);
  margin-bottom: 15px;
}

.login-header h1 {
  font-size: 24px;
  margin-bottom: 5px;
}

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

/* ===== Form Styles ===== */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: var(--text-color);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 14px;
  transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(246, 130, 31, 0.1);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--border-radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.6;
  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: var(--secondary-hover);
}

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

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

.btn-icon {
  padding: 8px;
  background: transparent;
  color: var(--text-color);
  border: 1px solid var(--border-color);
}

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

.btn-full {
  width: 100%;
}

.btn-small {
  padding: 6px 12px;
  font-size: 13px;
}

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

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

.header-left i {
  font-size: 28px;
  color: var(--primary-color);
}

.header-left h1 {
  font-size: 20px;
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 15px;
}

.username {
  font-weight: 500;
  color: var(--text-muted);
}

.permissions-badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.permissions-badge.read-only {
  background-color: #e3f2fd;
  color: #1976d2;
}

.permissions-badge.read-write {
  background-color: #e8f5e9;
  color: #388e3c;
}

/* ===== Admin Dashboard ===== */
.admin-main {
  padding: 30px;
  max-width: 1200px;
  margin: 0 auto;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.admin-header h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
}

.users-table-container {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  overflow: hidden;
}

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

.users-table th,
.users-table td {
  padding: 15px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.users-table th {
  background-color: var(--bg-color);
  font-weight: 600;
  color: var(--text-color);
}

.users-table tr:last-child td {
  border-bottom: none;
}

.users-table tr:hover td {
  background-color: var(--bg-color);
}

.user-actions {
  display: flex;
  gap: 8px;
}

/* ===== File Manager ===== */
.file-manager {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-height));
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 20px;
  background-color: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-left: 10px;
}

.breadcrumb-item {
  padding: 5px 10px;
  background-color: var(--bg-color);
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 14px;
  transition: var(--transition);
}

.breadcrumb-item:hover {
  background-color: var(--border-color);
}

.breadcrumb-separator {
  color: var(--text-muted);
}

/* File List */
.file-list-container {
  flex: 1;
  overflow: auto;
  position: relative;
  background-color: var(--card-bg);
  margin: 20px;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
}

.file-list-header {
  display: flex;
  padding: 12px 20px;
  background-color: var(--bg-color);
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  font-size: 13px;
  color: var(--text-muted);
  position: sticky;
  top: 0;
  z-index: 10;
}

.file-list {
  min-height: 200px;
}

.file-col {
  padding: 0 10px;
}

.file-name {
  flex: 1;
  min-width: 200px;
}

.file-size {
  width: 100px;
  text-align: right;
}

.file-date {
  width: 180px;
}

.file-actions {
  width: 150px;
  text-align: right;
}

/* File Item */
.file-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition);
}

.file-item:hover {
  background-color: var(--bg-color);
}

.file-item.selected {
  background-color: rgba(246, 130, 31, 0.1);
}

.file-item .file-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  border-radius: var(--border-radius);
  background-color: var(--bg-color);
}

.file-item .file-icon i {
  font-size: 18px;
}

.file-item .file-icon.folder {
  color: #ffc107;
}

.file-item .file-icon.image {
  color: #e91e63;
}

.file-item .file-icon.video {
  color: #9c27b0;
}

.file-item .file-icon.audio {
  color: #00bcd4;
}

.file-item .file-icon.pdf {
  color: #f44336;
}

.file-item .file-icon.document {
  color: #2196f3;
}

.file-item .file-icon.spreadsheet {
  color: #4caf50;
}

.file-item .file-icon.code {
  color: #ff9800;
}

.file-item .file-icon.text {
  color: #607d8b;
}

.file-item .file-icon.archive {
  color: #795548;
}

.file-item .file-icon.file {
  color: #9e9e9e;
}

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

.file-info .name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-info .meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.file-item .file-size {
  color: var(--text-muted);
  font-size: 13px;
}

.file-item .file-date {
  color: var(--text-muted);
  font-size: 13px;
}

.file-item .file-actions {
  display: flex;
  gap: 5px;
  justify-content: flex-end;
}

.file-item .file-actions .btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
}

/* Loading Overlay */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: rgba(255, 255, 255, 0.9);
  z-index: 100;
}

.loading-overlay.hidden {
  display: none;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 64px;
  margin-bottom: 15px;
  opacity: 0.5;
}

/* Upload Progress */
.upload-progress {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 350px;
  background: var(--card-bg);
  border-radius: var(--border-radius);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  z-index: 1000;
}

.upload-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 15px;
  border-bottom: 1px solid var(--border-color);
}

.upload-header h4 {
  font-size: 14px;
}

.upload-list {
  max-height: 300px;
  overflow-y: auto;
}

.upload-item {
  padding: 12px 15px;
  border-bottom: 1px solid var(--border-color);
}

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

.upload-item .upload-name {
  font-size: 13px;
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-item .upload-bar {
  height: 4px;
  background-color: var(--border-color);
  border-radius: 2px;
  overflow: hidden;
}

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

.upload-item .upload-bar .progress.complete {
  background-color: var(--success-color);
}

.upload-item .upload-bar .progress.error {
  background-color: var(--danger-color);
}

.upload-item .upload-status {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 5px;
}

/* ===== Modal ===== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 450px;
  max-height: 90vh;
  overflow: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
}

.modal-close:hover {
  color: var(--text-color);
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 15px 20px;
  border-top: 1px solid var(--border-color);
}

/* Preview Modal */
.preview-modal .modal-content {
  max-width: 90vw;
  max-height: 90vh;
}

.preview-modal .modal-header {
  display: flex;
  align-items: center;
  gap: 15px;
}

.preview-modal .modal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.preview-body {
  padding: 20px;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-color);
}

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

.preview-body video,
.preview-body audio {
  max-width: 100%;
  max-height: 70vh;
}

.preview-body iframe {
  width: 100%;
  height: 70vh;
  border: none;
}

.preview-body pre {
  width: 100%;
  max-height: 70vh;
  overflow: auto;
  padding: 20px;
  background-color: #1e1e1e;
  color: #d4d4d4;
  border-radius: var(--border-radius);
  font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
}

.preview-unsupported {
  text-align: center;
  color: var(--text-muted);
}

.preview-unsupported i {
  font-size: 64px;
  margin-bottom: 15px;
  opacity: 0.5;
}

/* ===== Toast Notifications ===== */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--card-bg);
  border-radius: var(--border-radius);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  min-width: 280px;
  max-width: 400px;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast.toast-exit {
  animation: slideOut 0.3s ease forwards;
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

.toast-icon {
  font-size: 20px;
}

.toast.success .toast-icon {
  color: var(--success-color);
}

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

.toast.warning .toast-icon {
  color: var(--warning-color);
}

.toast.info .toast-icon {
  color: var(--info-color);
}

.toast-message {
  flex: 1;
  font-size: 14px;
}

/* ===== Error Message ===== */
.error-message {
  color: var(--danger-color);
  font-size: 14px;
  margin-top: 15px;
  text-align: center;
}

.text-muted {
  color: var(--text-muted);
  font-size: 13px;
}

/* ===== Drag & Drop ===== */
.file-list-container.drag-over {
  border: 2px dashed var(--primary-color);
  background-color: rgba(246, 130, 31, 0.05);
}

.drop-zone-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: rgba(246, 130, 31, 0.1);
  pointer-events: none;
  z-index: 50;
}

.drop-zone-overlay i {
  font-size: 64px;
  color: var(--primary-color);
  margin-bottom: 15px;
}

.drop-zone-overlay p {
  font-size: 18px;
  color: var(--primary-color);
  font-weight: 500;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .header {
    padding: 0 15px;
  }

  .header-left h1 {
    font-size: 16px;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .toolbar-left,
  .toolbar-right {
    justify-content: center;
  }

  .breadcrumb {
    margin-left: 0;
    margin-top: 10px;
    flex-wrap: wrap;
  }

  .file-list-container {
    margin: 10px;
  }

  .file-col.file-date {
    display: none;
  }

  .file-item .file-actions {
    position: absolute;
    right: 10px;
  }

  .admin-main {
    padding: 15px;
  }

  .users-table {
    font-size: 13px;
  }

  .users-table th,
  .users-table td {
    padding: 10px;
  }

  .modal-content {
    margin: 10px;
    max-width: calc(100% - 20px);
  }

  .upload-progress {
    width: calc(100% - 40px);
    left: 20px;
    right: 20px;
  }
}
