/**
 * Extended Modals Styles
 * Extracted from index.css for better organization
 * Includes base modal styles, specific modals, and toasts
 */

/* --- MODALS (Estilo Base PC) --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    /* Keeping this for overlay effect */
    backdrop-filter: blur(5px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 150;
    /* Higher than sidebar (100) to display above it */
    padding: 20px;
}

.modal {
    background: var(--bg-panel);
    width: 100%;
    max-width: 500px;
    border-radius: 16px;
    border: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    height: auto;
    box-shadow: var(--shadow-heavy);
    overflow: hidden;
}

.modal-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-panel);
}

.modal-title {
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.9rem;
}

.close-icon {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0 5px;
    line-height: 1;
}

.close-icon:hover {
    color: var(--text-main);
}

.tabs-nav {
    display: flex;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-panel);
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-dim);
    padding: 12px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.8rem;
    transition: 0.2s;
}

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: var(--hover-light);
}

.tab-btn:hover {
    color: var(--text-main);
    background: var(--hover-light);
}

.modal-body {
    padding: 18px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    flex: 1;
}

.tab-content {
    display: none;
    animation: fadeIn 0.2s;
}

.tab-content.active {
    display: block;
}

/* Inputs de Modal */
.field label {
    font-size: 0.65rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.field input,
.field textarea {
    width: 100%;
    padding: 10px;
    font-size: 0.9rem;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    color: var(--text-main);
    outline: none;
}

.field input:focus,
.field textarea:focus {
    border-color: var(--accent);
}

.field textarea {
    min-height: 100px;
}

.key-list {
    gap: 6px;
    max-height: 160px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 2px 0;
}

.list-row {
    padding: 8px 12px;
    font-size: 0.85rem;
    background: var(--bg-input);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.list-row span {
    color: var(--text-main);
}

.row-del {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 1rem;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.row-del:hover {
    background: var(--hover-light);
    color: var(--accent);
}

.btn-primary {
    padding: 10px;
    font-size: 0.9rem;
    background: var(--bg-input);
    color: var(--gold-main);
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background: var(--hover-light);
    border-color: var(--gold-main);
    transform: translateY(-1px);
}

.btn-secondary {
    padding: 10px;
    font-size: 0.9rem;
    background: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    cursor: pointer;
}

.btn-secondary:hover {
    background: var(--hover-light);
}

.btn-danger {
    padding: 8px 14px;
    font-size: 0.9rem;
    background: var(--error);
    color: var(--text-main);
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.btn-danger:hover {
    opacity: 0.9;
}

/* Info Modal */
#info-modal .modal {
    max-width: 320px;
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
}

#info-modal .modal-header {
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-light);
}

#info-modal .modal-title {
    color: var(--text-main);
    font-weight: 600;
}

#info-modal p {
    color: var(--text-main);
    margin: 0;
    text-align: center;
}

/* Info modal type styles */
.modal.error {
    border-color: var(--error);
}

.modal.success {
    border-color: var(--success);
}

.modal.warning {
    border-color: var(--warning);
}

.modal.info {
    border-color: var(--accent);
}

#confirm-modal h3 {
    font-size: 1rem;
    color: var(--text-main);
    margin-bottom: 10px;
}

#confirm-modal p {
    color: var(--text-dim);
}

@media (max-width: 768px) {
    #confirm-modal .modal {
        width: calc(100vw - 40px);
        max-width: 320px;
    }
}

/* Specific handling for portrait orientation */
@media (max-width: 768px) and (orientation: portrait) {
    #confirm-modal .modal {
        width: 90vw;
        max-width: 320px;
    }
}

/* Historial Items */
.session-list {
    gap: 5px;
    display: flex;
    flex-direction: column;
}

.session-item {
    padding: 12px;
    background: var(--bg-input);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    border: 1px solid transparent;
}

.session-item:hover {
    background: var(--hover-light);
    border-color: var(--border-light);
}

.session-item.active {
    border-color: var(--accent);
    background: var(--hover-light);
}

.session-meta {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.session-title {
    font-size: 0.85rem;
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-date {
    font-size: 0.65rem;
    color: var(--text-dim);
    margin-top: 4px;
}

.row-del {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.row-del:hover {
    background: var(--hover-light);
    color: var(--accent);
}

/* Toasts */
/* Toasts (Mini Modales Flotantes) */
#toasts {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    /* Clicks pass through container */
    width: auto;
    max-width: 90%;
    align-items: center;
}

.toast {
    padding: 10px 20px;
    font-size: 0.85rem;
    background: var(--bg-panel);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-light);
    color: var(--text-main);
    border-radius: 50px;
    /* Pill shape */
    box-shadow: var(--shadow-medium);
    pointer-events: auto;
    /* Enable clicks on toast */
    animation: toastSlideDown 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.toast.error {
    border-color: var(--error);
    color: var(--error);
    background: var(--bg-panel);
}

.toast.success {
    border-color: var(--success);
    color: var(--success);
    background: var(--bg-panel);
}

.toast.info {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--bg-panel);
}

.toast.warning {
    border-color: var(--warning);
    color: var(--warning);
    background: var(--bg-panel);
}

@keyframes toastSlideDown {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastSlideUp {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    to {
        opacity: 0;
        transform: translateY(-20px) scale(0.9);
    }
}