/* Main CSS for Dungeon Daemon Frontend */

:root {
    --primary-color: #8b4513;
    --secondary-color: #d4af37;
    --accent-color: #a0522d;
    --background-color: #1a0f0a;
    --text-color: #f4f1eb;
    --border-color: #5d3317;
    --hover-color: #cd853f;
    --error-color: #dc2626;
    --success-color: #059669;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Georgia', 'Times New Roman', serif;
    background: linear-gradient(135deg, #1a0f0a 0%, #2c1810 50%, #1a0f0a 100%);
    color: var(--text-color);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    text-align: center;
    margin-bottom: 40px;
    padding: 20px 0;
    border-bottom: 2px solid var(--border-color);
    display: block !important;
    visibility: visible !important;
    z-index: 10;
    position: relative;
}

.header h1 {
    font-size: 2.5rem;
    color: var(--secondary-color);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    margin-bottom: 10px;
}

.header p {
    font-size: 1.1rem;
    color: var(--text-color);
    opacity: 0.8;
}

/* World Selection Grid */
.worlds-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 30px;
    margin: 40px 0;
}

.world-card {
    background: rgba(25, 15, 10, 0.8);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

.world-card:hover {
    border-color: var(--secondary-color);
    box-shadow: 0 8px 25px rgba(212, 175, 55, 0.3);
    transform: translateY(-5px);
}

.world-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: var(--primary-color);
}

.world-content {
    padding: 20px;
}

.world-title {
    font-size: 1.4rem;
    color: var(--secondary-color);
    margin-bottom: 10px;
    font-weight: bold;
}

.world-description {
    color: var(--text-color);
    opacity: 0.9;
    margin-bottom: 15px;
}

.world-blurb {
    color: var(--text-color);
    opacity: 0.7;
    font-style: italic;
    font-size: 0.9rem;
}

/* Character and Session Selection */
.selection-section {
    background: rgba(25, 15, 10, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 25px;
    margin: 20px 0;
}

.selection-section h2 {
    color: var(--secondary-color);
    margin-bottom: 20px;
    font-size: 1.3rem;
}

.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.character-card {
    background: rgba(15, 10, 5, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.character-card:hover {
    border-color: var(--secondary-color);
    background: rgba(15, 10, 5, 1);
}

.character-card.selected {
    border-color: var(--secondary-color);
    background: rgba(212, 175, 55, 0.1);
}

.character-card-new {
    border-color: var(--secondary-color);
    background: rgba(212, 175, 55, 0.05);
    border-style: dashed;
    text-align: center;
    position: relative;
}

.character-card-new:hover {
    background: rgba(212, 175, 55, 0.15);
    border-color: var(--hover-color);
}

.character-name {
    color: var(--secondary-color);
    font-weight: bold;
    margin-bottom: 5px;
}

.character-details {
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.8;
}

.session-list {
    max-height: 300px;
    overflow-y: auto;
    margin: 20px 0;
}

.session-item {
    background: rgba(15, 10, 5, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 12px 15px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.session-item:hover {
    border-color: var(--secondary-color);
    background: rgba(15, 10, 5, 0.8);
}

.session-item-new {
    border-color: var(--success-color);
    background: rgba(5, 150, 105, 0.05);
    border-style: dashed;
    text-align: center;
    margin-bottom: 20px;
    position: relative;
}

.session-item-new:hover {
    background: rgba(5, 150, 105, 0.15);
    border-color: #047857;
}

.session-title {
    color: var(--secondary-color);
    font-weight: bold;
    margin-bottom: 3px;
}

.session-meta {
    font-size: 0.8rem;
    color: var(--text-color);
    opacity: 0.7;
}

/* Chat Interface */
.chat-container {
    background: rgba(25, 15, 10, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    height: calc(100vh - 120px);
    min-height: 400px;
    display: flex;
    flex-direction: column;
}

/* Apply mobile-optimized layout for all screen sizes */
.chat-container {
    height: calc(100vh - 140px);
    min-height: 350px;
}

.container {
    padding: 3px 10px;
}

/* Hide entire header section on session pages only */
.session-page .header {
    display: none !important;
}

.nav {
    padding: 4px 0;
    margin-bottom: 6px;
}

.nav-brand {
    font-size: 0.8rem;
    background: var(--secondary-color);
    color: var(--background-color);
    border-radius: 3px;
    padding: 4px 8px;
    text-decoration: none;
    display: inline-block;
    transition: all 0.2s ease;
}

.nav-brand:hover {
    background: var(--hover-color);
}

.nav-links a {
    padding: 4px 6px;
    font-size: 0.7rem;
}

.chat-header {
    padding: 8px 12px;
}

.chat-input {
    padding: 12px;
}

.chat-input input,
.chat-input textarea {
    padding: 12px 15px;
    font-size: 1.08rem;
    min-height: 40px;
    resize: vertical;
    font-family: inherit;
    line-height: 1.4;
}

.btn {
    padding: 10px 12px;
    font-size: 0.98rem;
}

/* Hide session actions */
.flex-center.gap-10.mt-20 {
    display: none !important;
}

/* Optimized text sizing */
body {
    font-size: 0.93rem;
}

.message-content {
    font-size: 0.93rem;
}


.header h1 {
    font-size: 1.2rem;
    margin-bottom: 0 !important;
}

/* Hide redundant session info */
#session-info {
    display: none !important;
}

.chat-header {
    background: rgba(15, 10, 5, 0.8);
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    border-radius: 8px 8px 0 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.message {
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease;
}

.message-user {
    text-align: right;
}

.message-content {
    display: inline-block;
    max-width: 80%;
    padding: 12px 18px;
    border-radius: 15px;
    word-wrap: break-word;
}

.message-user .message-content {
    background: var(--primary-color);
    color: white;
}

.message-assistant .message-content {
    background: rgba(15, 10, 5, 0.8);
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

.message-premise .message-content {
    background: rgba(212, 175, 55, 0.1);
    border: 1px solid var(--secondary-color);
    color: var(--secondary-color);
    font-style: italic;
}

.chat-input {
    display: flex;
    padding: 20px;
    border-top: 1px solid var(--border-color);
    gap: 10px;
}

.chat-input-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.input-group {
    display: flex;
    gap: 10px;
    width: 100%;
}

.chat-input input,
.chat-input textarea {
    flex: 1;
    padding: 12px 15px;
    background: rgba(15, 10, 5, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-color);
    font-size: 1.08rem;
    font-family: inherit;
    line-height: 1.4;
}

.chat-input input:focus,
.chat-input textarea:focus {
    outline: none;
    border-color: var(--secondary-color);
}

/* Buttons */
.btn {
    padding: 12px 24px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.08rem;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn:hover {
    background: var(--hover-color);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--secondary-color);
    color: var(--background-color);
}

.btn-secondary:hover {
    background: var(--hover-color);
}

.btn-danger {
    background: var(--error-color);
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-success {
    background: var(--success-color);
}

.btn-success:hover {
    background: #047857;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    color: var(--secondary-color);
    margin-bottom: 5px;
    font-weight: bold;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    background: rgba(15, 10, 5, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-color);
    font-size: 1rem;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--secondary-color);
}

/* Admin Tables */
.admin-table {
    width: 100%;
    background: rgba(25, 15, 10, 0.6);
    border-collapse: collapse;
    margin: 20px 0;
    border-radius: 8px;
    overflow: hidden;
}

.admin-table th,
.admin-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.admin-table th {
    background: rgba(15, 10, 5, 0.8);
    color: var(--secondary-color);
    font-weight: bold;
}

.admin-table tr:hover {
    background: rgba(15, 10, 5, 0.4);
}

/* Loading and Status */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--secondary-color);
}

.error-message {
    background: rgba(220, 38, 38, 0.1);
    border: 1px solid var(--error-color);
    color: var(--error-color);
    padding: 15px;
    border-radius: 6px;
    margin: 20px 0;
}

.success-message {
    background: rgba(5, 150, 105, 0.1);
    border: 1px solid var(--success-color);
    color: var(--success-color);
    padding: 15px;
    border-radius: 6px;
    margin: 20px 0;
}

/* Navigation */
.nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 30px;
}

.nav-brand {
    font-size: 1.2rem;
    color: var(--background-color);
    background: var(--secondary-color);
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: bold;
    text-decoration: none;
    display: inline-block;
    transition: all 0.2s ease;
}

.nav-brand:hover {
    background: var(--hover-color);
    color: var(--background-color);
}

.nav-links {
    display: flex;
    gap: 20px;
}

.nav-links a {
    color: var(--text-color);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.nav-links a:hover {
    background: rgba(212, 175, 55, 0.1);
    color: var(--secondary-color);
}

/* Responsive Design - Additional mobile-specific styles */
@media (max-width: 768px) {
    .worlds-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .character-grid {
        grid-template-columns: 1fr;
    }

    /* Compact chat header layout on mobile */
    .chat-header > div {
        flex-direction: column !important;
        gap: 5px !important;
    }

    #chat-session-id {
        font-size: 0.7rem !important;
    }

    /* Keep world name in chat header on mobile */
    #chat-world-name,
    #world-separator {
        display: inline !important;
    }

    /* Compact navigation layout */
    .nav {
        flex-direction: row;
        gap: 10px;
    }

    .nav-links {
        gap: 10px;
    }
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background: var(--background-color);
    border: 2px solid var(--secondary-color);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease-out;
}

.modal-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: var(--secondary-color);
    font-size: 1.3rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-color);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--secondary-color);
}

.modal-body {
    padding: 24px;
}

.modal-body p {
    margin: 0 0 20px 0;
    color: var(--text-color);
    line-height: 1.5;
}

.modal-footer {
    padding: 16px 24px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.modal-footer .btn {
    min-width: 100px;
}

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

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mb-20 {
    margin-bottom: 20px;
}

.mt-20 {
    margin-top: 20px;
}

.flex {
    display: flex;
}

.flex-center {
    display: flex;
    justify-content: center;
    align-items: center;
}

.gap-10 {
    gap: 10px;
}
