/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #1a1a1a;
    color: #e0e0e0;
    line-height: 1.6;
    min-height: 100vh;
}

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

/* Header */
header {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 2px solid #333;
}

header h1 {
    color: #fff;
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 300;
}

header p {
    color: #aaa;
    font-size: 1.1rem;
}

/* Main layout */
main {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 30px;
    align-items: start;
}

@media (max-width: 768px) {
    main {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

/* Card preview */
.card-preview {
    position: sticky;
    top: 20px;
}

.image-section {
    background: #2a2a2a;
    border-radius: 12px;
    padding: 20px;
    border: 2px solid #333;
}

.image-upload {
    width: 100%;
    height: 300px;
    border: 2px dashed #555;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.image-upload:hover {
    border-color: #666;
    background-color: #333;
}

.image-upload img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

.upload-placeholder {
    text-align: center;
    color: #aaa;
}

.upload-placeholder span {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.upload-placeholder small {
    color: #777;
    font-size: 0.9rem;
}

/* Form styles */
.character-form {
    background: #2a2a2a;
    border-radius: 12px;
    padding: 30px;
    border: 2px solid #333;
}

.form-section {
    margin-bottom: 40px;
}

.form-section:last-child {
    margin-bottom: 0;
}

.form-section h2 {
    color: #fff;
    font-size: 1.5rem;
    margin-bottom: 20px;
    font-weight: 400;
    border-bottom: 1px solid #444;
    padding-bottom: 10px;
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #ccc;
    font-weight: 500;
    font-size: 0.95rem;
}

.form-group input[type='text'],
.form-group input[type='number'],
.form-group textarea,
.greeting-item textarea,
.book-entry-item textarea,
.greeting-item input[type='text'],
.greeting-item input[type='number'],
.book-entry-item input[type='text'],
.book-entry-item input[type='number'],
.book-entry-item select {
    width: 100%;
    padding: 12px 16px;
    background: #1a1a1a;
    border: 2px solid #444;
    border-radius: 8px;
    color: #e0e0e0;
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.3s ease;
    resize: vertical;
}

.form-group input[type='text']:focus,
.form-group input[type='number']:focus,
.form-group textarea:focus,
.greeting-item textarea:focus,
.book-entry-item textarea:focus,
.greeting-item input[type='text']:focus,
.greeting-item input[type='number']:focus,
.book-entry-item input[type='text']:focus,
.book-entry-item input[type='number']:focus,
.book-entry-item select:focus {
    outline: none;
    border-color: #555;
    background: #222;
}

.form-group input[type='checkbox'] {
    margin-right: 8px;
    transform: scale(1.2);
}

.form-group textarea {
    min-height: 100px;
    line-height: 1.5;
}

/* Buttons */
.btn-primary,
.btn-secondary {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-right: 10px;
    margin-bottom: 10px;
}

.btn-primary {
    background: #4a9eff;
    color: white;
}

.btn-primary:hover {
    background: #3a8eef;
    transform: translateY(-1px);
}

.btn-secondary {
    background: #444;
    color: #e0e0e0;
    border: 2px solid #555;
}

.btn-secondary:hover {
    background: #555;
    border-color: #666;
}

/* Dynamic sections */
.greeting-item,
.book-entry-item {
    background: #1a1a1a;
    border: 2px solid #444;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
    position: relative;
}

.greeting-item .form-group,
.book-entry-item .form-group {
    margin-bottom: 15px;
}

.greeting-item label,
.book-entry-item label {
    display: block;
    margin-bottom: 8px;
    color: #ccc;
    font-weight: 500;
    font-size: 0.95rem;
}

.greeting-item h4,
.book-entry-item h4 {
    color: #fff;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.remove-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #ff4757;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.remove-btn:hover {
    background: #ff3742;
    transform: scale(1.1);
}

/* Export section */
.export-section {
    background: #333;
    border-radius: 8px;
    padding: 25px;
    border: 2px solid #444;
}

.export-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* Macro autocomplete */
.macro-autocomplete {
    position: absolute;
    background: #2a2a2a;
    border: 2px solid #444;
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 9999;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    min-width: 250px;
    max-width: 400px;
}

.macro-autocomplete ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.macro-autocomplete li {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid #444;
    color: #e0e0e0;
    transition: background-color 0.2s ease;
}

.macro-autocomplete li:hover,
.macro-autocomplete li.selected {
    background: #4a9eff;
    color: white;
}

.macro-autocomplete li:last-child {
    border-bottom: none;
}

.macro-autocomplete .macro-name {
    font-weight: 500;
    font-family: monospace;
    color: #4a9eff;
}

.macro-autocomplete .macro-description {
    font-size: 0.85rem;
    color: #aaa;
    margin-top: 2px;
}

.macro-autocomplete li:hover .macro-name,
.macro-autocomplete li.selected .macro-name {
    color: white;
}

.macro-autocomplete li:hover .macro-description,
.macro-autocomplete li.selected .macro-description {
    color: #ddd;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1a1a;
}

::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .container {
        padding: 15px;
    }

    header h1 {
        font-size: 2rem;
    }

    .character-form {
        padding: 20px;
    }

    .export-buttons {
        flex-direction: column;
    }

    .btn-primary,
    .btn-secondary {
        width: 100%;
        margin-right: 0;
    }
}
