/**
 * K-MP3 Media Player - Custom Styles
 * Mobile-first responsive design
 * Created: June 17, 2025
 */

/* ===== GLOBAL STYLES ===== */
body {
  padding-top: 70px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  font-family: "Prompt", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

.container-fluid {
  max-width: 1200px;
  margin: 0 auto;
}

/* ===== NAVBAR ===== */
.navbar-default {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.navbar-brand {
  font-weight: bold;
  color: #667eea !important;
}

.navbar-brand i {
  margin-right: 8px;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 15px;
  padding: 30px;
  margin: 20px 0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
}

.page-header {
  border-bottom: 2px solid #f5f5f5;
  margin-bottom: 30px;
}

.page-header h1 {
  color: #333;
  margin-bottom: 10px;
}

.gradient-title {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  word-wrap: break-word;
  white-space: normal;
  line-height: 1.2;
}

.subtitle-text {
  color: #764ba2 !important;
  word-wrap: break-word;
  white-space: normal;
}

/* ===== FOLDER CARDS ===== */
.folder-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  border: 1px solid #f0f0f0;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  touch-action: manipulation;
}

.folder-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.folder-card:active {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.folder-icon {
  text-align: center;
  margin-bottom: 15px;
}

.folder-icon i {
  color: #667eea;
  transition: color 0.3s ease;
}

.folder-card:hover .folder-icon i {
  color: #764ba2;
}

.folder-name {
  margin: 0 0 10px 0;
  font-weight: 600;
  color: #333;
  text-align: center;
  word-wrap: break-word;
}

.folder-stats {
  text-align: center;
  margin-bottom: 15px;
  color: #666;
}

.folder-actions {
  text-align: center;
}

.folder-actions .btn {
  margin: 0 2px;
  border-radius: 20px;
}

/* Ensure folder action buttons are clickable */
.folder-actions {
  position: relative;
  z-index: 10;
}

.folder-actions .btn {
  position: relative;
  z-index: 11;
  pointer-events: auto;
}

/* Prevent folder card click on action buttons */
.folder-card .folder-actions {
  pointer-events: auto;
}

.folder-card .folder-actions * {
  pointer-events: auto;
}

/* ===== AUDIO PLAYER ===== */
.audio-player-container {
  background: linear-gradient(135deg, #667eea, #764ba2);
  border-radius: 15px;
  padding: 25px;
  margin-bottom: 30px;
  color: white;
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.player-info {
  text-align: center;
  margin-bottom: 20px;
}

.track-info h4 {
  margin: 0 0 5px 0;
  font-size: 18px;
  font-weight: 600;
}

/* Sliding title container */
.track-title-container {
  width: 100%;
  height: 24px; /* Fixed height for one line */
  overflow: hidden;
  position: relative;
  background: transparent;
  border-radius: 4px;
  display: flex;
  align-items: center;
}

.sliding-title {
  white-space: nowrap;
  margin: 0 !important;
  font-size: 18px !important;
  font-weight: 600 !important;
  line-height: 24px !important;
  display: inline-block;
  position: absolute;
  right: 0; /* เริ่มต้นที่ขอบขวาเสมอ */
  top: 0;
}

/* Animation for all sliding titles */
.sliding-title.animate {
  animation: slideLeftSmooth linear infinite;
}

@keyframes slideLeftSmooth {
  0% {
    transform: translateX(0%);
  }
  100% {
    transform: translateX(-200%);
  }
}

/* Responsive font sizes */
@media (max-width: 768px) {
  .sliding-title {
    font-size: 16px !important;
  }
  .track-title-container {
    height: 22px;
  }
}

@media (max-width: 480px) {
  .sliding-title {
    font-size: 14px !important;
  }
  .track-title-container {
    height: 20px;
  }
}

.track-info p {
  margin: 0;
  opacity: 0.8;
}

.audio-controls {
  width: 100%;
  margin-bottom: 20px;
  border-radius: 25px;
  height: 50px;
}

.player-controls {
  text-align: center;
  margin-bottom: 20px;
}

.player-controls .btn {
  margin: 0 5px;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.player-controls .btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
  color: white;
}

.player-controls .btn-lg {
  width: 60px;
  height: 60px;
  font-size: 20px;
}

.player-controls .btn.active {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.6);
}

.playlist-controls {
  text-align: center;
}

.playlist-controls .btn {
  margin: 0 5px;
  border-radius: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.playlist-controls .btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
  color: white;
}

/* ===== FILE LIST ===== */
.file-list {
  max-height: 500px;
  overflow-y: auto;
}

.file-item {
  display: flex;
  align-items: center;
  padding: 15px;
  margin-bottom: 10px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
  cursor: pointer;
  border: 2px solid transparent;
}

.file-item:hover {
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
  border-color: #667eea;
}

.file-item.playing {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border-color: #667eea;
}

.file-item.playing .text-muted {
  color: rgba(255, 255, 255, 0.8) !important;
}

.file-icon {
  margin-right: 15px;
  min-width: 50px;
  text-align: center;
}

.file-icon i {
  color: #667eea;
  transition: color 0.3s ease;
}

.file-item.playing .file-icon i {
  color: white;
}

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

.file-name {
  margin: 0 0 5px 0;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-item.playing .file-name {
  color: white;
}

.file-details {
  margin: 0;
  font-size: 12px;
}

.file-actions {
  margin-left: 15px;
}

.file-actions .btn {
  margin: 0 2px;
  border-radius: 50%;
  width: 35px;
  height: 35px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  padding: 60px 20px;
}

.empty-state i {
  margin-bottom: 20px;
}

.empty-state h3 {
  color: #666;
  margin-bottom: 15px;
}

/* ===== MODALS ===== */
.modal-content {
  border-radius: 10px;
  border: none;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.modal-header {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border-radius: 10px 10px 0 0;
}

.modal-header .close {
  color: white;
  opacity: 0.8;
}

.modal-header .close:hover {
  opacity: 1;
}

.modal-body {
  padding: 30px;
}

.modal-footer {
  border-top: 1px solid #f5f5f5;
  padding: 20px 30px;
}

/* ===== TOAST NOTIFICATIONS ===== */
#toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 9999;
  max-width: 300px;
}

.toast {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
  margin-bottom: 10px;
  padding: 15px;
  border-left: 4px solid;
  opacity: 0;
  transform: translateX(100%);
  transition: all 0.3s ease;
  border: 1px solid;
}

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

.toast.success {
  border-color: #c3e6cb;
  background-color: #d4edda;
  color: #155724;
}

.toast.error {
  border-color: #f5c6cb;
  background-color: #f8d7da;
  color: #721c24;
}

.toast.info {
  border-color: #bee5eb;
  background-color: #d1ecf1;
  color: #0c5460;
}

.toast-header {
  font-weight: 600;
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  line-height: 1.2;
}

.toast-title {
  display: flex;
  align-items: center;
  flex: 1;
}

.toast-title i {
  margin-right: 8px;
  font-size: 16px;
}

.toast.success .toast-title i {
  color: #28a745;
}

.toast.error .toast-title i {
  color: #dc3545;
}

.toast.info .toast-title i {
  color: #17a2b8;
}

.toast-title span {
  line-height: 1;
}

.toast-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  opacity: 0.6;
  line-height: 1;
  padding: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: inherit;
  font-weight: bold;
}

.toast-close:hover {
  opacity: 1;
  background-color: rgba(0, 0, 0, 0.1);
  border-radius: 3px;
}

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-spinner {
  text-align: center;
  color: white;
}

.loading-spinner p {
  margin-top: 15px;
  font-size: 16px;
}

/* ===== PROGRESS BAR ===== */
.progress {
  height: 8px;
  border-radius: 4px;
  background: #f5f5f5;
  margin-top: 15px;
}

.progress-bar {
  background: linear-gradient(135deg, #667eea, #764ba2);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {
  .main-content {
    margin: 10px;
    padding: 20px;
    border-radius: 10px;
  }
  .page-header h1 {
    font-size: 24px;
    line-height: 1.3;
    word-wrap: break-word;
  }

  .gradient-title {
    font-size: 24px !important;
    line-height: 1.3;
  }

  .folder-card {
    margin-bottom: 15px;
    padding: 15px;
    min-height: 140px;
    position: relative;
  }

  .audio-player-container {
    padding: 20px 15px;
    margin-bottom: 20px;
  }

  .player-controls .btn {
    margin: 0 3px;
    width: 45px;
    height: 45px;
  }

  .player-controls .btn-lg {
    width: 55px;
    height: 55px;
    font-size: 18px;
  }

  .file-item {
    padding: 12px;
    margin-bottom: 8px;
  }

  .file-icon {
    margin-right: 12px;
    min-width: 40px;
  }

  .file-actions .btn {
    width: 32px;
    height: 32px;
    font-size: 12px;
  }
  #toast-container {
    right: 10px;
    left: 10px;
    max-width: none;
  }

  .modal-body {
    padding: 20px;
  }

  .navbar-brand {
    font-size: 16px;
  }

  .folder-actions .btn {
    min-height: 44px;
    min-width: 44px;
    margin: 2px;
    font-size: 16px;
  }

  .folder-actions {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 15px;
  }
}

@media (max-width: 480px) {
  body {
    padding-top: 60px;
  }

  .main-content {
    margin: 5px;
    padding: 15px;
  }

  .folder-actions .btn {
    padding: 5px 8px;
    font-size: 12px;
  }

  .player-controls .btn {
    margin: 0 2px;
    width: 40px;
    height: 40px;
    font-size: 14px;
  }

  .player-controls .btn-lg {
    width: 50px;
    height: 50px;
    font-size: 16px;
  }

  .playlist-controls .btn {
    padding: 8px 12px;
    font-size: 12px;
    margin: 2px;
  }

  .file-item {
    padding: 10px;
  }

  .file-name {
    font-size: 14px;
  }

  .file-details {
    font-size: 11px;
  }
}

/* ===== CUSTOM SCROLLBAR ===== */
.file-list::-webkit-scrollbar {
  width: 6px;
}

.file-list::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.file-list::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.file-list::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.folder-card,
.file-item {
  animation: fadeIn 0.5s ease forwards;
}

.folder-card:nth-child(odd) {
  animation-delay: 0.1s;
}

.folder-card:nth-child(even) {
  animation-delay: 0.2s;
}

/* ===== AUDIO PLAYER CONTROLS ===== */

/* Repeat button states */
#repeat-btn.active {
  background-color: #5cb85c !important;
  border-color: #4cae4c !important;
  color: white !important;
}

#repeat-btn.repeat-all {
  background-color: #5bc0de !important;
  border-color: #46b8da !important;
}

#repeat-btn.repeat-one {
  background-color: #f0ad4e !important;
  border-color: #eea236 !important;
}

#repeat-btn.active:hover {
  opacity: 0.9;
}

/* Shuffle button */
#shuffle-btn.active {
  background-color: #d9534f !important;
  border-color: #d43f3a !important;
  color: white !important;
}

/* Play controls */
.audio-controls {
  margin: 20px 0;
  text-align: center;
}

.audio-controls .btn {
  margin: 0 5px;
  transition: all 0.3s ease;
}

.audio-controls .btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* ===== GO BACK SECTION ===== */
.go-back-section {
  margin-bottom: 20px;
  padding-bottom: 10px;
}

.back-to-home {
  background: linear-gradient(135deg, #667eea, #764ba2);
  border: none;
  color: white;
  padding: 8px 16px;
  border-radius: 25px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 15px rgba(103, 126, 234, 0.3);
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-block;
}

.back-to-home:hover,
.back-to-home:focus {
  background: linear-gradient(135deg, #5a6fd8, #6a42a0);
  color: white;
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(103, 126, 234, 0.4);
}

.back-to-home i {
  margin-right: 6px;
  font-size: 12px;
}

/* ===== UTILITY CLASSES ===== */
.text-shadow {
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.glass-effect {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.gradient-text {
  background: linear-gradient(135deg, #667eea, #764ba2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.btn-touch-active {
  transform: scale(0.95);
  opacity: 0.8;
}

/* Better touch targets for all clickable elements */
.btn,
a,
button,
[onclick] {
  min-height: 44px;
  min-width: 44px;
  touch-action: manipulation;
}

/* Folder open button specific styles */
.folder-open-btn {
  position: relative;
  z-index: 12;
  pointer-events: auto;
  text-decoration: none !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  cursor: pointer;
  /* Enhanced touch handling */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.folder-open-btn i {
  margin: 0;
  line-height: 1;
}

.folder-open-btn:hover,
.folder-open-btn:focus,
.folder-open-btn:active {
  text-decoration: none !important;
  color: #fff !important;
}

/* Touch feedback for mobile - enhanced */
.folder-open-btn:active,
.folder-open-btn:focus {
  transform: scale(0.95);
  transition: transform 0.1s ease;
  background-color: #337ab7 !important;
}

/* Touch state feedback */
.folder-open-btn.touching {
  transform: scale(0.95);
  background-color: #2e6da4 !important;
  transition: all 0.1s ease;
}

/* Mobile-specific improvements */
@media (max-width: 768px) {
  .folder-open-btn {
    min-height: 44px;
    min-width: 44px;
    padding: 8px 12px;
    font-size: 14px;
    border-radius: 4px;
  }
}
