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

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --success: #16a34a;
    --bg: #f3f4f6;
    --card-bg: #ffffff;
    --text: #1f2937;
    --text-light: #6b7280;
    --border: #e5e7eb;
}

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

.hidden { display: none !important; }

.view {
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height for mobile */
}

/* Login */
#login-view, #setup-view {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 2rem 1rem;
    padding-top: 15vh;
    overflow-y: auto;
}

@media (max-height: 500px) {
    #login-view, #setup-view {
        padding-top: 1rem;
        align-items: flex-start;
    }
}

.card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 360px;
    margin-bottom: 2rem;
}

.card h1, .card h2 {
    text-align: center;
    margin-bottom: 1rem;
    color: var(--primary);
    font-size: 1.5rem;
}

.card input, .card select, .card textarea {
    width: 100%;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 16px; /* Prevents zoom on iOS */
}

.card button {
    width: 100%;
    padding: 0.75rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
}

.card button:hover { background: var(--primary-dark); }

.error { color: var(--danger); font-size: 0.875rem; margin-top: 0.5rem; text-align: center; }

.alt-login {
    text-align: center;
    margin: 0.75rem 0;
    color: var(--text-light);
    font-size: 0.875rem;
}

.btn-secondary {
    background: var(--text-light) !important;
}

.btn-danger {
    background: var(--danger) !important;
}

/* Header */
header {
    background: var(--primary);
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

header h1 { font-size: 1.25rem; }

#settings-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
}

/* Content */
.content {
    padding: 1rem;
    max-width: 500px;
    margin: 0 auto;
}

.section {
    background: var(--card-bg);
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.section h3 {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
}

/* QR Scanner */
#qr-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 0.75rem;
    display: none;
}

#qr-container.active { display: block; }

#qr-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#qr-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    border: 3px solid var(--primary);
    border-radius: 12px;
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.5);
}

/* Input */
textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    resize: vertical;
    min-height: 80px;
    margin-bottom: 0.75rem;
}

.btn-row {
    display: flex;
    gap: 0.5rem;
}

.btn-row button {
    flex: 1;
    padding: 0.75rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.btn-full {
    width: 100%;
    padding: 0.75rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

/* File */
#file-input { display: none; }

.file-label {
    display: block;
    padding: 1rem;
    background: var(--bg);
    border: 2px dashed var(--border);
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    margin-bottom: 0.5rem;
}

.file-label:hover {
    border-color: var(--primary);
}

#file-name {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

#send-file-btn {
    width: 100%;
    padding: 0.75rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

/* Status */
#status {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    text-align: center;
}

#status.success { background: #dcfce7; color: var(--success); }
#status.error { background: #fee2e2; color: var(--danger); }
#status.loading { background: #dbeafe; color: var(--primary); }

/* History */
#history {
    max-height: 200px;
    overflow-y: auto;
}

.history-item {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

.history-item:last-child { border: none; }

.history-item .type {
    color: var(--primary);
    font-weight: 500;
}

.history-item .text {
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1rem;
}

.modal-content {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    width: 100%;
    max-width: 360px;
}

.modal-content h2 {
    margin-bottom: 1rem;
}

.modal-content label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-light);
}

.modal-content select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 1rem;
}

.modal-content button {
    width: 100%;
    padding: 0.75rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 0.5rem;
}

#settings-save { background: var(--primary); color: white; }
#settings-logout { background: var(--danger); color: white; }
#settings-close { background: var(--text-light); color: white; }
