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

/* Screen reader only class */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #990000 0%, #7a0000 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Header */
header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

header p {
    font-size: 1.1em;
    opacity: 0.95;
}

/* Main Content Layout */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

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

/* Panel Styles */
.editor-panel, .preview-panel {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.editor-panel h2, .preview-panel h2 {
    margin-bottom: 20px;
    color: #990000;
    font-size: 1.5em;
}

/* Input Section */
.input-section {
    margin-bottom: 25px;
}

.settings-section {
    margin-bottom: 20px;
    padding: 15px;
    background: #f9fafb;
    border-radius: 8px;
}

.settings-section h3 {
    font-size: 1em;
    margin-bottom: 10px;
    color: #990000;
}

.setting-row {
    margin-bottom: 10px;
}

.setting-row label {
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
    color: #333;
}

.setting-row input[type="text"] {
    width: 100%;
    padding: 8px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.95em;
}

.setting-row input[type="text"]:focus {
    outline: none;
    border-color: #990000;
}

.additional-options {
    margin-top: 15px;
    padding: 15px;
    background: #f9fafb;
    border-radius: 8px;
}

.option-row {
    margin-bottom: 15px;
}

.option-row:last-child {
    margin-bottom: 0;
}

.option-row label {
    display: flex;
    align-items: center;
    font-weight: 600;
    color: #333;
    cursor: pointer;
}

.option-row input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
}

.timestamp-inputs,
.image-inputs,
.sender-name-input {
    margin-top: 10px;
    padding-left: 24px;
    display: flex;
    gap: 10px;
}

.timestamp-inputs input,
.image-inputs input,
.sender-name-input input {
    flex: 1;
    padding: 8px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.9em;
}

.timestamp-inputs input:focus,
.image-inputs input:focus,
.sender-name-input input:focus {
    outline: none;
    border-color: #990000;
}

.message-input-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1em;
    resize: vertical;
    transition: border-color 0.3s;
}

.message-input-group textarea:focus {
    outline: none;
    border-color: #990000;
}

.input-controls {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.input-controls select {
    flex: 1;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    background: white;
    cursor: pointer;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: #990000;
    color: white;
    flex: 1;
}

.btn-primary:hover {
    background: #7a0000;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(153, 0, 0, 0.4);
}

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.btn-secondary:hover {
    background: #d0d0d0;
}

.btn-success {
    background: #10b981;
    color: white;
}

.btn-success:hover {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.btn-danger {
    background: #ef4444;
    color: white;
    padding: 5px 10px;
    font-size: 0.9em;
}

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

/* Message List */
.message-list {
    margin-bottom: 20px;
}

.message-list h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 1.1em;
}

#messagesList {
    max-height: 300px;
    overflow-y: auto;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 10px;
}

#messagesList:empty::before {
    content: 'No messages added yet';
    color: #999;
    font-style: italic;
    display: block;
    text-align: center;
    padding: 20px;
}

.message-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 10px;
    margin-bottom: 8px;
    background: #f9fafb;
    border-radius: 6px;
    border-left: 4px solid #990000;
}

.message-item.other {
    border-left-color: #9ca3af;
}

.message-item.sms {
    border-left-color: #34c759;
}

.message-item.timestamp {
    border-left-color: #f59e0b;
}

.message-content {
    flex: 1;
    margin-right: 10px;
}

.message-sender {
    font-weight: 600;
    font-size: 0.85em;
    color: #990000;
    margin-bottom: 4px;
}

.message-item.other .message-sender {
    color: #9ca3af;
}

.message-item.sms .message-sender {
    color: #34c759;
}

.message-text {
    color: #333;
    word-wrap: break-word;
}

.message-actions {
    display: flex;
    gap: 5px;
}

.btn-move {
    background: transparent;
    border: none;
    font-size: 1.2em;
    cursor: pointer;
    padding: 5px;
    color: #999;
}

.btn-move:hover {
    color: #990000;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 10px;
}

.action-buttons .btn {
    flex: 1;
}

/* Preview Panel */
.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.preview-header h2 {
    margin: 0;
    color: #990000;
    font-size: 1.5em;
}

.btn-download {
    background: transparent;
    color: #6b7280;
    padding: 8px;
    font-size: 1.4em;
    white-space: nowrap;
    transition: all 0.3s;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    line-height: 1;
    min-width: auto;
}

.btn-download:hover {
    background: #f3f4f6;
    color: #374151;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-download:disabled {
    background: transparent;
    color: #d1d5db;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

.tab-button {
    flex: 1;
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 1em;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    bottom: -2px;
}

.tab-button:hover {
    color: #990000;
    background: #f9fafb;
}

.tab-button:focus {
    outline: 2px solid #990000;
    outline-offset: -2px;
}

.tab-button.active {
    color: #990000;
    border-bottom-color: #990000;
    background: transparent;
}

.tab-content {
    display: none;
}

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

.preview-container {
    background: #ffffff;
    border-radius: 16px;
    padding: 20px;
    min-height: 400px;
}

.chat {
    max-width: 400px;
    margin: 0 auto;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.empty-state {
    text-align: center;
    color: #999;
    padding: 40px 20px;
    font-style: italic;
}

/* Preview styles matching AO3 output */
.phone-preview {
    max-width: 300px;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    display: table;
    margin: auto;
}

.messagebody-preview {
    background-color: #FFFFFF;
    display: table;
    padding-left: 0.5em;
    padding-right: 0.5em;
}

.messagebody-preview .msg-prefix-preview {
    display: none;
}

.messagebody-preview .text {
    float: left;
    color: #000000;
    margin: 0 0 0.5em;
    border-radius: 1em;
    padding: 0.5em 1em;
    background: #e5e5ea;
    max-width: 75%;
    clear: both;
    position: relative;
    display: inline-block;
}

.messagebody-preview .text::after {
    content: "";
    position: absolute;
    left: -0.5em;
    bottom: 0;
    width: 0.5em;
    height: 1em;
    border-right: 0.5em solid #e5e5ea;
    border-bottom-right-radius: 1em 0.5em;
}

.messagebody-preview .breply {
    float: right;
    color: #FFFFFF;
    margin: 0 0 0.5em;
    border-radius: 1em;
    padding: 0.5em 1em;
    background: #1289fe;
    max-width: 75%;
    clear: both;
    position: relative;
    display: inline-block;
}

.messagebody-preview .breply::after {
    content: "";
    position: absolute;
    right: -0.5em;
    bottom: 0;
    width: 0.5em;
    height: 1em;
    border-left: 0.5em solid #1289fe;
    border-bottom-left-radius: 1em 0.5em;
}

.messagebody-preview .greply {
    float: right;
    color: #FFFFFF;
    margin: 0 0 0.5em;
    border-radius: 1em;
    padding: 0.5em 1em;
    background: #34c759;
    max-width: 75%;
    clear: both;
    position: relative;
    display: inline-block;
}

.messagebody-preview .greply::after {
    content: "";
    position: absolute;
    right: -0.5em;
    bottom: 0;
    width: 0.5em;
    height: 1em;
    border-left: 0.5em solid #34c759;
    border-bottom-left-radius: 1em 0.5em;
}

/* Preview header */
.messagebody-preview .header-preview {
    min-width: 300px;
    background-color: #f6f6f6;
    border-bottom: 1px solid #b2b2b2;
    color: #000000;
    font-weight: bold;
    padding-bottom: .5em;
    padding-top: .5em;
    margin-left: -.5em;
    margin-right: -.5em;
    margin-bottom: -2em;
    text-align: center;
    text-transform: capitalize;
    display: table;
}

/* Preview timestamp */
.messagebody-preview .time-preview {
    min-width: 295px;
    color: #7B7C80;
    font-size: .75em;
    padding-bottom: .5em;
    padding-top: .5em;
    margin-left: -.5em;
    margin-right: -.5em;
    margin-bottom: -.5em;
    text-align: center;
    display: table;
}

/* Preview group text */
.messagebody-preview .grouptext-preview {
    color: #7B7C80;
    font-size: .75em;
    padding-bottom: .5em;
    padding-top: 1em;
    margin-left: .5em;
    margin-bottom: -1.5em;
    text-align: left;
    display: table;
    clear: both;
}

/* Preview image */
.messagebody-preview .image-preview {
    float: right;
    margin: 0 0 0.5em;
    border-radius: 1em;
    width: 50%;
    min-height: 75%;
    clear: both;
    position: relative;
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
    display: inline-block;
    padding-top: 50%;
}

.messagebody-preview .image-preview.image-other {
    float: left;
}

.messagebody-preview .image-link-preview {
    text-decoration: none;
}

/* Preview typing indicator */
.messagebody-preview .typing-indicator-preview {
    background-color: #e6e7ed;
    width: auto;
    border-radius: 1em;
    padding: .5em 1em;
    display: table;
    margin: 0 0 .5em;
    position: relative;
    overflow: hidden;
    text-align: left;
    clear: both;
}

.messagebody-preview .typing-indicator-preview::before,
.messagebody-preview .typing-indicator-preview::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: -2px;
    height: 12px;
    width: 12px;
    border-radius: 50%;
    background-color: #e6e7ed;
}

.messagebody-preview .typing-indicator-preview::after {
    height: 6px;
    width: 6px;
    left: -6px;
    bottom: -6px;
}

.messagebody-preview .typing-indicator-preview span {
    height: .65em;
    width: .65em;
    float: left;
    margin: .425em 0 .425em .25em;
    background-color: #9e9ea1;
    display: inline-block;
    border-radius: 50%;
    opacity: .5;
}

.messagebody-preview .typing-indicator-preview span:first-child {
    margin-left: 0;
}

.messagebody-preview .typing-indicator-preview span:nth-child(1) {
    opacity: .85;
}

.messagebody-preview .typing-indicator-preview span:nth-child(2) {
    opacity: .65;
}

/* Text Rendering Preview */
.text-preview {
    background: #f9fafb;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    overflow-x: auto;
    max-height: none;
    min-height: 360px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85em;
    color: #333;
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.6;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal.show {
    display: block;
}

.modal-content {
    background-color: white;
    margin: 2% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px 25px;
    background: #990000;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    color: white;
}

.close {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    opacity: 0.8;
}

.modal-body {
    padding: 25px;
    overflow-y: auto;
}

.code-section {
    margin-bottom: 25px;
}

.code-section h3 {
    margin-bottom: 10px;
    color: #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-copy {
    padding: 6px 12px;
    background: #990000;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.3s;
}

.btn-copy:hover {
    background: #7a0000;
}

.btn-copy.copied {
    background: #10b981;
}

pre {
    background: #f9fafb;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    overflow-x: auto;
    max-height: 300px;
}

pre code {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
    color: #333;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.instructions {
    background: #fffbeb;
    border: 2px solid #fbbf24;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

.instructions h3 {
    color: #92400e;
    margin-bottom: 15px;
}

.instructions ol {
    margin-left: 20px;
    color: #78350f;
}

.instructions li {
    margin-bottom: 8px;
    line-height: 1.6;
}

.instructions strong {
    color: #92400e;
}

/* Footer */
footer {
    text-align: center;
    color: white;
    padding: 20px;
    font-size: 0.9em;
}

footer a {
    color: white;
    text-decoration: underline;
}

footer a:hover {
    opacity: 0.8;
}
