/* 개인 대출관리 PWA - Custom Styles */

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

html {
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
}

body {
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Loading Screen */
#loadingScreen {
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

#loadingScreen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  display: none !important;
}

/* Pattern Lock Screen */
#patternLockScreen {
  transition: opacity 0.3s ease, visibility 0.3s ease;
  touch-action: none;
}

#patternLockScreen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  display: none !important;
}

#patternGrid {
  position: relative;
  z-index: 10;
}

.pattern-dot {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 3px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  cursor: pointer;
}

.pattern-dot::after {
  content: '';
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transition: all 0.15s ease;
}

.pattern-dot.active {
  border-color: #00d9ff;
  background: rgba(0, 217, 255, 0.2);
  transform: scale(1.1);
}

.pattern-dot.active::after {
  background: #00d9ff;
  box-shadow: 0 0 15px rgba(0, 217, 255, 0.6);
}

.pattern-dot.error {
  border-color: #ff5252;
  background: rgba(255, 82, 82, 0.2);
}

.pattern-dot.error::after {
  background: #ff5252;
}

.pattern-dot.success {
  border-color: #00c853;
  background: rgba(0, 200, 83, 0.2);
}

.pattern-dot.success::after {
  background: #00c853;
}

#patternCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
}

/* Page Sections */
.page-section {
  animation: fadeIn 0.3s ease;
}

.page-section.hidden {
  display: none;
}

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

/* Navigation Buttons */
.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 1rem;
  color: #9ca3af;
  transition: all 0.2s ease;
  border-radius: 0.75rem;
  background: transparent;
  border: none;
  cursor: pointer;
}

.nav-btn:hover {
  color: #d1d5db;
  background: rgba(255, 255, 255, 0.05);
}

.nav-btn.active {
  color: #00d9ff;
  background: rgba(0, 217, 255, 0.1);
}

.nav-btn.active i {
  transform: scale(1.1);
}

/* Modal Styles */
.modal {
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal.hidden {
  opacity: 0;
  visibility: hidden;
}

.modal-content {
  animation: slideUp 0.3s ease;
}

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

/* Card Styles */
.loan-card,
.payment-card,
.alarm-card {
  background: linear-gradient(135deg, rgba(22, 33, 62, 0.8) 0%, rgba(26, 26, 46, 0.8) 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 1rem;
  padding: 1rem;
  transition: all 0.2s ease;
}

.loan-card:hover,
.payment-card:hover,
.alarm-card:hover {
  border-color: rgba(0, 217, 255, 0.3);
  transform: translateY(-2px);
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.status-badge.completed {
  background: rgba(0, 200, 83, 0.2);
  color: #00c853;
}

.status-badge.pending {
  background: rgba(255, 171, 0, 0.2);
  color: #ffab00;
}

.status-badge.overdue {
  background: rgba(255, 82, 82, 0.2);
  color: #ff5252;
}

.status-badge.partial {
  background: rgba(0, 217, 255, 0.2);
  color: #00d9ff;
}

/* Form Inputs */
input[type="text"],
input[type="number"],
input[type="date"],
input[type="time"],
select,
textarea {
  font-size: 16px; /* Prevent zoom on iOS */
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 217, 255, 0.3);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 217, 255, 0.5);
}

/* Toast Notification */
#toast {
  animation: toastIn 0.3s ease;
}

#toast.hidden {
  display: none;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translate(-50%, -20px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* Progress Bar */
.progress-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* Upcoming Payment Item */
.upcoming-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 0.75rem;
  transition: all 0.2s ease;
}

.upcoming-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.upcoming-item .date-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, rgba(0, 217, 255, 0.2) 0%, rgba(0, 217, 255, 0.1) 100%);
  border-radius: 0.75rem;
  flex-shrink: 0;
}

.upcoming-item .date-badge .day {
  font-size: 1.25rem;
  font-weight: 700;
  color: #00d9ff;
  line-height: 1;
}

.upcoming-item .date-badge .month {
  font-size: 0.625rem;
  color: rgba(0, 217, 255, 0.8);
  text-transform: uppercase;
}

/* Action Buttons */
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.1);
  color: #9ca3af;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.action-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.action-btn.edit:hover {
  background: rgba(0, 217, 255, 0.2);
  color: #00d9ff;
}

.action-btn.delete:hover {
  background: rgba(255, 82, 82, 0.2);
  color: #ff5252;
}

.action-btn.payment:hover {
  background: rgba(0, 200, 83, 0.2);
  color: #00c853;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  background: #4b5563;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.toggle-switch.active {
  background: #00d9ff;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.toggle-switch.active::after {
  transform: translateX(20px);
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  text-align: center;
}

.empty-state i {
  font-size: 3rem;
  color: rgba(255, 255, 255, 0.1);
  margin-bottom: 1rem;
}

.empty-state p {
  color: #6b7280;
  font-size: 0.875rem;
}

/* Chart Container */
#loanChart {
  max-height: 250px;
}

/* Responsive Design */
@media (min-width: 640px) {
  .modal-content {
    max-height: 80vh;
  }
}

@media (max-width: 380px) {
  .grid-cols-2 {
    grid-template-columns: 1fr;
  }
}

/* Safe Area Insets for notched devices */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  nav {
    padding-bottom: env(safe-area-inset-bottom);
  }
  
  main {
    padding-bottom: calc(6rem + env(safe-area-inset-bottom));
  }
}

/* Pull to Refresh indicator */
.ptr-indicator {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.5rem 1rem;
  background: rgba(22, 33, 62, 0.95);
  border-radius: 9999px;
  color: #00d9ff;
  font-size: 0.875rem;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 30;
}

.ptr-indicator.visible {
  opacity: 1;
}

/* Skeleton Loading */
.skeleton {
  background: linear-gradient(90deg, 
    rgba(255, 255, 255, 0.05) 25%, 
    rgba(255, 255, 255, 0.1) 50%, 
    rgba(255, 255, 255, 0.05) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 0.5rem;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Number Input Arrows */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  opacity: 1;
  height: 30px;
}

/* Highlight Animation */
@keyframes highlight {
  0%, 100% {
    background: transparent;
  }
  50% {
    background: rgba(0, 217, 255, 0.1);
  }
}

.highlight {
  animation: highlight 0.5s ease;
}

/* D-Day Badge */
.d-day-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.625rem;
  font-weight: 600;
}

.d-day-badge.today {
  background: rgba(255, 82, 82, 0.2);
  color: #ff5252;
}

.d-day-badge.soon {
  background: rgba(255, 171, 0, 0.2);
  color: #ffab00;
}

.d-day-badge.normal {
  background: rgba(0, 217, 255, 0.2);
  color: #00d9ff;
}
