:root {
    --primary-color: #e60012; /* Rider Red */
    --secondary-color: #00a8e6; /* Rider Blue */
    --background-color: #1a1a1a;
    --surface-color: #2c2c2c;
    --text-color: #f0f0f0;
    --font-family: 'Orbitron', sans-serif;
}

body {
    background-color: var(--background-color);
    color: var(--text-color);
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
}

#app {
    width: 100%;
    max-width: 800px;
    text-align: center;
    margin: 0 auto;
}

header {
    margin-bottom: 20px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.header-user-area {
    display: flex;
    align-items: center;
    gap: 15px;
}

#current-user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

#current-user-info .user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--secondary-color);
}

.promo-title {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    color: #dcdcdc;
    font-size: 1.2em;
    font-style: italic;
    margin-bottom: 0;
}

header h1 {
    font-family: var(--font-family);
    color: var(--primary-color);
    text-shadow: 0 0 5px var(--primary-color);
    margin-top: 0;
    margin-bottom: 0;
}

header .subtitle {
    color: var(--secondary-color);
    font-family: var(--font-family);
    font-size: 1.1em;
}

main {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

#form-container {
    background-color: var(--surface-color);
    padding: 30px;
    border-radius: 10px;
    border: 1px solid #444;
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 600px) {
    #form-container {
        grid-template-columns: 1fr 1fr;
    }
    .form-group-full {
        grid-column: 1 / -1;
    }
}

.form-group {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.form-group.form-group-full {
    grid-column: 1 / -1;
}

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

.sub-label {
    margin-top: 15px;
    font-size: 0.9em;
    color: #ccc;
    font-weight: normal;
}

p.label-description {
    font-size: 0.85em;
    color: #aaa;
    margin: -4px 0 8px 0;
    font-style: italic;
    font-weight: normal;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

input[type="text"], textarea {
    background-color: #111;
    border: 1px solid #555;
    color: var(--text-color);
    padding: 10px;
    border-radius: 5px;
    font-size: 1em;
    font-family: inherit;
}

input[type="text"]:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 8px var(--primary-color);
}

textarea {
    resize: vertical;
}

#generate-btn {
    grid-column: 1 / -1;
    background: linear-gradient(45deg, var(--primary-color), #ff4d4d);
    color: white;
    font-family: var(--font-family);
    font-size: 1.5em;
    font-weight: bold;
    border: none;
    padding: 15px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
}

#generate-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px var(--primary-color);
}

#generate-btn:disabled {
    background: #555;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#result-container {
    background-color: var(--surface-color);
    padding: 30px;
    border-radius: 10px;
    border: 1px solid #444;
    margin-top: 20px;
    min-height: 200px;
    display: flex;
    justify-content: center;
    align-items: center;
}

#rider-output {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    width: 100%;
}

#base-form-output {
    width: 100%;
}

#output-name {
    color: var(--secondary-color);
    font-family: var(--font-family);
}

#rider-image {
    max-width: 100%;
    height: auto;
    max-height: 600px;
    border-radius: 10px;
    margin: 20px 0;
    border: 3px solid var(--secondary-color);
    box-shadow: 0 0 10px var(--secondary-color);
}

#rider-details h3 {
    color: var(--primary-color);
    font-family: var(--font-family);
    margin-bottom: 10px;
}

#rider-details p {
    line-height: 1.6;
    text-align: left;
}

#save-options {
    width: 100%;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #444;
}

#save-options h3 {
    color: var(--secondary-color);
    font-family: var(--font-family);
}

.save-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 15px;
}

.save-buttons button {
    font-family: var(--font-family);
    font-size: 1.1em;
    padding: 12px 20px;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

#save-private-btn {
    background-color: var(--secondary-color);
    color: white;
}

#save-public-btn {
    background-color: var(--primary-color);
    color: white;
}

#save-private-btn:hover {
    background-color: #00c0ff;
    transform: translateY(-2px);
}

#save-public-btn:hover {
    background-color: #ff3c4d;
    transform: translateY(-2px);
}

#save-private-btn:disabled, #save-public-btn:disabled {
    background-color: #555;
    cursor: not-allowed;
    transform: none;
}

#additional-forms-output {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.forms-title {
    color: var(--primary-color);
    font-family: var(--font-family);
    text-shadow: 0 0 5px var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
    margin-bottom: 10px;
}

.form-card {
    background-color: #1f1f1f;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

.form-card h3 {
    font-family: var(--font-family);
    color: var(--secondary-color);
    margin-top: 0;
}

.form-card img {
    max-width: 100%;
    max-height: 500px;
    height: auto;
    border-radius: 8px;
    margin: 15px 0;
    border: 2px solid var(--secondary-color);
}

.form-card-details h4 {
    color: var(--primary-color);
    font-family: var(--font-family);
}

.form-card-details p {
    text-align: left;
}

.form-card-loader {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 150px;
    gap: 15px;
}

.mini-loader {
    border: 5px solid #f3f3f3;
    border-top: 5px solid var(--secondary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

.hidden {
    display: none !important;
}

#loader {
    border: 8px solid #f3f3f3;
    border-top: 8px solid var(--primary-color);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#abilities-list {
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr;
}

@media (min-width: 600px) {
    #abilities-list {
        grid-template-columns: 1fr 1fr;
    }
}

/* --- Styles for Dynamic Additional Forms --- */
#additional-forms-container {
    border-top: 1px solid #444;
    padding-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#forms-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
}

.additional-form-entry {
    background-color: #1f1f1f;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #333;
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 10px;
    align-items: center;
}

.additional-form-entry textarea {
    grid-column: 1 / -1;
}

#add-form-btn {
    background: var(--secondary-color);
    color: white;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 1em;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: fit-content;
    align-self: flex-start;
}

#add-form-btn:hover {
    background-color: #008fbf;
    transform: scale(1.05);
}

.remove-form-btn {
    background-color: #666;
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: bold;
    line-height: 1;
    transition: background-color 0.3s ease, transform 0.2s ease;
    justify-self: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-form-btn:hover {
    background-color: var(--primary-color);
    transform: scale(1.1);
}

@media (max-width: 600px) {
    .additional-form-entry {
        grid-template-columns: 1fr;
        position: relative;
    }

    .additional-form-entry .remove-form-btn {
        position: absolute;
        top: 10px;
        right: 10px;
    }
}

/* Gallery Styles */
#gallery-container, #rider-detail-view-container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    color: var(--text-color);
    text-align: center;
}

.gallery-header, .detail-view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 2px solid var(--primary-color);
    margin-bottom: 20px;
}

.gallery-header h1 {
    font-family: var(--font-family);
    color: var(--primary-color);
    text-shadow: 0 0 5px var(--primary-color);
    margin: 0;
}

#back-to-generator-btn, #back-to-gallery-btn {
    background: var(--secondary-color);
    color: white;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 1em;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#back-to-generator-btn:hover, #back-to-gallery-btn:hover {
    background-color: #008fbf;
    transform: scale(1.05);
}

.gallery-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.tab-btn {
    padding: 10px 20px;
    font-size: 1.1em;
    font-family: var(--font-family);
    border: 2px solid var(--surface-color);
    background-color: var(--surface-color);
    color: var(--text-color);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn.active {
    border-color: var(--secondary-color);
    color: var(--secondary-color);
    box-shadow: 0 0 5px var(--secondary-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.rider-card {
    background-color: var(--surface-color);
    border: 1px solid #444;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    text-align: center;
}

.rider-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 168, 230, 0.4);
}

.rider-card img {
    width: 100%;
    height: 300px;
    object-fit: cover;
    display: block;
    background-color: #111;
}

.rider-card-info {
    padding: 15px;
}

.rider-card-info h4 {
    margin: 0 0 5px 0;
    font-family: var(--font-family);
    color: var(--secondary-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rider-card-info p {
    margin: 0;
    font-size: 0.9em;
    color: #ccc;
}

.placeholder-text {
    text-align: center;
    font-style: italic;
    color: #888;
    margin-top: 40px;
}

#gallery-loader {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 50px;
}

#gallery-loader .loader {
    border: 8px solid #f3f3f3;
    border-top: 8px solid var(--primary-color);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
}

#rider-detail-output {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    width: 100%;
}
#rider-detail-output #rider-image, #rider-detail-output img {
    max-width: 100%;
    height: auto;
    max-height: 700px; /* Larger for detail view */
    border-radius: 10px;
    margin: 20px 0;
    border: 3px solid var(--secondary-color);
    box-shadow: 0 0 10px var(--secondary-color);
}

#rider-detail-output .form-card img {
     border: 2px solid var(--secondary-color);
     max-height: 500px;
}

@media (max-width: 600px) {
    .header-top {
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }
    .save-buttons {
        flex-direction: column;
    }
    .gallery-grid {
        grid-template-columns: 1fr;
    }
    .additional-form-entry {
        grid-template-columns: 1fr;
    }
}

/* Interaction (Likes/Comments) Styles */
.interaction-section {
    width: 100%;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #444;
    text-align: left;
}

.like-section {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

#like-btn {
    background-color: var(--surface-color);
    color: var(--text-color);
    border: 1px solid var(--secondary-color);
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-family: var(--font-family);
    font-size: 1em;
    transition: all 0.3s ease;
    min-width: 100px;
}

#like-btn.liked {
    background-color: var(--secondary-color);
    color: white;
}

#like-btn:hover:not(:disabled) {
    box-shadow: 0 0 8px var(--secondary-color);
}

#like-btn:disabled {
    background: #555;
    cursor: not-allowed;
    border-color: #555;
}

#like-count {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 1.1em;
}

.comments-section h3 {
    font-family: var(--font-family);
    color: var(--secondary-color);
}

#comments-list {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.comment-entry {
    background-color: #1f1f1f;
    padding: 15px;
    border-radius: 8px;
    border-left: 3px solid var(--primary-color);
}

.comment-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.comment-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.comment-username {
    font-weight: bold;
    color: var(--secondary-color);
}

.comment-timestamp {
    font-size: 0.8em;
    color: #888;
    margin-left: auto;
}

.comment-body {
    line-height: 1.5;
    white-space: pre-wrap; /* Preserve line breaks */
    word-break: break-word;
}

.comment-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#comment-input {
    width: 100%;
    box-sizing: border-box;
    min-height: 80px;
}

#submit-comment-btn {
    background: var(--primary-color);
    color: white;
    font-family: var(--font-family);
    font-size: 1.1em;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    align-self: flex-start;
}

#submit-comment-btn:hover:not(:disabled) {
    background-color: #ff3c4d;
}

#submit-comment-btn:disabled {
    background: #555;
    cursor: not-allowed;
}