@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-bg: #0a0a0f;
    --secondary-bg: #1a1a2e;
    --card-bg: #16213e;
    --accent-primary: #0f3460;
    --accent-secondary: #e94560;
    --text-primary: #ffffff;
    --text-secondary: #b0b3b8;
    --text-muted: #8a8d93;
    --border-color: #2d3748;
    --hover-color: #1e293b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --info-color: #3b82f6;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, var(--primary-bg) 0%, var(--secondary-bg) 50%, var(--card-bg) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 20px;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 50%, rgba(15, 52, 96, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(233, 69, 96, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 80%, rgba(15, 52, 96, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: rgba(26, 26, 46, 0.9);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 40px;
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.02);
    backdrop-filter: blur(20px);
    position: relative;
    overflow: hidden;
}

.container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary), var(--accent-primary));
}

h1 {
    text-align: center;
    margin-bottom: 40px;
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    position: relative;
}

.subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 40px;
    font-weight: 400;
}

.input-section {
    margin-bottom: 40px;
}

.input-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 20px;
    background: var(--card-bg);
    border-radius: 12px;
    padding: 4px;
}

.input-tab {
    flex: 1;
    padding: 12px 20px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.input-tab.active {
    background: var(--accent-primary);
    color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(15, 52, 96, 0.3);
}

.input-tab:hover:not(.active) {
    background: var(--hover-color);
    color: var(--text-primary);
}

.input-content {
    display: none;
}

.input-content.active {
    display: block;
}

label {
    display: block;
    margin-bottom: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 14px;
    letter-spacing: 0.025em;
}

textarea {
    width: 100%;
    height: 250px;
    padding: 20px;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    transition: all 0.3s ease;
}

textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(15, 52, 96, 0.2);
}

.file-upload {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 250px;
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    background: var(--card-bg);
    transition: all 0.3s ease;
    cursor: pointer;
}

.file-upload:hover {
    border-color: var(--accent-primary);
    background: rgba(15, 52, 96, 0.1);
}

.file-upload.dragover {
    border-color: var(--accent-secondary);
    background: rgba(233, 69, 96, 0.1);
}

.file-upload input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.upload-content {
    text-align: center;
    pointer-events: none;
}

.upload-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 16px;
    opacity: 0.6;
}

.upload-text {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.upload-subtext {
    font-size: 14px;
    color: var(--text-muted);
}

.controls {
    display: flex;
    gap: 16px;
    margin-bottom: 40px;
    flex-wrap: wrap;
    align-items: center;
}

.controls-main {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

button {
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: var(--text-primary);
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    position: relative;
    overflow: hidden;
}

button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

button:hover::before {
    left: 100%;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(15, 52, 96, 0.4);
}

button:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--hover-color);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.filters {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
}

.filter-checkbox:hover {
    background: var(--hover-color);
    border-color: var(--accent-primary);
}

.filter-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-secondary);
}

.filter-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.search-filter input {
    padding: 8px 12px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    width: 200px;
}

.search-filter input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(15, 52, 96, 0.2);
}

.output-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    max-height: 700px;
    overflow-y: auto;
}

.log-entry {
    margin-bottom: 16px;
    padding: 16px;
    border-radius: 8px;
    border-left: 3px solid var(--accent-primary);
    background: rgba(26, 26, 46, 0.8);
    transition: all 0.3s ease;
    position: relative;
}

.log-entry::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, transparent, rgba(255,255,255,0.02));
    border-radius: 8px;
    pointer-events: none;
}

.log-entry:hover {
    background: rgba(30, 41, 62, 0.8);
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.log-header {
    display: flex;
    gap: 16px;
    margin-bottom: 10px;
    font-size: 13px;
    opacity: 0.9;
    flex-wrap: wrap;
    align-items: center;
}

.character-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--accent-primary);
    object-fit: cover;
    flex-shrink: 0;
}

.timestamp {
    color: var(--accent-secondary);
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

.character-name {
    color: var(--text-primary);
    font-weight: 600;
}

.communication-type {
    background: rgba(15, 52, 96, 0.3);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.log-content {
    line-height: 1.7;
    color: var(--text-primary);
    font-size: 14px;
}

/* Communication type specific styling */
.say { border-left-color: var(--success-color); }
.emote { border-left-color: var(--warning-color); }
.looc { border-left-color: var(--error-color); }
.ooc { border-left-color: var(--info-color); }

.say .communication-type { background: rgba(16, 185, 129, 0.2); }
.emote .communication-type { background: rgba(245, 158, 11, 0.2); }
.looc .communication-type { background: rgba(239, 68, 68, 0.2); }
.ooc .communication-type { background: rgba(59, 130, 246, 0.2); }

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 0;
    max-width: 800px;
    width: 90%;
    max-height: 80%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 30px;
    border-bottom: 1px solid var(--border-color);
    background: var(--card-bg);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: var(--error-color);
    color: var(--text-primary);
    transform: none;
    box-shadow: none;
}

.modal-body {
    padding: 30px;
    max-height: 60vh;
    overflow-y: auto;
}

.character-photo-item {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 16px;
    transition: all 0.3s ease;
}

.character-photo-item:hover {
    background: var(--hover-color);
    border-color: var(--accent-primary);
}

.character-photo-preview {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid var(--accent-primary);
    object-fit: cover;
    background: var(--secondary-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.character-photo-preview.no-image {
    color: var(--text-muted);
    font-size: 12px;
    text-align: center;
}

.character-photo-info {
    flex: 1;
}

.character-photo-name {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.character-photo-actions {
    display: flex;
    gap: 8px;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 6px;
}

.photo-upload {
    position: relative;
    overflow: hidden;
    display: inline-block;
}

.photo-upload input[type="file"] {
    position: absolute;
    left: -9999px;
}

/*  Color span classes with readable contrast */
.clr_red { color: #ff6b6b; font-weight: 500; }
.clr_lred { color: #ff8e8e; font-weight: 500; }
.clr_dred { color: #e55555; font-weight: 500; }
.clr_ora { color: #ff922b; font-weight: 500; }
.clr_lora { color: #ffc078; font-weight: 500; }
.clr_dora { color: #fd7e14; font-weight: 500; }
.clr_yel { color: #ffd43b; font-weight: 500; }
.clr_lyel { color: #fff3bf; font-weight: 500; }
.clr_dyel { color: #fab005; font-weight: 500; }
.clr_gre { color: #51cf66; font-weight: 500; }
.clr_lgre { color: #8ce99a; font-weight: 500; }
.clr_dgre { color: #40c057; font-weight: 500; }
.clr_blu { color: #4dabf7; font-weight: 500; }
.clr_lblu { color: #74c0fc; font-weight: 500; }
.clr_dblu { color: #339af0; font-weight: 500; }
.clr_ind { color: #845ef7; font-weight: 500; }
.clr_vio { color: #cc5de8; font-weight: 500; }
.clr_dind { color: #7048e8; font-weight: 500; }
.clr_pur { color: #d0bfff; font-weight: 500; }
.clr_pin { color: #f783ac; font-weight: 500; }
.clr_dpin { color: #e64980; font-weight: 500; }
.clr_cya { color: #22d3ee; font-weight: 500; }
.clr_turq { color: #15aabf; font-weight: 500; }
.clr_teal { color: #12b886; font-weight: 500; }

.hidden {
    display: none;
}

.stats {
    margin-bottom: 24px;
    padding: 20px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.stat-item {
    color: var(--text-secondary);
    font-size: 14px;
}

.stat-value {
    color: var(--accent-secondary);
    font-weight: 600;
    font-size: 16px;
}

/* Custom scrollbar */
.output-section::-webkit-scrollbar,
.modal-body::-webkit-scrollbar {
    width: 8px;
}

.output-section::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track {
    background: var(--card-bg);
    border-radius: 4px;
}

.output-section::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
    border-radius: 4px;
}

.output-section::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--accent-secondary);
}

.loading {
    display: none;
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.loading.show {
    display: block;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--accent-secondary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--error-color);
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}

.success-message {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--success-color);
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}

@media (max-width: 768px) {
    .container {
        margin: 10px;
        padding: 24px;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .controls-main {
        justify-content: center;
    }
    
    .filters {
        justify-content: center;
    }

    .input-tabs {
        flex-direction: column;
    }

    .log-header {
        flex-direction: column;
        gap: 8px;
    }

    .search-filter input {
        width: 100%;
    }

    .modal-content {
        width: 95%;
        max-height: 90%;
    }

    .modal-header {
        padding: 20px;
    }

    .modal-body {
        padding: 20px;
    }

    .character-photo-item {
        flex-direction: column;
        text-align: center;
    }

    .character-photo-actions {
        justify-content: center;
    }
}