/**
 * Error Handling and Loading States CSS
 * 오류 처리 및 로딩 상태 스타일
 */

/* Loading States */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    min-height: 200px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-message {
    color: #666;
    font-size: 14px;
    text-align: center;
}

.loading-timeout {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
}

.timeout-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.timeout-message {
    color: #e74c3c;
    font-size: 16px;
    margin-bottom: 1rem;
}

.retry-btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

.retry-btn:hover {
    background: #2980b9;
}

/* Error Modal */
.error-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.error-modal.show {
    opacity: 1;
}

.error-content {
    background: white;
    border-radius: 8px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.error-modal.show .error-content {
    transform: scale(1);
}

.error-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.error-icon.network {
    color: #f39c12;
}

.error-icon.authentication {
    color: #c0392b;
}

.error-icon.game {
    color: #9b59b6;
}

.error-icon.generic {
    color: #95a5a6;
}

.error-title {
    color: #2c3e50;
    margin-bottom: 1rem;
    font-size: 1.5rem;
    font-weight: 600;
}

.error-message {
    color: #c0392b;
    margin-bottom: 2rem;
    line-height: 1.5;
    background: #fdf2f2;
    padding: 1rem;
    border-radius: 6px;
    border-left: 4px solid #e74c3c;
}

.error-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.error-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    min-width: 100px;
}

.error-btn.primary {
    background: #3498db;
    color: white;
}

.error-btn.primary:hover {
    background: #2980b9;
    transform: translateY(-1px);
}

.error-btn.secondary {
    background: #95a5a6;
    color: white;
}

.error-btn.secondary:hover {
    background: #7f8c8d;
    transform: translateY(-1px);
}

/* Notification System */
.notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    max-width: 400px;
}

.notification {
    background: white;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 10px;
    overflow: hidden;
    transform: translateX(100%);
    animation: slideIn 0.3s ease forwards;
}

@keyframes slideIn {
    to {
        transform: translateX(0);
    }
}

.notification.success {
    border-left: 4px solid #27ae60;
}

.notification.error {
    border-left: 4px solid #e74c3c;
}

.notification.warning {
    border-left: 4px solid #f39c12;
}

.notification.info {
    border-left: 4px solid #3498db;
}

.notification-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
}

.notification-message {
    flex: 1;
    color: #2c3e50;
    font-size: 14px;
}

.notification-close {
    background: none;
    border: none;
    font-size: 18px;
    color: #95a5a6;
    cursor: pointer;
    padding: 0;
    margin-left: 1rem;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notification-close:hover {
    color: #7f8c8d;
}

/* Game Loading States */
.game-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.game-loading .loading-content {
    text-align: center;
}

.game-loading .loading-title {
    font-size: 1.2rem;
    color: #2c3e50;
    margin-bottom: 1rem;
}

.game-loading .loading-progress {
    width: 200px;
    height: 4px;
    background: #ecf0f1;
    border-radius: 2px;
    overflow: hidden;
    margin: 1rem auto;
}

.game-loading .loading-bar {
    height: 100%;
    background: #3498db;
    border-radius: 2px;
    animation: loadingProgress 2s ease-in-out infinite;
}

@keyframes loadingProgress {
    0% {
        width: 0%;
        transform: translateX(-100%);
    }
    50% {
        width: 100%;
        transform: translateX(0%);
    }
    100% {
        width: 100%;
        transform: translateX(100%);
    }
}

/* Enhanced Game Result UI */
.points-animate {
    animation: pointsSuccess 1s ease-out;
}

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

.points-success h3 {
    color: #27ae60;
    margin-bottom: 1rem;
}

.points-breakdown {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.points-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    border-radius: 4px;
    background: #f8f9fa;
}

.points-item.earned {
    background: #d4edda;
    border: 1px solid #c3e6cb;
}

.points-item.total {
    background: #cce5ff;
    border: 1px solid #99d6ff;
}

.points-item.remaining {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
}

.points-item.remaining .value.exhausted {
    color: #e74c3c;
    font-weight: bold;
}

.points-label {
    font-weight: 500;
    color: #495057;
}

.points-value {
    font-weight: bold;
    color: #2c3e50;
}

.points-error-content {
    text-align: center;
    padding: 1rem;
}

.points-error-content h3 {
    color: #e74c3c;
    margin-bottom: 1rem;
}

.error-message {
    color: #6c757d;
    margin-bottom: 1rem;
}

.error-actions {
    display: flex;
    justify-content: center;
}

/* Responsive Design */
@media (max-width: 768px) {
    .error-content {
        margin: 1rem;
        padding: 1.5rem;
    }
    
    .error-title {
        font-size: 1.3rem;
    }
    
    .error-icon {
        font-size: 3rem;
    }
    
    .error-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .error-btn {
        width: 100%;
        max-width: 200px;
        margin-bottom: 0.5rem;
    }
    
    .notification-container {
        left: 10px;
        right: 10px;
        max-width: none;
    }
    
    .notification {
        margin-bottom: 5px;
    }
    
    .notification-content {
        padding: 0.75rem;
    }
    
    .notification-message {
        font-size: 13px;
    }
    
    .points-breakdown {
        gap: 0.25rem;
    }
    
    .points-item {
        padding: 0.375rem;
        font-size: 0.9rem;
    }
    
    .loading-container {
        padding: 1.5rem;
    }
    
    .loading-spinner {
        width: 35px;
        height: 35px;
    }
    
    .loading-message {
        font-size: 13px;
    }
    
    .game-loading .loading-title {
        font-size: 1rem;
    }
    
    .game-loading .loading-progress {
        width: 150px;
    }
}

@media (max-width: 480px) {
    .error-content {
        margin: 0.5rem;
        padding: 1rem;
        width: 95%;
    }
    
    .error-title {
        font-size: 1.2rem;
        margin-bottom: 0.75rem;
    }
    
    .error-icon {
        font-size: 2.5rem;
        margin-bottom: 0.75rem;
    }
    
    .error-message {
        font-size: 13px;
        padding: 0.5rem;
        margin-bottom: 1rem;
    }
    
    .error-btn {
        padding: 0.6rem 1.2rem;
        font-size: 0.85rem;
        max-width: 180px;
    }
    
    .notification-container {
        top: 10px;
        left: 5px;
        right: 5px;
    }
    
    .notification-content {
        padding: 0.6rem;
    }
    
    .notification-message {
        font-size: 12px;
    }
    
    .notification-close {
        width: 18px;
        height: 18px;
        font-size: 16px;
    }
    
    .loading-container {
        padding: 1rem;
        min-height: 150px;
    }
    
    .loading-spinner {
        width: 30px;
        height: 30px;
        border-width: 3px;
    }
    
    .loading-message {
        font-size: 12px;
    }
    
    .timeout-icon {
        font-size: 2.5rem;
    }
    
    .timeout-message {
        font-size: 14px;
    }
    
    .retry-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }
    
    .game-loading .loading-title {
        font-size: 0.9rem;
        margin-bottom: 0.75rem;
    }
    
    .game-loading .loading-progress {
        width: 120px;
        height: 3px;
    }
    
    .points-item {
        flex-direction: column;
        text-align: center;
        gap: 0.25rem;
        padding: 0.4rem 0.5rem;
    }
    
    .points-label {
        font-size: 0.8rem;
    }
    
    .points-value {
        font-size: 0.9rem;
    }
}

@media (max-width: 360px) {
    .error-content {
        margin: 0.25rem;
        padding: 0.75rem;
        width: 98%;
    }
    
    .error-title {
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
    }
    
    .error-icon {
        font-size: 2rem;
        margin-bottom: 0.5rem;
    }
    
    .error-message {
        font-size: 12px;
        padding: 0.5rem;
        margin-bottom: 1rem;
    }
    
    .error-btn {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
        max-width: 150px;
    }
    
    .loading-container {
        padding: 0.75rem;
        min-height: 120px;
    }
    
    .loading-spinner {
        width: 25px;
        height: 25px;
        border-width: 2px;
    }
    
    .loading-message {
        font-size: 11px;
    }
    
    .game-loading .loading-title {
        font-size: 0.85rem;
    }
    
    .game-loading .loading-progress {
        width: 100px;
    }
    
    .points-item {
        padding: 0.35rem 0.4rem;
    }
    
    .points-label {
        font-size: 0.75rem;
    }
    
    .points-value {
        font-size: 0.85rem;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .loading-spinner {
        animation: none;
    }
    
    .notification {
        animation: none;
        transform: translateX(0);
    }
    
    .error-modal,
    .error-content {
        transition: none;
    }
    
    .points-animate {
        animation: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .error-modal {
        background: rgba(0, 0, 0, 0.9);
    }
    
    .error-content {
        border: 2px solid #000;
    }
    
    .notification {
        border: 1px solid #000;
    }
}