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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #232526 0%, #414345 100%);
    min-height: 100vh;
    color: #333;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
    padding-top: 20px;
}

header h1 {
    color: white;
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 8px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

header p {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
    font-weight: 300;
}

/* Add message section */
.add-message-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 20px;
    margin-top: 20px;
    margin-bottom: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}


.input-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message-title-input {
    width: 100%;
    padding: 16px;
    border: 2px solid #e1e5e9;
    border-radius: 12px;
    font-family: inherit;
    font-size: 16px;
    transition: border-color 0.2s ease;
    background: white;
}

.message-title-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.edit-textarea {
    width: 100%;
    padding: 16px;
    border: 2px solid #e1e5e9;
    border-radius: 12px;
    font-family: inherit;
    font-size: 16px;
    resize: vertical;
    min-height: 100px;
    transition: border-color 0.2s ease;
    background: white;
}

.edit-textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#newMessageInput {
    width: 100%;
    padding: 16px;
    border: 2px solid #e1e5e9;
    border-radius: 12px;
    font-family: inherit;
    font-size: 16px;
    resize: vertical;
    min-height: 80px;
    transition: border-color 0.2s ease;
    background: white;
}

#newMessageInput:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 16px 24px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Messages container */
.messages-container {
    margin-bottom: 20px;
    padding-bottom: 20px;
}

.messages-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Message item */
.message-item {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    user-select: none;
}

.message-item.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
    z-index: 1000;
}

.message-item.drag-over {
    border: 2px dashed #667eea;
    background: rgba(102, 126, 234, 0.1);
}

.reorder-buttons {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.move-btn {
    background: none;
    border: none;
    color: #ccc;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 20px;
    line-height: 1;
}

.move-btn:hover {
    color: #667eea;
    background: rgba(102, 126, 234, 0.1);
    transform: scale(1.1);
}

.move-btn:active {
    transform: scale(0.95);
}

.edit-btn {
    background: none;
    border: none;
    color: #667eea;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.edit-btn:hover {
    background: rgba(102, 126, 234, 0.1);
    transform: scale(1.1);
}

.message-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
}

.message-item:active {
    transform: scale(0.98);
}

.message-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.message-content {
    font-size: 14px;
    line-height: 1.5;
    color: #666;
    word-wrap: break-word;
    margin-bottom: 12px;
    white-space: pre-wrap;
    display: none;
    padding-top: 8px;
    border-top: 1px solid #f0f0f0;
}

.message-content.expanded {
    display: block;
}

.expand-arrow {
    font-size: 12px;
    color: #999;
    transition: transform 0.2s ease;
    user-select: none;
}

.expand-arrow.expanded {
    transform: rotate(180deg);
}

.message-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
}

.action-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
}

.copy-indicator {
    font-size: 12px;
    color: #667eea;
    font-weight: 500;
    opacity: 0.8;
}

.delete-btn {
    background: none;
    border: none;
    color: #ff4757;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.delete-btn:hover {
    background: rgba(255, 71, 87, 0.1);
    transform: scale(1.1);
}

/* No messages placeholder */
.no-messages {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 40px 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    margin: 20px 0;
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 16px 24px;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 500;
    z-index: 1000;
    transition: transform 0.3s ease;
    backdrop-filter: blur(10px);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    padding: 32px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    max-width: 400px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

/* Mobile-specific modal styles */
@media (max-width: 768px) {
    .modal-content {
        width: 100%;
        max-width: none;
        margin: 20px;
        padding: 24px;
        border-radius: 16px;
        max-height: calc(100vh - 40px);
    }
    
    /* Make edit modal even larger on mobile */
    #editModal .modal-content {
        width: calc(100% - 20px);
        margin: 10px;
        max-height: calc(100vh - 20px);
    }
    
    /* Adjust input fields for mobile */
    #editModal .message-title-input,
    #editModal .edit-textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    #editModal .edit-textarea {
        min-height: 120px;
    }
}

.modal-content h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #333;
}

.modal-content p {
    color: #666;
    margin-bottom: 24px;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    gap: 12px;
}

.btn-secondary {
    flex: 1;
    background: #f8f9fa;
    color: #333;
    border: none;
    padding: 14px 20px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.btn-danger {
    flex: 1;
    background: #ff4757;
    color: white;
    border: none;
    padding: 14px 20px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

/* Loading screen */
.loading-screen {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    justify-content: center;
    align-items: center;
}

.loading-content {
    text-align: center;
    color: white;
}

.loading-content h2 {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.loading-content p {
    font-size: 0.9rem;
    opacity: 0.8;
}

/* Authentication screen */
.auth-screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.auth-container {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.auth-tabs {
    display: flex;
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 4px;
}

.auth-tab {
    flex: 1;
    padding: 12px 20px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.auth-tab.active {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.auth-form {
    display: flex;
    flex-direction: column;
}

.auth-form .input-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.auth-form input {
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 16px;
    transition: all 0.3s ease;
}

.auth-form input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.auth-form input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.15);
}

.signup-fields {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-error {
    color: #ff6b6b;
    font-size: 14px;
    margin-top: 10px;
    padding: 10px;
    background: rgba(255, 107, 107, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(255, 107, 107, 0.3);
    display: none;
}

@media (max-width: 768px) {
    .auth-container {
        padding: 30px 20px;
        margin: 0 10px;
    }
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: rgba(255, 255, 255, 0.8);
}

.empty-state h3 {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    opacity: 0.8;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .container {
        padding: 16px;
    }
    
    header h1 {
        font-size: 1.75rem;
    }
    
    .add-message-section {
        padding: 16px;
    }
    
    .message-item {
        padding: 16px;
    }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    .container {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Prevent zoom on input focus on iOS */
@media screen and (max-width: 767px) {
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    textarea,
    select {
        font-size: 16px;
    }
}
