/* css/components.css - 공통 컴포넌트 스타일 */

/* ========== 접근성 유틸리티 ========== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ========== 포커스 스타일 개선 ========== */
*:focus-visible {
    outline: 2px solid #4F46E5;
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid #4F46E5;
    outline-offset: 2px;
}

/* ========== 버튼 스타일 ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 0.5rem;
    transition: all 0.2s ease-in-out;
    cursor: pointer;
    border: none;
    min-height: 44px; /* 터치 최적화 */
    gap: 0.5rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Primary 버튼 */
.btn-primary {
    background-color: #4f46e5; /* indigo-600 */
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: #4338ca; /* indigo-700 */
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(79, 70, 229, 0.3);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

/* Secondary 버튼 */
.btn-secondary {
    background-color: #6b7280; /* gray-500 */
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background-color: #4b5563; /* gray-600 */
}

/* Success 버튼 */
.btn-success {
    background-color: #10b981; /* green-500 */
    color: white;
}

.btn-success:hover:not(:disabled) {
    background-color: #059669; /* green-600 */
}

/* Danger 버튼 */
.btn-danger {
    background-color: #ef4444; /* red-500 */
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background-color: #dc2626; /* red-600 */
}

/* Outline 버튼 */
.btn-outline {
    background-color: transparent;
    border: 2px solid #4f46e5;
    color: #4f46e5;
}

.btn-outline:hover:not(:disabled) {
    background-color: #4f46e5;
    color: white;
}

/* Small 버튼 */
.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    min-height: 36px;
}

/* Large 버튼 */
.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1.125rem;
    min-height: 52px;
}

/* ========== 카드 컴포넌트 ========== */
.card {
    background: white;
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.2s ease-in-out;
}

.card:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.card-header {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: #1f2937; /* gray-800 */
}

.card-body {
    color: #4b5563; /* gray-600 */
}

/* ========== Badge (뱃지) ========== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
    text-transform: uppercase;
}

.badge-success {
    background-color: #d1fae5; /* green-100 */
    color: #065f46; /* green-800 */
}

.badge-warning {
    background-color: #fef3c7; /* yellow-100 */
    color: #92400e; /* yellow-800 */
}

.badge-danger {
    background-color: #fee2e2; /* red-100 */
    color: #991b1b; /* red-800 */
}

.badge-info {
    background-color: #dbeafe; /* blue-100 */
    color: #1e40af; /* blue-800 */
}

/* ========== Toast 알림 ========== */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 400px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    animation: slideIn 0.3s ease-out;
    border-left: 4px solid;
    min-width: 300px;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.toast.hiding {
    animation: slideOut 0.3s ease-out forwards;
}

.toast-success {
    border-left-color: #10b981; /* green-500 */
}

.toast-error {
    border-left-color: #ef4444; /* red-500 */
}

.toast-warning {
    border-left-color: #f59e0b; /* yellow-500 */
}

.toast-info {
    border-left-color: #3b82f6; /* blue-500 */
}

.toast-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.toast-success .toast-icon {
    color: #10b981;
}

.toast-error .toast-icon {
    color: #ef4444;
}

.toast-warning .toast-icon {
    color: #f59e0b;
}

.toast-info .toast-icon {
    color: #3b82f6;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.25rem;
}

.toast-message {
    font-size: 0.875rem;
    color: #6b7280;
}

.toast-close {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 0;
    font-size: 1.25rem;
    line-height: 1;
    flex-shrink: 0;
}

.toast-close:hover {
    color: #4b5563;
}

/* ========== 모달 ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.2s ease-out;
}

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

.modal {
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1f2937;
}

.modal-close {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 0;
    font-size: 1.5rem;
    line-height: 1;
}

.modal-close:hover {
    color: #4b5563;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* ========== 로딩 스피너 ========== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1rem;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e5e7eb;
    border-top-color: #4f46e5;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    color: white;
    font-size: 1rem;
    font-weight: 500;
}

/* ========== Empty State (빈 상태) ========== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #9ca3af;
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 0.5rem;
}

.empty-state-message {
    font-size: 0.875rem;
    color: #9ca3af;
}

/* ========== 반응형 유틸리티 ========== */
@media (max-width: 640px) {
    .toast-container {
        left: 1rem;
        right: 1rem;
        max-width: none;
    }

    .toast {
        min-width: auto;
    }

    .modal {
        max-width: none;
        margin: 0;
        border-radius: 0;
        max-height: 100vh;
    }
}
