/* ============================================
   Variables y Reset
   ============================================ */

:root {
    --primary-color: #ff0055;
    --accent-cyan: #00ffff;
    --accent-purple: #9d00ff;
    --accent-gold: #ffcc00;
    --dark-bg: #0a0a0a;
    --card-bg: #111111;
    --text-light: #f0f0f0;
    --text-gray: #b0b0b0;
    --border-color: rgba(255, 0, 85, 0.3);
    --success: #00ff88;
    --danger: #ff3333;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Montserrat', sans-serif;
    background: var(--dark-bg);
    color: var(--text-light);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Efecto de ruido de fondo */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.03'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 1;
    animation: noise 0.2s infinite;
}

@keyframes noise {
    0%, 100% { opacity: 0.03; }
    50% { opacity: 0.05; }
}

/* ============================================
   Header
   ============================================ */

.admin-header {
    background: linear-gradient(135deg, rgba(255, 0, 85, 0.1), rgba(0, 255, 255, 0.05));
    border-bottom: 2px solid var(--border-color);
    padding: 1.5rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 100%;
}

.admin-title {
    font-family: 'Playfair Display', serif;
    font-size: 2rem;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0.05em;
}

.btn-back {
    padding: 0.8rem 1.5rem;
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%);
    transition: var(--transition);
    font-size: 0.9rem;
}

.btn-back:hover {
    background: var(--primary-color);
    color: var(--text-light);
    box-shadow: 0 0 20px rgba(255, 0, 85, 0.6);
    transform: translateX(-5px);
}

/* ============================================
   Layout Principal
   ============================================ */

.admin-container {
    min-height: 100vh;
    position: relative;
    z-index: 2;
}

.admin-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    height: calc(100vh - 100px);
    gap: 0;
}

/* ============================================
   Sidebar de Hilos
   ============================================ */

.threads-sidebar {
    background: var(--card-bg);
    border-right: 2px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 0, 85, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-size: 1.2rem;
    color: var(--accent-cyan);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.btn-new-thread {
    padding: 0.6rem 1.2rem;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-purple));
    border: none;
    color: var(--text-light);
    font-weight: 700;
    cursor: pointer;
    clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 0 100%);
    transition: var(--transition);
    font-size: 0.9rem;
}

.btn-new-thread:hover {
    box-shadow: 0 0 20px rgba(255, 0, 85, 0.6);
    transform: scale(1.05);
}

.threads-filters {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 0, 85, 0.2);
}

.filter-btn {
    flex: 1;
    padding: 0.6rem;
    background: transparent;
    border: 1px solid rgba(255, 0, 85, 0.3);
    color: var(--text-gray);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.filter-btn.active {
    background: rgba(255, 0, 85, 0.2);
    border-color: var(--primary-color);
    color: var(--primary-color);
    box-shadow: 0 0 10px rgba(255, 0, 85, 0.3);
}

.filter-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.threads-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.thread-item {
    background: linear-gradient(135deg, rgba(255, 0, 85, 0.05), rgba(0, 255, 255, 0.03));
    border: 1px solid var(--border-color);
    padding: 1rem;
    margin-bottom: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
    clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%);
    position: relative;
}

.thread-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 15px rgba(255, 0, 85, 0.3);
    transform: translateX(5px);
}

.thread-item.active {
    background: linear-gradient(135deg, rgba(255, 0, 85, 0.15), rgba(0, 255, 255, 0.08));
    border-color: var(--accent-cyan);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.4);
}

.thread-item.completed {
    opacity: 0.6;
}

.thread-item.completed .thread-item-title {
    text-decoration: line-through;
}

.thread-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.thread-item-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 0.3rem;
    line-height: 1.3;
}

.thread-item-badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.thread-item-badge.open {
    background: rgba(0, 255, 136, 0.2);
    color: var(--success);
}

.thread-item-badge.completed {
    background: rgba(157, 0, 255, 0.2);
    color: var(--accent-purple);
}

.thread-item-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-gray);
}

.thread-item-author {
    color: var(--accent-cyan);
}

.thread-item-count {
    color: var(--text-gray);
}

/* ============================================
   Panel de Mensajes
   ============================================ */

.messages-panel {
    background: var(--dark-bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-gray);
}

.empty-state p {
    color: var(--text-gray);
    max-width: 400px;
}

.thread-view {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.thread-header {
    padding: 1.5rem 2rem;
    border-bottom: 2px solid var(--border-color);
    background: linear-gradient(135deg, rgba(255, 0, 85, 0.08), rgba(157, 0, 255, 0.05));
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.thread-info {
    flex: 1;
}

.thread-title {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-light);
}

.thread-status {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 0 100%);
}

.thread-status.open {
    background: rgba(0, 255, 136, 0.2);
    color: var(--success);
    border: 1px solid var(--success);
}

.thread-status.completed {
    background: rgba(157, 0, 255, 0.2);
    color: var(--accent-purple);
    border: 1px solid var(--accent-purple);
}

.thread-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    width: 40px;
    height: 40px;
    background: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 0 100%);
}

.btn-icon:hover {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.5);
    transform: scale(1.1);
}

.btn-icon.btn-danger:hover {
    border-color: var(--danger);
    box-shadow: 0 0 15px rgba(255, 51, 51, 0.5);
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    background: linear-gradient(to bottom, rgba(255, 0, 85, 0.02), transparent 20%);
}

.message {
    background: rgba(17, 17, 17, 0.8);
    border: 1px solid rgba(255, 0, 85, 0.2);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    clip-path: polygon(0 0, calc(100% - 15px) 0, 100% 15px, 100% 100%, 0 100%);
    transition: var(--transition);
}

.message:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 20px rgba(255, 0, 85, 0.2);
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 0, 85, 0.1);
}

.message-author {
    font-weight: 700;
    color: var(--accent-cyan);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.9rem;
}

.message-date {
    font-size: 0.8rem;
    color: var(--text-gray);
}

.message-content {
    color: var(--text-light);
    line-height: 1.8;
    white-space: pre-wrap;
}

/* ============================================
   Formulario de Mensaje
   ============================================ */

.message-form {
    background: var(--card-bg);
    border-top: 2px solid var(--border-color);
    padding: 1.5rem 2rem;
}

.form-row {
    margin-bottom: 1rem;
}

.author-select {
    width: 100%;
    padding: 0.8rem;
    background: rgba(255, 0, 85, 0.05);
    border: 2px solid var(--border-color);
    color: var(--text-light);
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: 'Montserrat', sans-serif;
}

.author-select:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.3);
}

.message-input {
    width: 100%;
    padding: 1rem;
    background: rgba(255, 0, 85, 0.05);
    border: 2px solid var(--border-color);
    color: var(--text-light);
    font-size: 0.95rem;
    resize: vertical;
    min-height: 80px;
    font-family: 'Montserrat', sans-serif;
    line-height: 1.6;
    transition: var(--transition);
}

.message-input:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.3);
}

.message-input::placeholder {
    color: var(--text-gray);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
}

.btn-send {
    padding: 0.8rem 2rem;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-purple));
    border: none;
    color: var(--text-light);
    font-weight: 700;
    cursor: pointer;
    clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%);
    transition: var(--transition);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.btn-send:hover {
    box-shadow: 0 0 25px rgba(255, 0, 85, 0.8);
    transform: scale(1.05);
}

.btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   Modal
   ============================================ */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    max-width: 600px;
    width: 90%;
    clip-path: polygon(0 0, calc(100% - 20px) 0, 100% 20px, 100% 100%, 0 100%);
    box-shadow: 0 0 50px rgba(255, 0, 85, 0.5);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, rgba(255, 0, 85, 0.1), rgba(0, 255, 255, 0.05));
}

.modal-header h3 {
    font-size: 1.3rem;
    color: var(--accent-cyan);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.close-modal {
    background: transparent;
    border: none;
    color: var(--text-light);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    transition: var(--transition);
}

.close-modal:hover {
    color: var(--primary-color);
    transform: rotate(90deg);
}

.modal-body {
    padding: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--accent-cyan);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.1em;
}

.form-input {
    width: 100%;
    padding: 0.8rem;
    background: rgba(255, 0, 85, 0.05);
    border: 2px solid var(--border-color);
    color: var(--text-light);
    font-size: 0.95rem;
    font-family: 'Montserrat', sans-serif;
    transition: var(--transition);
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.3);
}

textarea.form-input {
    resize: vertical;
    min-height: 100px;
    line-height: 1.6;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 2px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.btn-cancel,
.btn-create {
    padding: 0.8rem 1.5rem;
    border: none;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.btn-cancel {
    background: transparent;
    border: 2px solid var(--text-gray);
    color: var(--text-gray);
    clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 0 100%);
}

.btn-cancel:hover {
    border-color: var(--text-light);
    color: var(--text-light);
}

.btn-create {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-purple));
    color: var(--text-light);
    clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%);
}

.btn-create:hover {
    box-shadow: 0 0 25px rgba(255, 0, 85, 0.8);
    transform: scale(1.05);
}

/* ============================================
   Scrollbar Personalizado
   ============================================ */

.threads-list::-webkit-scrollbar,
.messages-container::-webkit-scrollbar {
    width: 8px;
}

.threads-list::-webkit-scrollbar-track,
.messages-container::-webkit-scrollbar-track {
    background: var(--dark-bg);
}

.threads-list::-webkit-scrollbar-thumb,
.messages-container::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--primary-color), var(--accent-purple));
    border-radius: 4px;
}

.threads-list::-webkit-scrollbar-thumb:hover,
.messages-container::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--accent-cyan), var(--primary-color));
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 968px) {
    .admin-layout {
        grid-template-columns: 1fr;
        height: auto;
    }

    .threads-sidebar {
        border-right: none;
        border-bottom: 2px solid var(--border-color);
        max-height: 400px;
    }

    .admin-title {
        font-size: 1.5rem;
    }

    .thread-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    .admin-header {
        padding: 1rem;
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .threads-filters {
        flex-direction: column;
    }

    .modal-content {
        width: 95%;
    }

    .modal-body {
        padding: 1rem;
    }
}
