/* ====== TOAST NOTIFICATION STYLES ====== */

.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
    max-width: 90vw;
}

@media (max-width: 768px) {
    .toast-container {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
        max-width: calc(100vw - 2rem);
    }
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(8px);
    animation: slideInRight 0.3s ease-out;
    max-width: 500px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

@media (max-width: 768px) {
    .toast {
        max-width: 100%;
        padding: 0.875rem;
        gap: 0.75rem;
    }
}

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

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

.toast--removing {
    animation: slideOutRight 0.3s ease-out forwards;
}

/* Toast variants */
.toast--success {
    background-color: rgba(34, 197, 94, 0.95);
    color: white;
    border-left: 4px solid #22c55e;
}

.toast--error {
    background-color: rgba(239, 68, 68, 0.95);
    color: white;
    border-left: 4px solid #ef4444;
}

.toast--warning {
    background-color: rgba(245, 158, 11, 0.95);
    color: white;
    border-left: 4px solid #f59e0b;
}

.toast--info {
    background-color: rgba(59, 130, 246, 0.95);
    color: white;
    border-left: 4px solid #3b82f6;
}

/* Dark mode variants */
[data-theme="dark"] .toast {
    background-color: rgba(30, 30, 30, 0.95);
}

[data-theme="dark"] .toast--success {
    background-color: rgba(34, 197, 94, 0.85);
    border-left-color: #86efac;
}

[data-theme="dark"] .toast--error {
    background-color: rgba(239, 68, 68, 0.85);
    border-left-color: #fca5a5;
}

[data-theme="dark"] .toast--warning {
    background-color: rgba(245, 158, 11, 0.85);
    border-left-color: #fcd34d;
}

[data-theme="dark"] .toast--info {
    background-color: rgba(59, 130, 246, 0.85);
    border-left-color: #93c5fd;
}

/* Toast content */
.toast__content {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.toast__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.2);
    font-weight: bold;
    font-size: 0.875rem;
}

.toast__message-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.toast__title {
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.3;
    word-break: break-word;
}

.toast__message {
    font-size: 0.875rem;
    opacity: 0.95;
    line-height: 1.4;
    word-break: break-word;
}

.toast__actionable {
    font-size: 0.8rem;
    opacity: 0.85;
    margin-top: 0.25rem;
    line-height: 1.4;
    word-break: break-word;
}

.toast__link {
    display: inline-block;
    margin-top: 0.25rem;
    font-size: 0.8rem;
    text-decoration: underline;
    opacity: 0.9;
    transition: opacity 0.2s;
}

.toast__link:hover {
    opacity: 1;
}

/* Toast buttons */
.toast__close,
.toast__retry {
    flex-shrink: 0;
    padding: 0.25rem;
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast__close:hover,
.toast__retry:hover {
    opacity: 1;
}

.toast__close svg {
    width: 1.25rem;
    height: 1.25rem;
    stroke-width: 2.5;
}

.toast__retry {
    padding: 0.4rem 0.8rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 0.25rem;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
}

.toast__retry:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* ====== FIELD ERROR STYLES ====== */

.has-error {
    position: relative;
}

.has-error input,
.has-error textarea,
.has-error select {
    border-color: #ef4444 !important;
    background-color: rgba(239, 68, 68, 0.05);
}

.has-error input:focus,
.has-error textarea:focus,
.has-error select:focus {
    outline-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

[data-theme="dark"] .has-error input,
[data-theme="dark"] .has-error textarea,
[data-theme="dark"] .has-error select {
    border-color: #fca5a5 !important;
    background-color: rgba(239, 68, 68, 0.08);
}

.field-error {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.8rem;
    color: #ef4444;
    line-height: 1.4;
    animation: slideDown 0.2s ease-out;
}

[data-theme="dark"] .field-error {
    color: #fca5a5;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-0.25rem);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ====== FORM-LEVEL ERROR MESSAGES ====== */

.form-errors {
    padding: 1rem;
    margin-bottom: 1.5rem;
    border-radius: 0.5rem;
    background-color: rgba(239, 68, 68, 0.1);
    border-left: 4px solid #ef4444;
}

[data-theme="dark"] .form-errors {
    background-color: rgba(239, 68, 68, 0.08);
    border-left-color: #fca5a5;
}

.form-errors__title {
    font-weight: 600;
    color: #dc2626;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

[data-theme="dark"] .form-errors__title {
    color: #fca5a5;
}

.form-errors__list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.form-errors__item {
    font-size: 0.875rem;
    color: #991b1b;
}

[data-theme="dark"] .form-errors__item {
    color: #fecaca;
}

.form-errors__item:before {
    content: "• ";
    margin-right: 0.5rem;
}

/* ====== SUCCESS MESSAGE STYLES ====== */

.form-success {
    padding: 1rem;
    margin-bottom: 1.5rem;
    border-radius: 0.5rem;
    background-color: rgba(34, 197, 94, 0.1);
    border-left: 4px solid #22c55e;
    color: #166534;
}

[data-theme="dark"] .form-success {
    background-color: rgba(34, 197, 94, 0.08);
    border-left-color: #86efac;
    color: #86efac;
}

.form-success__title {
    font-weight: 600;
    margin-bottom: 0.25rem;
    font-size: 0.95rem;
}

.form-success__message {
    font-size: 0.875rem;
    line-height: 1.4;
}

/* ====== LOADING STATE ====== */

.is-loading {
    pointer-events: none;
    opacity: 0.6;
}

.is-loading button {
    pointer-events: none;
}

/* ====== RETRY BUTTON ====== */

.btn-retry {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: #3b82f6;
    color: white;
    border: none;
    border-radius: 0.375rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.btn-retry:hover {
    background-color: #2563eb;
}

.btn-retry:active {
    transform: scale(0.98);
}

[data-theme="dark"] .btn-retry {
    background-color: #2563eb;
}

[data-theme="dark"] .btn-retry:hover {
    background-color: #1d4ed8;
}

.btn-retry:disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
}

/* ====== SPINNER ANIMATION ====== */

.spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    animation: spin 0.8s linear infinite;
}

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

/* ====== INLINE HELP TEXT ====== */

.help-text {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.8rem;
    color: #666;
    line-height: 1.4;
}

[data-theme="dark"] .help-text {
    color: #999;
}

.help-text a {
    color: #3b82f6;
    text-decoration: none;
    transition: text-decoration 0.2s;
}

.help-text a:hover {
    text-decoration: underline;
}

[data-theme="dark"] .help-text a {
    color: #93c5fd;
}

/* ====== RESPONSIVE ADJUSTMENTS ====== */

@media (max-width: 640px) {
    .toast {
        font-size: 0.875rem;
    }

    .toast__title {
        font-size: 0.875rem;
    }

    .toast__message,
    .toast__actionable {
        font-size: 0.75rem;
    }

    .form-errors,
    .form-success {
        padding: 0.75rem;
        margin-bottom: 1rem;
    }

    .form-errors__title,
    .form-success__title {
        font-size: 0.875rem;
    }

    .form-errors__item,
    .form-success__message {
        font-size: 0.8rem;
    }
}
