/* Zenome File Sharing System - Apple-style CSS */

:root {
  --primary: #007AFF;
  --primary-dark: #0056CC;
  --text: #1D1D1F;
  --text-light: #6E6E73;
  --background: #FFFFFF;
  --surface: #F2F2F7;
  --border: #D2D2D7;
  --error: #FF3B30;
  --success: #30D158;
  --warning: #FF9500;
  
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.12);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', sans-serif;
  line-height: 1.5;
  color: var(--text);
  background: var(--surface);
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 30px 20px 40px 20px;
}

.card {
  background: var(--background);
  border-radius: var(--radius);
  padding: 30px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.card-header {
  margin-bottom: 30px;
}

.card-title {
  font-size: 28px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.card-subtitle {
  font-size: 17px;
  color: var(--text-light);
  font-weight: 400;
}

/* Forms */
.form-group {
  margin-bottom: 24px;
}

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

.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 17px;
  background: var(--background);
  transition: all 0.2s ease;
}

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 17px;
  font-weight: 500;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 120px;
  height: 44px;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--background);
  transform: translateY(-1px);
}

.btn-small {
  padding: 8px 16px;
  font-size: 15px;
  min-width: 80px;
  height: 36px;
}

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

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

.btn-icon {
  background: none !important;
  border: none !important;
  cursor: pointer !important;
  padding: 8px !important;
  border-radius: 6px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: background-color 0.2s ease !important;
  color: var(--text) !important;
}

.btn-icon:hover {
  background: var(--surface) !important;
}

.btn-icon:active {
  background: var(--border) !important;
  transform: scale(0.95);
}

/* Tables */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 20px 0;
}

.table th,
.table td {
  padding: 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

/* Column-specific alignment */
.table th.size-col,
.table td.size-col {
  text-align: right;
}

.table th.actions-col,
.table td.actions-col {
  text-align: center;
}

.table th.created-col,
.table td.created-col {
  text-align: center;
}

/* Better button alignment in actions column */
.table td.actions-col .btn {
  margin: 0;
  min-width: 60px;
}

.table td.actions-col > div {
  display: flex !important;
  gap: 4px !important;
  justify-content: center !important;
  align-items: center !important;
  flex-wrap: wrap !important;
}

/* Improved file size formatting */
.table td.size-col {
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
  font-size: 14px;
  font-weight: 500;
}

.table th {
  background: var(--surface);
  font-weight: 600;
  font-size: 15px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.table th:first-child,
.table td:first-child {
  border-top-left-radius: var(--radius-sm);
  border-bottom-left-radius: var(--radius-sm);
}

.table th:last-child,
.table td:last-child {
  border-top-right-radius: var(--radius-sm);
  border-bottom-right-radius: var(--radius-sm);
}

.table tbody tr {
  transition: all 0.2s ease;
}

.table tbody tr:hover {
  background: rgba(0, 122, 255, 0.04);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* File table improvements */
.files-table {
  background: var(--background);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.files-table .table {
  margin: 0;
}

.files-table th {
  background: var(--surface);
  padding: 20px 24px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border: none;
}

.files-table td {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

/* File icon styles */
.file-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: white;
  margin-right: 16px;
  flex-shrink: 0;
}

.file-icon.image { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.file-icon.text { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); }
.file-icon.json { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); }
.file-icon.csv { background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%); }
.file-icon.pdf { background: linear-gradient(135deg, #fa709a 0%, #fee140 100%); }
.file-icon.default { background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%); }

.file-info {
  display: flex;
  align-items: center;
}

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

.file-name {
  font-weight: 600;
  font-size: 16px;
  color: var(--text-dark);
  margin-bottom: 4px;
  word-break: break-all;
}

.file-path {
  font-size: 13px;
  color: var(--text-light);
  opacity: 0.7;
}

.file-size {
  font-weight: 500;
  color: var(--text-light);
  font-size: 14px;
}

.file-type {
  display: inline-block;
  background: var(--surface);
  color: var(--text-light);
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  text-transform: lowercase;
}

.file-date {
  font-size: 14px;
  color: var(--text-light);
}

.file-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Enhanced buttons */
.btn-file-action {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-file-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.btn-share {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.btn-download {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  color: white;
}

/* Navigation */
.navbar {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
  position: sticky;
  top: 0;
  z-index: 1000;
  transition: all 0.3s ease;
}

.navbar-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.navbar-brand {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-info {
  font-size: 15px;
  color: var(--text-light);
}

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

.login-card {
  width: 100%;
  max-width: 400px;
  margin: 20px;
}

/* Dashboard layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 30px;
}

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

@media (min-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

/* Stats cards */
.stat-card {
  text-align: center;
  padding: 24px;
  background: var(--background);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.stat-number {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
}

.stat-label {
  font-size: 15px;
  color: var(--text-light);
}

/* Alerts */
.alert {
  padding: 16px 20px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.alert-success {
  background: rgba(48, 209, 88, 0.1);
  border: 1px solid rgba(48, 209, 88, 0.2);
  color: #1B5E20;
}

.alert-error {
  background: rgba(255, 59, 48, 0.1);
  border: 1px solid rgba(255, 59, 48, 0.2);
  color: #C62828;
}

.alert-warning {
  background: rgba(255, 149, 0, 0.1);
  border: 1px solid rgba(255, 149, 0, 0.2);
  color: #E65100;
}

.alert-info {
  background: rgba(0, 122, 255, 0.1);
  border: 1px solid rgba(0, 122, 255, 0.2);
  color: #0056CC;
}

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 50%;
  border-top-color: var(--primary);
  animation: spin 1s ease-in-out infinite;
}

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

/* File size formatting */
.file-size {
  font-family: -apple-system-mono, Monaco, 'Courier New', monospace;
  font-size: 14px;
  color: var(--text-light);
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.2s ease, transform 0.2s ease;
  transform: scale(1);
}

.modal {
  background: var(--background);
  border-radius: var(--radius);
  padding: 30px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  transform: scale(1);
  transition: transform 0.2s ease;
}

/* Modal animations */
.modal-overlay.closing {
  opacity: 0;
  transform: scale(0.95);
}

.modal-overlay.closing .modal {
  transform: scale(0.95);
}

.modal-header {
  margin-bottom: 20px;
}

.modal-title {
  font-size: 22px;
  font-weight: 600;
}

/* Compact modal styles */
.modal-compact {
  padding: 20px;
  max-height: 90vh;
  overflow-y: auto;
}

.form-group-compact {
  margin-bottom: 16px;
}

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

.form-input-compact {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: var(--background);
  transition: all 0.2s ease;
}

.form-input-compact:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.form-row {
  display: flex;
  gap: 0;
  align-items: flex-end;
}

/* Make checkboxes more compact */
.modal-compact input[type="checkbox"] {
  transform: scale(0.9);
}

/* Compact button spacing */
.modal-compact .btn {
  padding: 8px 16px;
  font-size: 14px;
  min-width: 70px;
  height: 32px;
}

/* Animations */
.fade-in {
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Loading toast */
.loading-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 2000;
  animation: slideInRight 0.3s ease-out;
}

.loading-toast-content {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  font-size: 15px;
  color: var(--text);
}

.loading-toast .spinner {
  flex-shrink: 0;
}

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

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

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* Universal toast notifications */
.toast-notification {
  position: fixed;
  top: 20px;
  right: 20px;
  min-width: 300px;
  max-width: 400px;
  border-radius: var(--radius-sm);
  z-index: 2000;
  opacity: 0;
  transform: translateX(100%) scale(0.9);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  box-shadow: var(--shadow);
}

.toast-notification.show {
  opacity: 1;
  transform: translateX(0) scale(1);
}

.toast-notification.hide {
  opacity: 0;
  transform: translateX(100%) scale(0.9);
}

.success-toast {
  background: var(--success);
  color: white;
  border: 1px solid rgba(48, 209, 88, 0.3);
}

.error-toast {
  background: var(--error);
  color: white;
  border: 1px solid rgba(255, 59, 48, 0.3);
}

.info-toast {
  background: var(--primary);
  color: white;
  border: 1px solid rgba(0, 122, 255, 0.3);
}

.toast-content {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
}

.toast-icon {
  font-size: 20px;
  flex-shrink: 0;
  animation: toastIconBounce 0.5s ease-out;
}

@keyframes toastIconBounce {
  0% {
    transform: scale(0.3) rotate(-10deg);
    opacity: 0;
  }
  50% {
    transform: scale(1.2) rotate(5deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

/* Legacy copy toast support */
.copy-toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--success);
  color: white;
  border-radius: 25px;
  z-index: 2000;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.copy-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.copy-toast.hide {
  opacity: 0;
  transform: translateX(-50%) translateY(20px) scale(0.9);
}

.copy-toast-content {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 500;
}

/* Improved button interactions */
.btn:active {
  transform: translateY(1px);
}

.btn-small:active {
  transform: translateY(0.5px);
}

/* Better responsive behavior for toasts and modals */
@media (max-width: 768px) {
  .loading-toast {
    right: 10px;
    top: 10px;
    max-width: calc(100vw - 20px);
  }
  
  .toast-notification {
    right: 10px;
    top: 10px;
    min-width: auto;
    max-width: calc(100vw - 20px);
  }
  
  .toast-content {
    padding: 12px 16px;
    font-size: 14px;
  }
  
  .copy-toast {
    bottom: 20px;
    max-width: calc(100vw - 40px);
  }
  
  .copy-toast-content {
    padding: 10px 16px;
    font-size: 14px;
  }
  
  /* На мобильных устройствах меньший отступ сверху */
  .modal-overlay {
    padding-top: 5vh;
  }
}

/* Improved button feedback */
.btn.loading {
  pointer-events: none;
  opacity: 0.7;
  position: relative;
}

.btn.loading .spinner {
  margin-right: 8px;
}

/* File grouping styles */
.file-folder-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--background);
  overflow: hidden;
}

.folder-header {
  background: var(--surface);
  transition: background-color 0.2s ease;
}

.folder-header:hover {
  background: #E5E5EA;
}

.folder-toggle {
  transition: transform 0.2s ease;
  display: inline-block;
  color: var(--primary);
  font-weight: 600;
}

.folder-content {
  border-top: 1px solid var(--border);
}

.folder-content .table {
  margin: 0;
  border: none;
  border-radius: 0;
  table-layout: fixed;
  width: 100%;
}

.folder-content .table thead th {
  background: #F8F9FA;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
  padding: 12px 15px;
  border-radius: 0;
}

.folder-content .table tbody td {
  padding: 12px 15px;
  border-radius: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Fix column widths for grouped tables */
.folder-content .table th:nth-child(1),
.folder-content .table td:nth-child(1) { 
  width: 35%; 
  min-width: 200px;
} /* File Name */

.folder-content .table th:nth-child(2),
.folder-content .table td:nth-child(2) { 
  width: 15%; 
  text-align: right;
} /* Size */

.folder-content .table th:nth-child(3),
.folder-content .table td:nth-child(3) { 
  width: 20%; 
} /* Type */

.folder-content .table th:nth-child(4),
.folder-content .table td:nth-child(4) { 
  width: 15%; 
  text-align: center;
} /* Created */

.folder-content .table th:nth-child(5),
.folder-content .table td:nth-child(5) { 
  width: 15%; 
  text-align: center;
} /* Actions */

.folder-content .table tbody tr:last-child td {
  border-bottom: none;
}

.folder-content .table tbody tr {
  border-radius: 0;
}

.folder-content .table tbody tr td {
  border-radius: 0;
}

/* File selection grouping in modals */
.file-selection-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  overflow: hidden;
}

.folder-selection-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  transition: background-color 0.2s ease;
}

.folder-selection-header:hover {
  background: #E5E5EA;
}

/* Modal error styling */
.modal-error {
  background: #FEF2F2 !important;
  color: #DC2626 !important;
  border: 1px solid #FECACA !important;
  border-radius: var(--radius-sm);
  padding: 12px;
  margin: 0 0 15px 0 !important;
  font-size: 14px;
  line-height: 1.4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: slideInDown 0.3s ease;
}

.modal-error button {
  background: none !important;
  border: none !important;
  color: #DC2626 !important;
  cursor: pointer;
  font-size: 18px;
  font-weight: bold;
  line-height: 1;
  padding: 0 !important;
  margin: 0 0 0 10px !important;
  min-width: auto !important;
  width: auto !important;
  height: auto !important;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.modal-error button:hover {
  opacity: 1;
  background: none !important;
}

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
