@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --primary-blue: #2196F3;
    --success-green: #4CAF50;
    --warning-orange: #FF9800;
    --danger-red: #F44336;
    --text-dark: #212121;
    --text-gray: #757575;
    --border-light: #E0E0E0;
    --bg-light: #F5F5F5;
    --card-white: #FFFFFF;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.12);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.15);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-light);
    min-height: 100vh;
    padding: 20px;
    color: var(--text-dark);
}

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 0 10px;
}

/* 헤더 */
.header {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 30px;
    padding: 0 10px;
    position: relative;
}

.header-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-dark);
    text-align: center;
}

.header-time {
    font-weight: 600;
    margin-left: 8px;
}

.header-time.am {
    color: #F9A825; /* 오전: 노란색 */
}

.header-time.pm {
    color: #FB8C00; /* 오후: 주황색 */
}

.header-time .time-value {
    color: #212121; /* 시간: 검은색 */
    font-weight: 700;
}

.header-actions {
    position: absolute;
    right: 10px;
    display: flex;
    gap: 12px;
}

.btn-header {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-add {
    background: var(--primary-blue);
}

.btn-add:hover {
    background: #1976D2;
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

.btn-restore {
    background: var(--warning-orange);
}

.btn-restore:hover {
    background: #FB8C00;
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

.btn-delete-all {
    background: var(--danger-red);
}

.btn-delete-all:hover {
    background: #d32f2f;
    transform: scale(1.1);
    box-shadow: var(--shadow-md);
}

/* 타이머 그리드 */
.timers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

/* 타이머 카드 */
.timer-card {
    background: var(--card-white);
    border-radius: 12px;
    padding: 14px;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    position: relative;
    border: 2px solid transparent;
    overflow: hidden;
    max-width: 100%;
}

.timer-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.timer-card.running {
    border-color: var(--success-green);
}

.timer-card.countdown {
    border-color: var(--primary-blue);
}

.timer-card.alert {
    border-color: var(--danger-red);
    animation: pulse-border 1.5s infinite;
}

.timer-card.anesthesia-over {
    border-color: var(--danger-red);
    background: #ffebee;
}

/* 시술중 상태 - 파란 테두리 */
.timer-card.procedure-started {
    border-color: var(--primary-blue);
    border-width: 3px;
}

/* 시술종료 상태 - 검은 테두리 */
.timer-card.procedure-finished {
    border-color: #666666;
    border-width: 3px;
}

/* 준비완료 상태 - 초록 테두리 */
.timer-card.anesthesia-complete {
    border-color: var(--success-green);
    border-width: 3px;
}

.timer-card.anesthesia-over .timer-display {
    color: var(--danger-red);
    font-weight: 900;
}

@keyframes pulse-border {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(244, 67, 54, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(244, 67, 54, 0);
    }
}

/* 삭제 버튼 */
.delete-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #BDBDBD;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    transition: all 0.2s ease;
    z-index: 10;
    opacity: 0.4;
}

.delete-btn:hover {
    opacity: 1;
    background: var(--danger-red);
    transform: scale(1.15);
}

/* 타이머 정보 wrapper */
.timer-info-wrapper {
    position: relative;
    margin-bottom: 8px;
    min-height: 24px;
    padding-top: 12px;
    padding-bottom: 12px;
}

.location-info {
    position: absolute;
    top: 0;
    left: 0;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-gray);
    background: white;
    padding: 4px 12px;
    border: 2px solid var(--text-gray);
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    min-height: 28px;
    min-width: 40px;
}

.location-info.empty {
    background: #BDBDBD;
    border-color: #BDBDBD;
    color: transparent;
}

.exit-time-badge {
    position: absolute;
    top: 0;
    right: 0;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--danger-red);
    background: white;
    padding: 3px 10px;
    border: 2px solid var(--danger-red);
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(244, 67, 54, 0.2);
    transition: all 0.2s ease;
    white-space: nowrap;
}

.exit-time-badge:hover {
    background: #ffebee;
    box-shadow: 0 3px 8px rgba(244, 67, 54, 0.3);
    transform: translateY(-1px);
}

/* 환자 정보 */
.patient-info {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex-wrap: wrap;
    width: 100%;
}

.patient-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-dark);
}

.patient-number {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-gray);
    margin-left: 6px;
}

/* 타이머 디스플레이 */
.timer-display {
    font-size: 2.2rem;
    font-weight: 800;
    text-align: center;
    margin: 14px 0 6px 0;
    font-family: 'Inter', sans-serif;
    letter-spacing: -1px;
    color: var(--text-dark);
    line-height: 1;
}

.timer-display.over {
    color: var(--danger-red);
}

.timer-display.countdown-mode {
    color: var(--primary-blue);
}

.timer-card.alert .timer-display {
    color: var(--danger-red);
    animation: blink 1s infinite;
}

.anesthesia-location {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-gray);
    font-weight: 500;
    margin-top: -4px;
    margin-bottom: 8px;
}

@keyframes blink {
    0%, 50%, 100% { opacity: 1; }
    25%, 75% { opacity: 0.5; }
}

/* 컨트롤 */
.controls-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.timer-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.control-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s ease;
    color: white;
    box-shadow: var(--shadow-sm);
}

.control-btn:hover {
    transform: scale(1.08);
    box-shadow: var(--shadow-md);
}

.control-btn:active {
    transform: scale(0.95);
}

.control-btn.play-btn {
    background: var(--success-green);
}

.control-btn.play-btn:hover {
    background: #43A047;
}

.control-btn.reset-btn {
    background: var(--primary-blue);
}

.control-btn.reset-btn:hover {
    background: #1976D2;
}

/* 알림 프리셋 */
.alert-presets {
    display: flex;
    justify-content: center;
    gap: 3px;
    flex-wrap: nowrap;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.alert-presets::-webkit-scrollbar {
    display: none;
}

.preset-btn {
    width: 32px;
    height: 28px;
    border: 2px solid var(--border-light);
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-gray);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.preset-btn:hover {
    border-color: var(--primary-blue);
    background: #E3F2FD;
    color: var(--primary-blue);
}

.preset-btn.active {
    background: var(--primary-blue);
    color: white;
    border-color: var(--primary-blue);
}

/* 입력 */
.input-row {
    display: flex;
    gap: 5px;
    margin-bottom: 8px;
    max-width: 100%;
}

.input-group-inline {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 3px;
    min-width: 0;
}

.input-group-inline label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-gray);
    white-space: nowrap;
    flex-shrink: 0;
    transition: color 0.2s ease;
}

.input-group-inline label[onclick] {
    cursor: pointer;
    user-select: none;
}

.input-group-inline label[onclick]:hover {
    color: var(--primary-blue);
    text-decoration: underline;
}

.input-field-sm {
    flex: 1;
    min-width: 0;
    width: 100%;
    padding: 5px 6px;
    border: 1px solid var(--border-light);
    border-radius: 5px;
    font-size: 0.75rem;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
    background: #FAFAFA;
}

.input-time-display {
    font-weight: 400;
}

.input-field-sm:hover:not([readonly]) {
    border-color: var(--primary-blue);
    background: white;
}

.input-field-sm:focus {
    outline: none;
    border-color: var(--primary-blue);
    background: white;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

/* 입력값이 있을 때 (저장됨 표시) */
.input-field-sm.has-value {
    background: #E8E8E8;
    border-color: #C0C0C0;
    font-weight: 600;
}

.input-field-sm.has-value:hover {
    background: #DEDEDE;
}

/* 시술 내용 */
.procedure-section-wrapper {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
}

.procedure-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
    min-height: 1.05rem; /* 고정 높이로 레이아웃 안정화 */
}

.procedure-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-gray);
    cursor: pointer;
    transition: color 0.2s ease;
    user-select: none;
}

.procedure-title:hover {
    color: var(--primary-blue);
    text-decoration: underline;
}

.procedure-list {
    margin-top: 0;
}

.procedure-divider {
    border-top: 1px dashed var(--border-light);
    margin: 6px 0;
    height: 0;
}

.procedure-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    background: #FAFAFA;
    border-radius: 6px;
    margin-bottom: 6px;
    border: 1px solid var(--border-light);
    transition: all 0.2s ease;
}

.procedure-item.completed {
    opacity: 0.6;
}

.procedure-item.completed .procedure-text {
    text-decoration: line-through;
    color: var(--text-gray);
}

.procedure-text {
    flex: 1;
    font-size: 0.67rem;
    color: var(--text-dark);
    line-height: 1.4;
    transition: all 0.2s ease;
}

.procedure-text:hover {
    color: var(--primary-blue);
}

.procedure-duration {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}

.duration-label {
    font-size: 0.67rem;
    color: var(--text-gray);
    border: 1.5px solid var(--text-gray);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.duration-label:hover {
    background: var(--primary-blue);
    color: white;
    border-color: var(--primary-blue);
    transform: scale(1.1);
}

.increment-btn {
    font-size: 0.67rem;
    color: white;
    background: var(--primary-blue);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    flex-shrink: 0;
}

.increment-btn:hover {
    background: #1976D2;
    transform: scale(1.1);
}

.procedure-item.completed .duration-label {
    color: var(--text-gray);
    border-color: var(--danger-red);
}

.duration-input {
    width: 32px;
    padding: 3px 0px 3px 2px;
    border: 1px solid var(--border-light);
    border-radius: 5px;
    font-size: 0.67rem;
    text-align: right;
    font-family: 'Inter', sans-serif;
    background: white;
}

.duration-input:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.1);
}

.duration-unit {
    font-size: 0.67rem;
    color: var(--text-gray);
    font-weight: 600;
    transition: all 0.2s ease;
    user-select: none;
    margin-left: 2px;
}

.duration-unit:hover {
    color: var(--danger-red);
    transform: scale(1.1);
}

/* 담당자 표시 */
.assigned-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 700;
    margin-right: 6px;
    flex-shrink: 0;
}

/* 담당자 없음 (빈 동그라미) */
.assigned-badge.empty {
    border: 2px solid #D0D0D0;
    background: white;
    color: transparent;
}

/* 담당자별 색상 */
.assigned-badge.assigned-문 {
    background: #FF6B6B;
    color: white;
}

.assigned-badge.assigned-박 {
    background: #4ECDC4;
    color: white;
}

.assigned-badge.assigned-이 {
    background: #FFD93D;
    color: white;
}

.assigned-badge.assigned-김 {
    background: #95E1D3;
    color: white;
}

.assigned-badge.assigned-최 {
    background: #A8E6CF;
    color: white;
}

.assigned-badge.assigned-정 {
    background: #C7CEEA;
    color: white;
}

.assigned-badge.assigned-H {
    background: #FF8C42;
    color: white;
}

/* 기본 색상 (그 외 담당자) */
.assigned-badge.assigned-default {
    background: #9B9B9B;
    color: white;
}

/* 입력 섹션 */
.input-section {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
}

.patient-name-input {
    width: 100%;
    min-height: 70px;
    font-size: 0.85rem;
    font-weight: 400;
    font-family: 'Inter', sans-serif;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 6px;
    transition: all 0.2s ease;
    background: #FAFAFA;
    color: var(--text-dark);
    resize: vertical;
    line-height: 1.5;
}

.patient-name-input:hover {
    border-color: var(--primary-blue);
    background: white;
}

.patient-name-input:focus {
    outline: none;
    border-color: var(--primary-blue);
    background: white;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.btn-submit-input {
    width: 100%;
    padding: 7px 14px;
    background: var(--primary-blue);
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-submit-input:hover {
    background: #1976D2;
    transform: translateY(-1px);
}

.btn-submit-input:active {
    transform: translateY(0);
}

/* 다이얼로그 */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.dialog {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

.edit-procedure-dialog {
    max-width: 600px;
    width: 90%;
}

.edit-procedure-textarea {
    width: 100%;
    min-height: 250px;
    padding: 14px;
    border: 2px solid var(--border-light);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    resize: vertical;
    transition: all 0.2s ease;
}

.edit-procedure-textarea:hover {
    border-color: var(--primary-blue);
    background: #FAFAFA;
}

.edit-procedure-textarea:focus {
    outline: none;
    border-color: var(--primary-blue);
    background: white;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

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

.dialog-header {
    padding: 24px 24px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.dialog-header i {
    font-size: 28px;
    color: var(--warning-orange);
}

.dialog-header.alert-header i {
    color: var(--danger-red);
}

.dialog-header h3 {
    font-size: 1.3rem;
    font-weight: 700;
}

.dialog-body {
    padding: 0 24px 24px;
}

.dialog-body p {
    margin-bottom: 8px;
    color: var(--text-gray);
    line-height: 1.5;
}

.dialog-patient-name {
    font-weight: 700;
    color: var(--text-dark);
    font-size: 1.1rem;
}

.alert-message {
    font-size: 1.05rem;
    color: var(--text-dark);
    line-height: 1.5;
}

.dialog-footer {
    padding: 16px 24px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    border-top: 1px solid var(--border-light);
}

.btn {
    padding: 12px 28px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.btn-primary:hover {
    background: #1976D2;
}

.btn-secondary {
    background: white;
    color: var(--text-dark);
    border: 2px solid var(--border-light);
}

.btn-secondary:hover {
    background: var(--bg-light);
}

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

.btn-danger:hover {
    background: #E53935;
}

/* 마취 닦기 알림 다이얼로그 (4배 크기) */
.anesthesia-wipe-dialog {
    max-width: 800px !important;
    width: 90%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 4px solid var(--danger-red);
}

.anesthesia-wipe-header {
    padding: 48px 48px 32px !important;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px 16px 0 0;
}

.anesthesia-wipe-header i {
    font-size: 72px !important;
    color: var(--danger-red) !important;
    animation: pulse 1s infinite;
}

.anesthesia-wipe-header h2 {
    font-size: 2.8rem !important;
    font-weight: 800;
    color: var(--text-dark);
    margin: 0;
}

.anesthesia-wipe-body {
    padding: 48px !important;
    background: rgba(255, 255, 255, 0.95);
}

.anesthesia-wipe-message {
    font-size: 2.5rem !important;
    font-weight: 700 !important;
    color: var(--danger-red) !important;
    text-align: center;
    line-height: 1.6 !important;
    animation: pulse 1s infinite;
}

.anesthesia-wipe-dialog .dialog-footer {
    padding: 32px 48px !important;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 0 0 16px 16px;
    border-top: 3px solid var(--danger-red);
}

.btn-large {
    padding: 24px 64px !important;
    font-size: 1.8rem !important;
    font-weight: 700 !important;
}

@keyframes pulse {
    0%, 100% { 
        transform: scale(1);
        opacity: 1;
    }
    50% { 
        transform: scale(1.05);
        opacity: 0.9;
    }
}

/* 복구 토스트 */
.restore-dialog {
    min-width: 400px;
    max-width: 500px;
}

.restore-list {
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.restore-item {
    padding: 16px;
    background: var(--bg-light);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.restore-item:hover {
    background: #E3F2FD;
    border-color: var(--primary-blue);
    transform: translateX(4px);
}

.restore-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.restore-number {
    font-size: 0.9rem;
    color: var(--text-gray);
}

.restore-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-gray);
    font-size: 0.95rem;
}

/* 반응형 */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .header {
        flex-direction: row;
        gap: 12px;
        align-items: center;
        margin-bottom: 20px;
    }

    .header-title {
        font-size: 1.2rem;
    }

    .header-actions {
        position: absolute;
        right: 10px;
    }

    .btn-header {
        width: 42px;
        height: 42px;
        font-size: 1rem;
    }

    .timers-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .timer-card {
        padding: 16px;
    }

    .timer-display {
        font-size: 2.2rem;
    }

    .control-btn {
        width: 48px;
        height: 48px;
        font-size: 18px;
    }

    .preset-btn {
        width: 42px;
        height: 32px;
        font-size: 0.8rem;
    }

    .input-group-inline label {
        font-size: 0.7rem;
    }

    .input-field-sm {
        font-size: 0.8rem;
        padding: 6px 8px;
    }
}

@media (min-width: 769px) and (max-width: 1200px) {
    .timers-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }
}
