/* style.css - Modern FTP Client Redesign */
:root {
  --primary-color: #667eea;
  --primary-dark: #5a6fd8;
  --secondary-color: #764ba2;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --error-color: #ef4444;
  --info-color: #3b82f6;
  --dark-color: #1f2937;
  --light-color: #f8fafc;
  --gray-color: #6b7280;
  --border-color: #e5e7eb;
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  min-height: 100vh;
  color: var(--dark-color);
  line-height: 1.6;
}

/* Layout Components */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* Login Page */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.login-card {
  width: 100%;
  max-width: 440px;
  position: relative;
}

.login-header {
  text-align: center;
  padding: 2.5rem 2rem 1rem;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
}

.login-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
}

.login-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.login-header p {
  opacity: 0.9;
  font-size: 0.95rem;
}

.login-body {
  padding: 2rem;
}

/* Forms */
.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--dark-color);
  font-size: 0.9rem;
}

.form-control {
  width: 100%;
  padding: 0.875rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  transition: var(--transition);
  background: white;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-control::placeholder {
  color: var(--gray-color);
  opacity: 0.7;
}

.form-hint {
  display: block;
  margin-top: 0.375rem;
  font-size: 0.8rem;
  color: var(--gray-color);
}

/* Checkbox */
.checkbox-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.checkbox-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary-color);
}

.checkbox-group label {
  margin: 0;
  font-weight: 500;
  cursor: pointer;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 1.5rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  line-height: 1.2;
  min-height: 36px;
  box-sizing: border-box;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--primary-color);
  color: white;
  width: 100%;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-secondary {
  background: var(--gray-color);
  color: white;
}

.btn-secondary:hover {
  background: #5a6268;
}

.btn-success {
  background: var(--success-color);
  color: white;
}

.btn-success:hover {
  background: #059669;
}

.btn-danger {
  background: var(--error-color);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-info {
  background: var(--info-color);
  color: white;
}

.btn-info:hover {
  background: #2563eb;
}

.btn-sm {
  padding: 0.5rem 0.75rem !important;
  font-size: 0.8rem !important;
  min-height: 32px;
  min-width: 70px;
  text-align: center;
}

.btn-full {
  flex: 1;
}

/* Button Alignment Fixes */
.action-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.action-buttons .btn,
.action-buttons .delete-form .btn {
  min-width: 70px;
  text-align: center;
  padding: 0.5rem 0.75rem !important;
  font-size: 0.8rem !important;
  height: auto;
  line-height: 1.2;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Ensure all buttons have same height and alignment */
.action-buttons .btn-sm {
  padding: 0.5rem 0.75rem !important;
  font-size: 0.8rem !important;
  min-height: 32px;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
}

/* Fix delete form inline display */
.delete-form {
  display: inline-block;
  margin: 0;
}

/* Fix visited link colors */
a:visited {
  color: var(--primary-color) !important;
}

a.btn {
  color: white !important;
  text-decoration: none !important;
}

a.btn:visited {
  color: white !important;
}

a.btn-secondary:visited {
  color: white !important;
}

a.btn-success:visited {
  color: white !important;
}

a.btn-info:visited {
  color: white !important;
}

a.btn-danger:visited {
  color: white !important;
}

/* Specific fixes for file table buttons */
.file-table .action-buttons {
  justify-content: flex-start;
}

.file-table .action-buttons .btn,
.file-table .action-buttons .delete-form .btn {
  flex: 0 0 auto;
  width: auto;
}

/* Ensure consistent button sizes in action-buttons */
.action-buttons > * {
  flex-shrink: 0;
}

/* Mobile responsiveness for action buttons */
@media (max-width: 768px) {
  .action-buttons {
    gap: 0.375rem;
  }
  
  .action-buttons .btn,
  .action-buttons .delete-form .btn {
    min-width: 65px;
    padding: 0.4rem 0.6rem !important;
    font-size: 0.75rem !important;
  }
  
  .file-table .action-buttons {
    flex-direction: row;
    flex-wrap: wrap;
  }
  
  .btn-sm {
    min-width: 65px;
  }
}

@media (max-width: 480px) {
  .action-buttons {
    gap: 0.25rem;
  }
  
  .action-buttons .btn,
  .action-buttons .delete-form .btn {
    min-width: 60px;
    padding: 0.35rem 0.5rem !important;
    font-size: 0.7rem !important;
  }
  
  .btn-sm {
    min-width: 60px;
  }
}

/* Fix for button alignment in table cells */
.file-table td .action-buttons {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Force consistent button sizes */
.action-buttons a.btn,
.action-buttons button.btn,
.action-buttons .delete-form button {
  min-width: 70px !important;
  max-width: 70px !important;
  padding: 0.5rem 0.5rem !important;
  margin: 0 !important;
  text-align: center;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .action-buttons a.btn,
  .action-buttons button.btn,
  .action-buttons .delete-form button {
    min-width: 65px !important;
    max-width: 65px !important;
    padding: 0.4rem 0.4rem !important;
    font-size: 0.75rem;
  }
}

@media (max-width: 480px) {
  .action-buttons a.btn,
  .action-buttons button.btn,
  .action-buttons .delete-form button {
    min-width: 60px !important;
    max-width: 60px !important;
    padding: 0.35rem 0.35rem !important;
    font-size: 0.7rem;
  }
}

/* Alerts */
.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.5rem;
  font-weight: 500;
  border-left: 4px solid transparent;
}

.alert-error {
  background: #fef2f2;
  border-color: var(--error-color);
  color: #7f1d1d;
}

.alert-success {
  background: #f0fdf4;
  border-color: var(--success-color);
  color: #14532d;
}

.alert-warning {
  background: #fffbeb;
  border-color: var(--warning-color);
  color: #78350f;
}

/* Error Tips */
.error-tips {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(239, 68, 68, 0.2);
}

.error-tips strong {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.error-tips ul {
  margin: 0.5rem 0 0 1.5rem;
  font-size: 0.875rem;
}

.error-tips li {
  margin-bottom: 0.25rem;
}

/* Debug Section */
.debug-section {
  background: #f8fafc;
  padding: 1.25rem;
  border-radius: var(--radius-sm);
  margin-top: 1.5rem;
  font-size: 0.875rem;
  border: 1px solid var(--border-color);
}

.debug-section h4 {
  margin-bottom: 0.75rem;
  color: var(--dark-color);
  font-size: 1rem;
}

.debug-section p {
  margin-bottom: 0.5rem;
  color: var(--gray-color);
}

.debug-link {
  text-align: center;
  margin-top: 1rem;
}

.debug-link a {
  color: var(--primary-color);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.debug-link a:hover {
  text-decoration: underline;
}

/* Hosting Examples */
.hosting-examples {
  background: #f8fafc;
  padding: 1.5rem;
  border-radius: var(--radius-sm);
  margin-top: 2rem;
  border: 1px solid var(--border-color);
}

.hosting-examples h3 {
  margin-bottom: 1rem;
  color: var(--dark-color);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hosting-examples ul {
  list-style: none;
}

.hosting-examples li {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.hosting-examples li:last-child {
  border-bottom: none;
}

.hosting-examples li::before {
  content: "•";
  color: var(--primary-color);
  font-weight: bold;
}

.hosting-examples strong {
  color: var(--primary-color);
}

/* Dashboard */
.dashboard-container {
  background: white;
  min-height: 100vh;
}

.dashboard-header {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
  padding: 1.5rem 0;
  box-shadow: var(--shadow);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.header-info h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.connection-info {
  font-size: 0.9rem;
  opacity: 0.9;
}

.header-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Breadcrumb */
.breadcrumb {
  background: #f8fafc;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.breadcrumb a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition);
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb span {
  color: var(--gray-color);
  margin: 0 0.5rem;
}

/* File Actions - FIXED FOR MOBILE */
.file-actions-section {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.file-actions-header {
  background: var(--primary-color);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: var(--transition);
}

.file-actions-header:hover {
  background: var(--primary-dark);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-left h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.collapse-indicator {
  font-size: 0.8rem;
  opacity: 0.9;
}

.toggle-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 1rem;
}

.toggle-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.file-actions-compact {
  background: #f8fafc;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  border: 1px solid var(--border-color);
  border-top: none;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: top;
}

.file-actions-compact.expanded {
  max-height: 1000px; /* Increased for mobile */
  opacity: 1;
  padding: 1.5rem;
  transform: scaleY(1);
}

.actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.action-item {
  background: white;
  padding: 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  transition: var(--transition);
}

.action-item:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow);
}

.action-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-weight: 600;
  color: var(--dark-color);
  font-size: 0.95rem;
}

.compact-form {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.form-input {
  flex: 1;
}

.form-input input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition: var(--transition);
}

.form-input input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.compact-btn {
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.compact-btn:hover {
  transform: translateY(-1px);
}

.btn-upload {
  background: var(--success-color);
  color: white;
}

.btn-folder {
  background: var(--info-color);
  color: white;
}

.btn-file {
  background: var(--warning-color);
  color: white;
}

.file-input-compact {
  position: relative;
}

.file-input-compact input[type="file"] {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.file-input-label {
  display: block;
  padding: 0.625rem 0.875rem;
  background: #f8fafc;
  border: 2px dashed #d1d5db;
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 0.85rem;
  color: var(--gray-color);
  cursor: pointer;
  transition: var(--transition);
}

.file-input-label:hover {
  border-color: var(--primary-color);
  background: #f1f5f9;
}

.file-name {
  font-size: 0.8rem;
  color: var(--gray-color);
  margin-top: 0.5rem;
  font-style: italic;
}

/* Stats */
.stats-compact {
  background: var(--primary-color);
  color: white;
  padding: 1rem;
  border-radius: var(--radius-sm);
  margin-top: 1.25rem;
  font-size: 0.85rem;
  font-weight: 500;
}

/* File List */
.file-list-container {
  padding: 1.5rem;
}

.file-list-container h3 {
  margin-bottom: 1.25rem;
  color: var(--dark-color);
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.file-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.file-table th,
.file-table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.file-table th {
  background: #f8fafc;
  color: var(--dark-color);
  font-weight: 600;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.file-table tr:hover {
  background: #f8fafc;
}

.file-table a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition);
}

.file-table a:hover {
  text-decoration: underline;
}

/* Empty Folder */
.empty-folder {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--gray-color);
  font-style: italic;
}

.empty-folder-tip {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  opacity: 0.8;
}

/* File Type Badges */
.file-type-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  background: var(--warning-color);
  color: white;
  border-radius: 1rem;
  font-size: 0.7rem;
  margin-left: 0.5rem;
  font-weight: 500;
}

/* Editor Styles */
.editor-container {
  padding: 1.5rem;
}

.file-info {
  background: #f8fafc;
  padding: 1.25rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.5rem;
  border-left: 4px solid var(--primary-color);
}

.file-info p {
  margin: 0.5rem 0;
  font-size: 0.9rem;
}

.editor-actions {
  margin-top: 1.5rem;
  display: flex;
  gap: 0.75rem;
}

/* Editor Switcher */
.editor-switcher {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
}

.editor-tab {
  padding: 0.75rem 1.25rem;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.editor-tab.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.editor-tab:hover:not(.active) {
  background: #e5e7eb;
}

.editor-info {
  background: #f8fafc;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--gray-color);
  border-left: 4px solid var(--info-color);
}

/* CodeMirror Custom */
.CodeMirror {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 14px;
  line-height: 1.5;
  height: 500px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

/* Responsive Design - FIXED FOR MOBILE QUICK ACTIONS */
@media (max-width: 768px) {
  .login-container {
    padding: 1rem;
  }
  
  .login-header {
    padding: 2rem 1.5rem 1rem;
  }
  
  .login-body {
    padding: 1.5rem;
  }
  
  .header-content {
    flex-direction: column;
    text-align: center;
  }
  
  .header-actions {
    justify-content: center;
  }
  
  .actions-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .action-item {
    padding: 1rem;
  }
  
  .compact-form {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  
  .file-actions-compact.expanded {
    padding: 1.25rem;
    max-height: 1200px; /* More space for mobile */
  }
  
  .file-table {
    font-size: 0.875rem;
    display: block;
    overflow-x: auto;
  }
  
  .file-table th,
  .file-table td {
    padding: 0.75rem 0.5rem;
  }
  
  .editor-actions {
    flex-direction: column;
  }
  
  .editor-switcher {
    flex-direction: column;
  }
  
  .CodeMirror {
    height: 300px;
    font-size: 12px;
  }
  
  /* Mobile-specific quick actions fixes */
  .file-actions-section {
    padding: 1rem;
  }
  
  .file-actions-header {
    padding: 0.875rem 1.25rem;
  }
  
  .header-left h3 {
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .login-card {
    margin: 0.5rem;
  }
  
  .login-header h1 {
    font-size: 1.5rem;
  }
  
  .breadcrumb {
    font-size: 0.875rem;
    padding: 0.875rem 1rem;
  }
  
  .file-list-container {
    padding: 1rem;
  }
  
  .file-actions-section {
    padding: 0.875rem;
  }
  
  .file-actions-compact.expanded {
    padding: 1rem;
    max-height: 1400px; /* Even more space for very small screens */
  }
  
  .action-item {
    padding: 0.875rem;
  }
  
  .action-title {
    font-size: 0.9rem;
  }
  
  .form-input input {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
  }
  
  .compact-btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
  }
}

/* Loading States */
.btn-loading {
  pointer-events: none;
  opacity: 0.7;
}

.btn-loading::after {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-left: 0.5rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Focus States */
button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Selection */
::selection {
  background: rgba(102, 126, 234, 0.2);
}