/* Error States and Empty States Styling */

/* Base states container styling */
.error-state-container,
.empty-state-container,
.loading-state-container {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    padding: 2rem 1rem;
}

/* Error State */
.error-state {
    text-align: center;
    max-width: 400px;
    animation: slideInUp 0.4s ease-out;
    width: 100%;
}

.error-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    display: block;
    animation: bounce 0.6s ease-out;
}

.error-state-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-error, #ef4444);
    margin-bottom: 0.5rem;
    word-break: break-word;
}

.error-state-message {
    color: var(--color-text-secondary, #666);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 1.5rem;
    word-break: break-word;
}

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

.error-dismiss-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--color-text-secondary, #999);
    transition: color 0.2s;
    padding: 0.5rem;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.error-dismiss-btn:hover {
    color: var(--color-text, #333);
}

/* Empty State */
.empty-state {
    text-align: center;
    max-width: 400px;
    animation: slideInUp 0.4s ease-out;
    width: 100%;
}

.empty-state-icon {
    font-size: 8rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    width: 100%;
    animation: float 3s ease-in-out infinite;
}

@media (max-width: 768px) {
    .empty-state-icon {
        font-size: 6rem;
        height: 150px;
    }
}

@media (max-width: 480px) {
    .empty-state-icon {
        font-size: 5rem;
        height: 120px;
    }
}

.empty-state-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-text, #333);
    margin-bottom: 0.5rem;
    word-break: break-word;
}

.empty-state-message {
    color: var(--color-text-secondary, #666);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 1.5rem;
    word-break: break-word;
}

.empty-state-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Loading State */
.loading-state {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

.loading-message {
    font-size: 0.95rem;
    color: var(--color-text-secondary, #666);
    font-weight: 500;
}

.loading-progress {
    width: 100%;
    max-width: 200px;
    height: 4px;
    background: var(--color-border, #e5e7eb);
    border-radius: 2px;
    overflow: hidden;
}

.loading-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary, #3b82f6), var(--color-primary-light, #60a5fa));
    animation: progress 2s ease-in-out infinite;
}

/* Multiple Loading Spinner Styles */
.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.loading-spinner-ring {
    width: 3rem;
    height: 3rem;
    border: 3px solid var(--color-border, #e5e7eb);
    border-top-color: var(--color-primary, #3b82f6);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-spinner-dots {
    display: flex;
    gap: 0.3rem;
    align-items: flex-end;
}

.loading-dot {
    width: 0.5rem;
    height: 0.5rem;
    background: var(--color-primary, #3b82f6);
    border-radius: 50%;
    animation: bounce-dots 1.4s infinite;
}

.loading-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dot:nth-child(3) {
    animation-delay: 0.4s;
}

.loading-spinner-pulse {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background: var(--color-primary, #3b82f6);
    animation: pulse 2s ease-in-out infinite;
}

.loading-spinner-bars {
    display: flex;
    gap: 0.25rem;
    align-items: flex-end;
    height: 2rem;
}

.loading-bar {
    width: 0.35rem;
    background: var(--color-primary, #3b82f6);
    border-radius: 2px;
    animation: bar-bounce 1.2s infinite;
}

.loading-bar:nth-child(1) {
    height: 60%;
    animation-delay: -0.36s;
}

.loading-bar:nth-child(2) {
    height: 80%;
    animation-delay: -0.24s;
}

.loading-bar:nth-child(3) {
    height: 100%;
    animation-delay: -0.12s;
}

/* Skeleton Loading */
.loading-skeleton {
    background: var(--color-border, #e5e7eb);
    border-radius: 0.5rem;
    animation: skeleton-loading 1.5s ease-in-out infinite;
}

.loading-skeleton-line {
    height: 0.75rem;
    margin-bottom: 0.5rem;
    width: 100%;
}

.loading-skeleton-circle {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    margin: 0 auto 0.5rem;
}

/* Dark mode support */
:root.dark-mode .error-state-title,
:root.dark-mode .empty-state-title {
    color: inherit;
}

:root.dark-mode .error-state-message,
:root.dark-mode .empty-state-message,
:root.dark-mode .loading-message {
    color: var(--color-text-secondary, #aaa);
}

/* Animations */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes bounce {
    0% {
        transform: scale(0.8) translateY(-10px);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

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

@keyframes progress {
    0% {
        width: 0;
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
    }
    50% {
        width: 100%;
    }
    100% {
        width: 0;
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    }
}

@keyframes bounce-dots {
    0%, 60%, 100% {
        height: 0.5rem;
        opacity: 0.5;
    }
    30% {
        height: 1rem;
        opacity: 1;
    }
}

@keyframes bar-bounce {
    0%, 100% {
        height: 40%;
    }
    50% {
        height: 100%;
    }
}

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

@keyframes skeleton-loading {
    0%, 100% {
        background: var(--color-border, #e5e7eb);
    }
    50% {
        background: var(--color-border-light, #f3f4f6);
    }
}

/* Button styles for error/empty states */
.error-action-btn,
.empty-action-btn,
.error-report-btn {
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    border: none;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 44px;
    min-width: 44px;
    font-size: 0.95rem;
}

.error-action-btn:hover,
.empty-action-btn:hover,
.error-report-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.error-action-btn:active,
.empty-action-btn:active,
.error-report-btn:active {
    transform: translateY(0);
}

/* Error Report Modal */
.error-report-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.error-report-modal.active {
    display: flex;
}

.error-report-content {
    background: var(--color-bg, #fff);
    border-radius: 0.75rem;
    padding: 2rem;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    animation: slideInUp 0.3s ease-out;
}

.error-report-header {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.error-report-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--color-text-secondary, #999);
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.error-report-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 500;
    font-size: 0.9rem;
}

.form-group input,
.form-group textarea {
    padding: 0.75rem;
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: 0.5rem;
    font-family: inherit;
    font-size: 0.95rem;
    background: var(--color-input-bg, #fff);
    color: var(--color-text, #333);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.error-report-submit {
    padding: 0.75rem 1.5rem;
    background: var(--color-primary, #3b82f6);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 44px;
}

.error-report-submit:hover {
    background: var(--color-primary-dark, #2563eb);
    transform: translateY(-2px);
}

.error-report-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Responsive Design */
@media (max-width: 768px) {
    .error-state-container,
    .empty-state-container,
    .loading-state-container {
        min-height: 250px;
        padding: 1rem;
    }

    .error-state,
    .empty-state {
        width: 100%;
    }

    .error-state-icon,
    .empty-state-icon {
        font-size: 3rem;
    }

    .error-state-title,
    .empty-state-title {
        font-size: 1.25rem;
    }

    .error-state-message,
    .empty-state-message {
        font-size: 0.9rem;
    }

    .error-state-actions,
    .empty-state-actions {
        gap: 0.5rem;
    }

    .error-action-btn,
    .empty-action-btn,
    .error-report-btn {
        padding: 0.7rem 1.25rem;
        font-size: 0.9rem;
        flex: 1;
        min-width: unset;
    }

    .error-report-content {
        padding: 1.5rem;
        border-radius: 0.5rem;
    }

    .error-report-header {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .error-state-container,
    .empty-state-container,
    .loading-state-container {
        min-height: 200px;
        padding: 1rem 0.75rem;
    }

    .error-state,
    .empty-state {
        max-width: 100%;
    }

    .error-state-icon,
    .empty-state-icon {
        font-size: 2.5rem;
        margin-bottom: 0.75rem;
    }

    .error-state-title,
    .empty-state-title {
        font-size: 1.1rem;
        margin-bottom: 0.375rem;
    }

    .error-state-message,
    .empty-state-message {
        font-size: 0.85rem;
        margin-bottom: 1rem;
    }

    .error-state-actions,
    .empty-state-actions {
        flex-direction: column;
        gap: 0.5rem;
    }

    .error-action-btn,
    .empty-action-btn,
    .error-report-btn {
        width: 100%;
        padding: 0.7rem 1rem;
        font-size: 0.85rem;
    }

    .loading-spinner-ring {
        width: 2rem;
        height: 2rem;
        border-width: 2px;
    }

    .error-report-content {
        max-width: 95%;
        padding: 1.25rem;
    }

    .error-report-close {
        top: 0.75rem;
        right: 0.75rem;
    }
}

/* Integration with existing components */
.calendar-view.empty .calendar-grid,
.task-list.empty .task-items,
.goals-list.empty .goals-cards,
.achievements-grid.empty .achievement-item {
    display: none;
}

/* Graceful error in specific contexts */
.event-item.error,
.task-item.error,
.goal-card.error {
    border-left: 3px solid var(--color-error, #ef4444);
    background: rgba(239, 68, 68, 0.05);
    opacity: 0.7;
}

.event-item.error::after {
    content: ' (Failed to save)';
    color: var(--color-error, #ef4444);
    font-size: 0.8rem;
    font-weight: 600;
}
