/**
 * Timer Modal Styles
 * 메인 타이머 모달 전용 스타일
 */

/* KPI 완전 비노출 - 방어적 CSS */
.dm-timer .session-summary,
.dm-timer .timer-kpis,
.dm-timer .kpi-row,
.dm-timer .kpi,
.dm-timer [data-kpi],
#completed-sessions,
#total-time,
#today-pages,
[data-role="completed-sessions"],
[data-role="total-time"],
[data-role="today-pages"],
/* 대시보드 세션 기록 모달 KPI 방어 */
.session-records-modal .session-summary,
.record-modal .session-summary,
.session-summary,
.summary-item,
.summary-value,
.summary-label {
  display: none !important;
}

@layer timer.components {
  /* Main modal overlay */
  .timer-modal-overlay.enhanced {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("/images/timer_bg.jpg") center/cover,
      linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-blend-mode: overlay;
    backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: var(--dm-timer-z-modal, 1000);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
      visibility 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  /* Modal visibility states */
  .timer-modal-overlay.enhanced.is-open {
    display: flex;
    opacity: 1;
    visibility: visible;
    animation: fadeInEnhanced 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .timer-modal-overlay.enhanced.is-hidden {
    opacity: 0;
    visibility: hidden;
  }

  .dm-timer .timer-modal-overlay.enhanced {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("/images/timer_bg.jpg") center/cover,
      var(--timer-background);
    background-blend-mode: overlay;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--timer-z-modal);
    animation: fadeInEnhanced var(--timer-anim-slow) var(--timer-anim-timing);
  }

  /* Background overlay for readability */
  .timer-modal-overlay.enhanced::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: -1;
  }

  .dm-timer .timer-modal-overlay.enhanced::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: -1;
  }

  /* Background particles effect */
  .background-particles {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    pointer-events: none;
  }

  .dm-timer .background-particles {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    pointer-events: none;
  }

  .background-particles::before,
  .background-particles::after {
    content: "";
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    animation: floatParticles 8s ease-in-out infinite;
  }

  .dm-timer .background-particles::before,
  .dm-timer .background-particles::after {
    content: "";
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    animation: floatParticles 8s ease-in-out infinite;
  }

  .background-particles::before {
    top: 20%;
    left: 10%;
    animation-delay: 0s;
  }

  .dm-timer .background-particles::before {
    top: 20%;
    left: 10%;
    animation-delay: 0s;
  }

  .background-particles::after {
    top: 60%;
    right: 15%;
    animation-delay: -3s;
  }

  .dm-timer .background-particles::after {
    top: 60%;
    right: 15%;
    animation-delay: -3s;
  }

  /* Main modal */
  .timer-modal.enhanced {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(25px);
    border-radius: 24px;
    width: 440px;
    max-width: 90vw;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4),
      0 0 0 1px rgba(255, 255, 255, 0.15),
      inset 0 1px 0 rgba(255, 255, 255, 0.2);
    animation: slideUpEnhanced 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    min-height: clamp(520px, 62vh, 640px);
  }

  .dm-timer .timer-modal.enhanced {
    background: var(--timer-glass);
    backdrop-filter: blur(25px);
    border-radius: var(--timer-radius);
    width: 440px;
    max-width: 90vw;
    box-shadow: var(--timer-shadow), 0 0 0 1px rgba(255, 255, 255, 0.15),
      inset 0 1px 0 rgba(255, 255, 255, 0.2);
    animation: slideUpEnhanced var(--timer-anim-slow) var(--timer-anim-timing);
    transition: all var(--timer-anim-duration) var(--timer-anim-timing);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    min-height: clamp(520px, 62vh, 540px);
  }

  /* Header - 최소화 버튼 여백 확보 */
  .timer-header.minimal {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* 헤더 패딩을 살짝 줄여 오른쪽 끝 정렬 안정화 */
    padding: 14px 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    min-height: 60px;
  }

  .dm-timer .timer-header.minimal {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    min-height: 60px;
  }

  .timer-header.minimal h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    text-align: center;
    flex: 1;
    /* Reserve less space on the right for the control buttons to prevent
       an overly wide gap between them.  120px accommodates two 36px
       icons and an 8px gap comfortably. */
    max-width: calc(100% - 120px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .dm-timer .timer-header.minimal h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--timer-text-white);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    text-align: center;
    flex: 1;
    max-width: calc(100% - 120px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .timer-controls {
    display: inline-flex;
    align-items: center;
    gap: var(--dm-timer-control-gap);
  }

  .dm-timer .timer-controls {
    display: inline-flex;
    align-items: center;
    gap: var(--dm-timer-control-gap);
  }

  .control-btn {
    width: var(--dm-timer-control-size);
    height: var(--dm-timer-control-size);
    border-radius: var(--dm-timer-control-radius);
    border: 0;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.95);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease;
  }

  .dm-timer .control-btn {
    width: var(--dm-timer-control-size);
    height: var(--dm-timer-control-size);
    border-radius: var(--dm-timer-control-radius);
    border: 0;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.95);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease;
  }

  .control-btn .icon {
    width: var(--dm-timer-control-icon);
    height: var(--dm-timer-control-icon);
  }

  .control-btn:hover {
    background: rgba(255, 255, 255, 0.16);
    transform: translateY(-1px);
  }

  .dm-timer .control-btn .icon {
    width: var(--dm-timer-control-icon);
    height: var(--dm-timer-control-icon);
  }

  .dm-timer .control-btn:hover {
    background: rgba(255, 255, 255, 0.16);
    transform: translateY(-1px);
  }

  /* 최소화 버튼도 동일 룩앤필 (이전 특별 스타일 제거) */
  .control-btn.minimize {
    background: rgba(255, 255, 255, 0.1);
  }

  .dm-timer .control-btn.minimize {
    background: rgba(255, 255, 255, 0.1);
  }

  /* 다크 테마 대응 */
  .dm-timer [data-theme="dark"] .control-btn {
    background: rgba(255, 255, 255, 0.08);
  }

  .dm-timer [data-theme="dark"] .control-btn:hover {
    background: rgba(255, 255, 255, 0.14);
  }

  /* Timer body - 개선된 여백과 레이아웃 */
  .timer-body.enhanced {
    padding: 1.75rem 1.75rem 1rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 380px;
    position: relative;
  }

  .dm-timer .timer-body.enhanced {
    padding: 1.75rem 1.75rem 1rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 380px;
    position: relative;
  }

  /* Circular timer container */
  .circular-timer-container {
    position: relative;
    display: inline-block;
    margin-bottom: 2rem;
    width: 260px;
    height: 260px;
  }

  .dm-timer .circular-timer-container {
    position: relative;
    display: inline-block;
    margin-bottom: 2rem;
    width: 260px;
    height: 260px;
  }

  .circular-timer {
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.1));
  }

  .dm-timer .circular-timer {
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.1));
  }

  /* Progress circle styles */
  .timer-progress {
    stroke-dasharray: 534; /* 2π × 85 */
    stroke-dashoffset: 534;
    transition: stroke-dashoffset 1s ease-out;
    animation: progressGlow 3s ease-in-out infinite alternate;
  }

  .dm-timer .timer-progress {
    stroke-dasharray: 534; /* 2π × 85 */
    stroke-dashoffset: 534;
    transition: stroke-dashoffset 1s ease-out;
    animation: progressGlow 3s ease-in-out infinite alternate;
  }

  .timer-pulse {
    animation: pulseEffect 4s ease-in-out infinite;
  }

  .dm-timer .timer-pulse {
    animation: pulseEffect 4s ease-in-out infinite;
  }

  /* Center time display */
  .timer-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    width: 180px;
    text-align: center;
  }

  .dm-timer .timer-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    width: 180px;
    text-align: center;
  }

  .timer-time {
    font-size: 2.8rem;
    font-weight: 400;
    color: #ffffff;
    line-height: 1;
    text-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
    letter-spacing: -0.02em;
    white-space: nowrap;
  }

  .dm-timer .timer-time {
    font-size: 2.8rem;
    font-weight: 400;
    color: var(--timer-text-white);
    line-height: 1;
    text-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
    letter-spacing: -0.02em;
    white-space: nowrap;
  }

  /* Focus mode indicator */
  .ambient-info {
    margin-bottom: 2rem;
  }

  .dm-timer .ambient-info {
    margin-bottom: 2rem;
  }

  /* 집중 시간 텍스트 - 자연스럽고 깔끔한 중앙 정렬 */
  .focus-mode {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    background: none;
    border: none;
    padding: 0;
    margin: 0 0 1.5rem 0;
    transition: color 0.3s ease;
    cursor: default;
  }

  .dm-timer .focus-mode {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    background: none;
    border: none;
    padding: 0;
    margin: 0 0 1.5rem 0;
    transition: color 0.3s ease;
    cursor: default;
  }

  .focus-mode:hover {
    color: rgba(255, 255, 255, 1);
    background: none;
    transform: none;
    box-shadow: none;
  }

  .dm-timer .focus-mode:hover {
    color: rgba(255, 255, 255, 1);
    background: none;
    transform: none;
    box-shadow: none;
  }

  .mode-icon {
    font-size: 1.25rem;
    animation: iconPulse 2s ease-in-out infinite;
  }

  .dm-timer .mode-icon {
    font-size: 1.25rem;
    animation: iconPulse 2s ease-in-out infinite;
  }

  .mode-text {
    font-weight: 600;
    letter-spacing: 0.02em;
  }

  .dm-timer .mode-text {
    font-weight: 600;
    letter-spacing: 0.02em;
  }

  /* Break mode styles */
  .timer-modal.break-mode .focus-mode {
    background: rgba(16, 185, 129, 0.2);
    border-color: rgba(16, 185, 129, 0.3);
  }

  .dm-timer .timer-modal.break-mode .focus-mode {
    background: rgba(16, 185, 129, 0.2);
    border-color: rgba(16, 185, 129, 0.3);
  }

  .timer-modal.break-mode .focus-mode .mode-icon {
    animation: iconFloat 3s ease-in-out infinite;
  }

  .dm-timer .timer-modal.break-mode .focus-mode .mode-icon {
    animation: iconFloat 3s ease-in-out infinite;
  }

  .timer-modal.break-mode .focus-mode .mode-text {
    color: #ffffff;
  }

  .dm-timer .timer-modal.break-mode .focus-mode .mode-text {
    color: #ffffff;
  }

  /* Action buttons - 하단 여백 추가로 모달 경계와 거리 확보 */
  .timer-actions.enhanced {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: center;
    /* 최소 24px + iOS Safe Area 고려한 하단 패딩 */
    padding: 1rem 1.5rem max(24px, env(safe-area-inset-bottom) + 12px);
    width: 100%;
    box-sizing: border-box;
    margin-top: auto;
  }

  .dm-timer .timer-actions.enhanced {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: center;
    padding: 1rem 1.5rem max(24px, env(safe-area-inset-bottom) + 12px);
    width: 100%;
    box-sizing: border-box;
    margin-top: auto;
  }

  .timer-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: var(--dm-timer-btn-padding, 12px 20px);
    border: none;
    border-radius: 16px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    min-width: 120px;
    flex: 0 1 auto;
  }

  .dm-timer .timer-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: var(--dm-timer-btn-padding);
    border: none;
    border-radius: var(--timer-radius-lg);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s var(--timer-anim-timing);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    min-width: 120px;
    flex: 0 1 auto;
  }

  .timer-btn.primary {
    background: #3b82f6;
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.3);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  }

  .dm-timer .timer-btn.primary {
    background: var(--timer-primary);
    color: var(--timer-text-white);
    box-shadow: 0 4px 14px var(--timer-glow);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  }

  .timer-btn.primary:hover {
    background: #1d4ed8;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.3);
  }

  .dm-timer .timer-btn.primary:hover {
    background: var(--timer-secondary);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--timer-glow);
  }

  /* 일시정지 버튼 - 중립 색상으로 강조 제거 */
  .timer-btn.primary.pause {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  }

  .dm-timer .timer-btn.primary.pause {
    background: rgba(255, 255, 255, 0.1);
    color: var(--timer-text-white);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  }

  /* 일시정지 버튼 hover - 중립적인 반응 */
  .timer-btn.primary.pause:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  }

  .dm-timer .timer-btn.primary.pause:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  }

  .timer-btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  }

  .dm-timer .timer-btn.secondary {
    background: var(--timer-glass);
    color: var(--timer-text-white);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  }

  .timer-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
  }

  .dm-timer .timer-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
  }

  /* Minimize area */
  /* 최소화 영역 - 개선된 여백과 스타일 */
  .timer-minimize {
    padding: 1.25rem 1.5rem;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.02);
    transition: all 0.25s ease;
    text-shadow: none;
    margin-top: 0.5rem;
  }

  .dm-timer .timer-minimize {
    padding: 1.25rem 1.5rem;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.02);
    transition: all 0.25s ease;
    text-shadow: none;
    margin-top: 0.5rem;
  }

  .timer-minimize:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.9);
    border-top-color: rgba(255, 255, 255, 0.15);
  }

  .dm-timer .timer-minimize:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.9);
    border-top-color: rgba(255, 255, 255, 0.15);
  }

