/* --- Global & Base Styles --- */
body {
    font-family: "gg sans", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background-color: #2c2f33;
    color: #ffffff;
    margin: 0;
    padding: 0;
}

input, textarea, select, button {
    font-family: inherit !important;
}

/* --- Header & Navigation --- */
header {
    background-color: #23272a;
    padding: 10px 20px;
}

nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.header-left, .header-center, .header-right {
    flex: 1;
}

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

.header-title {
    font-weight: 500;
    font-size: 1.1em;
    color: #ffffff;
}

.header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 20px;
}

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

.nav-links a {
    color: #b9bbbe;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.nav-links a:hover {
    color: #ffffff;
}

/* --- User Dropdown --- */
.user-dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-trigger {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    background-color: #23272a;
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 1000;
    border-radius: 4px;
    overflow: hidden;
}

.dropdown-content a {
    color: white;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    font-size: 14px;
}

.dropdown-content a:hover {
    background-color: #2c2f33;
}

.user-dropdown:hover .dropdown-content {
    display: block;
}

.logout-link {
    color: #f04747 !important;
    border-top: 1px solid #2c2f33;
}

.external {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
}

.external::after {
    content: "\2197";
    font-size: 12px;
    margin-left: 8px;
    color: #72767d;
    transition: color 0.2s ease;
}

.external:hover::after {
    color: #ffffff;
}

/* --- Main Layout --- */
.container {
    display: flex;
    gap: 20px;
    padding: 20px;
    flex-wrap: wrap;
    align-items: flex-start;
}

.builder {
    background-color: #393a41;
    padding: 20px;
    border-radius: 8px;
    flex: 1 1 400px;
    min-width: 300px;
}

.preview {
    background-color: #2c2f33; 
    padding: 20px;
    border-radius: 8px;
    flex: 1 1 400px;
    min-width: 300px;
}

/* --- Builder Inputs --- */
.builder input, .builder textarea, .builder select {
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 10px;
    padding: 8px;
    border-radius: 5px;
    border: none;
    background-color: #2c2f33;
    color: #fff;
}

.builder label {
    display: block;
    margin-bottom: 4px;
    font-weight: bold;
    font-size: 0.9rem;
    color: #b9bbbe;
}

/* --- Input Utilities --- */
.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.char-counter {
    font-size: 11px;
    color: #b9bbbe;
    font-weight: normal;
}

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

.input-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* --- Buttons --- */
.builder-btn, .builder-btn-red, .builder-btn-green, .builder-btn-og {
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
    margin: 4px;
    transition: background-color 0.2s ease;
    color: white;
}

.builder-btn { background-color: #5865F2; }
.builder-btn:hover { background-color: #4752c4; }

.builder-btn-green { background-color: #008545; }
.builder-btn-green:hover { background-color: #006c37; }

.builder-btn-og { background-color: #7289da; }
.builder-btn-og:hover { background-color: #6375b9; }

.builder-btn-red, .btn-clear { background-color: #ed4245; }
.builder-btn-red:hover, .btn-clear:hover { background-color: #c0392b; }

.btn-send { background-color: #00863a; }
.btn-send:hover { background-color: #057834; }

.btn-copy { background-color: #4a56cf; }
.btn-copy:hover { background-color: #4751c5; }

/* --- Accordions --- */
.accordion {
    background-color: #2c2f33;
    color: #fff;
    cursor: pointer;
    padding: 12px;
    width: 100%;
    border: none;
    text-align: left;
    outline: none;
    font-size: 15px;
    transition: 0.4s;
    border-radius: 5px;
    margin-top: 5px;
}

.accordion:after {
    content: '\002B';
    color: #777;
    font-weight: bold;
    float: right;
    margin-left: 5px;
}

.accordion.active:after {
    content: "\2212";
}

.panel {
    padding: 0 18px;
    background-color: transparent;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.panel.show {
    max-height: 800px;
    padding-top: 10px;
    overflow: visible;
}

/* --- Nested Fields --- */
.field-item {
    border: 1px solid #444;
    border-radius: 5px;
    margin-bottom: 10px;
    background-color: #393a41;
    overflow: hidden;
}

.field-header {
    background-color: #36393f;
    padding: 10px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.field-left-group {
    display: flex;
    align-items: center;
    flex: 1;
    overflow: hidden;
}

.field-indicator {
    font-weight: bold;
    color: #72767d;
    margin-right: 10px;
    font-family: monospace;
    font-size: 1.2em;
    width: 12px;
}

.field-title-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 10px;
    font-weight: 500;
}

.header-inline-label {
    font-size: 0.85rem;
    color: #b9bbbe;
    margin-right: 15px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.header-inline-label input {
    margin: 0 !important;
    cursor: pointer;
}

.field-controls {
    display: flex;
    gap: 5px;
}

.field-control-btn {
    background: none;
    border: none;
    color: #b9bbbe;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 5px;
}

.field-control-btn:hover {
    color: white;
}

.field-content {
    padding: 10px;
    display: none;
}

.field-content.show {
    display: block;
}

/* --- Discord Preview --- */

.discord-message-wrapper {
    display: flex;
    align-items: flex-start;
    padding: 10px 0;
    color: #dcddde;
    font-family: 'gg sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.375rem;
    max-width: 100%;
}

/* Left Column: Avatar */
.discord-avatar-col {
    width: 40px;
    margin-right: 16px;
    margin-top: 2px;
    flex-shrink: 0;
}

.webhook-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

/* Right Column: Content */
.discord-content-col {
    min-width: 0;
    flex: 1;
}

.message-header {
    display: block;
    margin-bottom: 2px;
}

.webhook-name {
    font-weight: 500;
    color: #ffffff;
    margin-right: 0.25rem;
    font-size: 1rem;
    display: inline;
}

.webhook-timestamp {
    font-size: 0.75rem;
    color: #72767d;
    margin-left: 0.25rem;
    display: inline-block;
}

/* Plain Text Content */
.message-content {
    white-space: pre-wrap;
    margin-bottom: 8px;
    color: #dcddde;
}

/* Attachments */
.attachment-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
    max-width: 520px;
}

.attachment-item img, .attachment-item video {
    max-width: 100%;
    max-height: 300px;
    border-radius: 4px;
    display: block;
    cursor: pointer;
}

.attachment-item {
    font-size: 0.9rem;
    color: #dcddde;
}

/* Embed Box */
.discord-embed {
    display: block;
    position: relative;
    overflow: hidden;
    max-width: 520px;
    min-width: 150px;
    width: fit-content;
    border-radius: 4px;
    background-color: #2f3136;
    border-left: 4px solid #202225;
    padding: 10px;
    box-sizing: border-box;
}

.discord-embed .embed-content {
    display: block;
    width: 100%;
}

.discord-embed a {
    color: #00a8fc;
    text-decoration: none;
}
.discord-embed a:hover { text-decoration: underline; }

/* Embed Layout Rows */
.discord-embed .author {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.875rem;
}

.author-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    margin-right: 8px;
    object-fit: cover;
}

.discord-embed .title {
    margin-bottom: 8px;
    font-size: 1rem;
    color: #ffffff;
}

.discord-embed .description {
    margin-bottom: 8px;
    font-size: 0.875rem;
    line-height: 1.125rem;
    color: #dcddde;
    white-space: pre-wrap;
}

.discord-embed .fields {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.discord-embed .field-box {
    flex: 1 0 100%;
    font-size: 0.875rem;
    margin-bottom: 4px;
}

.discord-embed .field-box.inline {
    flex: 1 0 auto;
    width: auto;
    min-width: 150px;
    max-width: 48%;
}

.discord-embed .field-box strong {
    display: block;
    margin-bottom: 2px;
    color: #ffffff;
    font-weight: 600;
}

.discord-embed .field-box p {
    margin: 0;
    color: #dcddde;
    white-space: pre-wrap;
}

.discord-embed .image {
    margin-top: 10px;
    border-radius: 4px;
    max-width: 100%;
    display: block;
}

.discord-embed .embed-thumbnail {
    float: right;
    max-width: 80px;
    max-height: 80px;
    border-radius: 4px;
    margin-left: 16px;
    object-fit: cover;
}

.discord-embed .footer {
    display: flex;
    align-items: center;
    margin-top: 8px;
    font-size: 0.75rem;
    color: #dcddde;
}

.footer-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin-right: 8px;
    object-fit: cover;
}

/* --- Modals & Login --- */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: #2f3136;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    color: white;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid #444;
    padding-bottom: 10px;
}

.close-modal {
    cursor: pointer;
    font-size: 24px;
    color: #b9bbbe;
}
.close-modal:hover { color: white; }

.load-item-btn {
    width: 100%;
    text-align: left;
    background: #36393f;
    border: 1px solid #444;
    color: white;
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 4px;
    cursor: pointer;
}
.load-item-btn:hover { border-color: #5865f2; }

/* Login Pages */
.login-container, .simple-login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 70px);
    padding: 20px;
    flex-direction: column;
}

.login-card {
    background-color: #2f3136;
    padding: 40px;
    border-radius: 8px;
    text-align: center;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.btn-discord-login {
    display: inline-block;
    padding: 12px 24px;
    background-color: #5865f2;
    color: white;
    font-weight: 500;
    font-size: 16px;
    border: none;
    border-radius: 5px;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s ease;
}
.btn-discord-login:hover { background-color: #4752c4; }

/* Saved Embeds Page */
.narrow-container {
    max-width: 700px;
    margin: 0 auto;
    width: 100%;
}

.saved-item {
    background: #23272a;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.saved-item:hover { background: #282b30; }

.back-link {
    display: inline-block;
    color: #5865f2;
    text-decoration: none;
    margin-bottom: 15px;
    font-weight: 500;
}
.back-link:hover { text-decoration: underline; }