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

:root {
    --bg: #1a1a1a;
    --bg-light: #2a2a2a;
    --bg-lighter: #3a3a3a;
    --text: #e0e0e0;
    --text-dim: #888;
    --primary: #4a90d9;
    --danger: #d9534f;
    --border: #444;
}

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* Login Page */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-container {
    background: var(--bg-light);
    padding: 40px;
    border-radius: 8px;
    width: 100%;
    max-width: 360px;
    border: 1px solid var(--border);
}

.login-container h1 {
    font-size: 2rem;
    text-align: center;
    margin-bottom: 5px;
}

.subtitle {
    text-align: center;
    color: var(--text-dim);
    margin-bottom: 30px;
}

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

.login-form label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-dim);
}

.login-form input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary);
}

.error {
    background: rgba(217, 83, 79, 0.2);
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 20px;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    text-decoration: none;
    transition: opacity 0.2s, background 0.2s;
}

.btn:hover { opacity: 0.85; }

.btn-primary {
    background: var(--primary);
    color: white;
    width: 100%;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-tiny {
    padding: 4px 10px;
    font-size: 0.8rem;
    background: var(--bg-lighter);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 3px;
    cursor: pointer;
}

.btn-tiny:hover { background: #4a4a4a; }
.btn-tiny.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-tiny.btn-danger:hover { background: #c9302c; }

.btn-file {
    background: var(--bg-lighter);
    color: var(--text);
    cursor: pointer;
}

.btn-file:hover {
    background: #4a4a4a;
}

.btn-send {
    background: var(--primary);
    color: white;
    padding: 10px 24px;
    font-weight: 500;
}

.btn-send:hover {
    background: #3a7bc8;
}

/* App Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 1200px;
    margin: 0 auto;
    background: var(--bg);
}

/* Desktop: Add side borders */
@media (min-width: 1201px) {
    .app-container {
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
    }
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    background: var(--bg-light);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.app-header h1 {
    font-size: 1.4rem;
    letter-spacing: 1px;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

.username {
    color: var(--text-dim);
    font-size: 0.9rem;
}

/* Chat Area */
.chat-container {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message {
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    max-width: 100%;
}

.msg-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.85rem;
}

.msg-user {
    font-weight: 600;
    color: var(--primary);
}

.msg-time {
    color: var(--text-dim);
}

.msg-text {
    word-break: break-word;
    white-space: pre-wrap;
    font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
    font-size: 0.9rem;
    background: var(--bg);
    padding: 12px 14px;
    border-radius: 4px;
    margin-bottom: 10px;
    border: 1px solid var(--border);
    line-height: 1.6;
}

.msg-file {
    margin-bottom: 10px;
}

.file-link {
    color: var(--primary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg);
    border-radius: 4px;
    border: 1px solid var(--border);
    transition: background 0.2s;
}

.file-link:hover {
    background: var(--bg-lighter);
}

.file-link::before {
    content: "↓";
    font-weight: bold;
}

.msg-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
}

.msg-expire {
    color: var(--text-dim);
}

.msg-expire.expiring {
    color: var(--danger);
    font-weight: 600;
}

.msg-actions {
    display: flex;
    gap: 8px;
}

/* Input Area */
.input-area {
    padding: 16px 20px;
    background: var(--bg-light);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.message-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.input-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.input-row textarea {
    flex: 1;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
    resize: none;
    font-family: inherit;
    min-height: 46px;
    max-height: 150px;
    line-height: 1.4;
}

.input-row textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.input-row textarea::placeholder {
    color: var(--text-dim);
}

.options-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.file-upload {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-upload input[type="file"] {
    display: none;
}

#fileNames {
    font-size: 0.85rem;
    color: var(--text-dim);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.expire-option {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
}

.expire-option label {
    color: var(--text-dim);
    white-space: nowrap;
}

.expire-option select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
}

.expire-option select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Actions Bar */
.actions-bar {
    display: flex;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--bg-light);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-light);
    padding: 28px;
    border-radius: 8px;
    width: 100%;
    max-width: 340px;
    position: relative;
    border: 1px solid var(--border);
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-dim);
    line-height: 1;
}

.modal-close:hover {
    color: var(--text);
}

.modal-content h3 {
    margin-bottom: 18px;
    font-size: 1.1rem;
}

.modal-content select {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.95rem;
}

/* Desktop Styles */
@media (min-width: 768px) {
    .app-header {
        padding: 18px 30px;
    }
    
    .app-header h1 {
        font-size: 1.5rem;
    }
    
    .messages {
        padding: 25px 30px;
    }
    
    .message {
        padding: 16px 20px;
    }
    
    .input-area {
        padding: 18px 30px;
    }
    
    .actions-bar {
        padding: 14px 30px;
    }
    
    .options-row {
        gap: 25px;
    }
    
    #fileNames {
        max-width: 400px;
    }
}

/* Large Desktop */
@media (min-width: 1024px) {
    .message {
        max-width: 85%;
    }
    
    .msg-text {
        font-size: 0.95rem;
    }
    
    .input-row textarea {
        font-size: 1rem;
    }
}

/* Mobile Styles */
@media (max-width: 600px) {
    .app-header {
        padding: 12px 15px;
    }
    
    .app-header h1 {
        font-size: 1.2rem;
    }
    
    .header-info {
        gap: 12px;
    }
    
    .username {
        font-size: 0.8rem;
    }
    
    .messages {
        padding: 12px;
        gap: 10px;
    }
    
    .message {
        padding: 12px;
    }
    
    .msg-text {
        padding: 10px;
        font-size: 0.85rem;
    }
    
    .input-area {
        padding: 12px;
    }
    
    .input-row {
        gap: 8px;
    }
    
    .input-row textarea {
        padding: 10px 12px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .btn-send {
        padding: 10px 16px;
    }
    
    .options-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .file-upload {
        justify-content: space-between;
    }
    
    #fileNames {
        max-width: 180px;
    }
    
    .expire-option {
        justify-content: space-between;
    }
    
    .expire-option select {
        flex: 1;
        max-width: 160px;
    }
    
    .actions-bar {
        padding: 10px 12px;
    }
    
    .msg-footer {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .msg-actions {
        gap: 6px;
    }
    
    .btn-tiny {
        padding: 5px 10px;
        font-size: 0.75rem;
    }
}

/* Scrollbar Styling */
.messages::-webkit-scrollbar {
    width: 8px;
}

.messages::-webkit-scrollbar-track {
    background: var(--bg);
}

.messages::-webkit-scrollbar-thumb {
    background: var(--bg-lighter);
    border-radius: 4px;
}

.messages::-webkit-scrollbar-thumb:hover {
    background: #4a4a4a;
}

/* Empty state */
.messages:empty::after {
    content: "Ingen beskeder endnu";
    display: block;
    text-align: center;
    color: var(--text-dim);
    padding: 60px 20px;
    font-size: 1rem;
}

/* Selection */
::selection {
    background: var(--primary);
    color: white;
}