/* ===================================================================
   Zero-Knowledge Notes – Dark theme
   =================================================================== */

/* -- Reset & base --------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: system-ui, -apple-system, sans-serif;
    background: #0f0f0f;
    color: #e0e0e0;
    display: flex;
    justify-content: center;
    padding: 2rem 1rem;
    min-height: 100vh;
}

main {
    max-width: 640px;
    width: 100%;
}

/* -- Typography ----------------------------------------------------- */
h1 {
    font-size: 1.6rem;
    margin-bottom: 0.25rem;
    color: #fff;
}

h1::before { content: "\1F512 "; }

h2 {
    font-size: 1.1rem;
    color: #bbb;
    margin-bottom: 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid #2a2a2a;
}

p.subtitle {
    color: #666;
    font-size: 0.85rem;
    margin-bottom: 2rem;
    line-height: 1.4;
}

/* -- Login overlay -------------------------------------------------- */
#login-overlay {
    position: fixed;
    inset: 0;
    background: #0f0f0f;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}

#login-overlay[hidden] {
    display: none;
}

.login-card {
    background: #181818;
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    padding: 2rem 1.5rem;
    max-width: 400px;
    width: 100%;
}

.login-card h1 {
    text-align: center;
    margin-bottom: 0.25rem;
}

.login-card .subtitle {
    text-align: center;
    margin-bottom: 1.5rem;
}

#login-error {
    margin-top: 0.75rem;
    text-align: center;
    font-size: 0.85rem;
}

#login-error[hidden] {
    display: none;
}

/* -- App header with logout ----------------------------------------- */
.app-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.app-header p.subtitle {
    margin-bottom: 1rem;
}

#logout-btn {
    background: #2a2a2a;
    color: #ccc;
    padding: 0.4rem 0.9rem;
    font-size: 0.8rem;
    flex-shrink: 0;
    margin-top: 0.25rem;
}

#logout-btn:hover {
    background: #3a3a3a;
    color: #fff;
}

/* -- Sections ------------------------------------------------------- */
section {
    background: #181818;
    border: 1px solid #2a2a2a;
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

/* -- Form elements -------------------------------------------------- */
textarea,
input[type="text"],
input[type="password"] {
    width: 100%;
    background: #111;
    border: 1px solid #333;
    border-radius: 6px;
    color: #e0e0e0;
    padding: 0.6rem 0.75rem;
    font-family: inherit;
    font-size: 0.9rem;
    margin-bottom: 0.6rem;
    transition: border-color 0.15s;
}

textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.5;
}

textarea:focus,
input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: #4a9eff;
}

textarea::placeholder,
input::placeholder {
    color: #555;
}

/* -- Buttons -------------------------------------------------------- */
button {
    font-family: inherit;
    font-size: 0.9rem;
    border: none;
    border-radius: 6px;
    padding: 0.6rem 1.2rem;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

button[type="submit"] {
    width: 100%;
    background: #4a9eff;
    color: #fff;
    font-weight: 600;
    margin-top: 0.25rem;
}

button[type="submit"]:hover:not(:disabled) {
    background: #3a8eef;
}

/* -- Result area ---------------------------------------------------- */
.result {
    margin-top: 0.75rem;
    background: #111;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    padding: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.result span {
    color: #888;
    font-size: 0.85rem;
}

.result code {
    font-family: "SF Mono", "Fira Code", "Consolas", monospace;
    font-size: 0.85rem;
    color: #4a9eff;
    background: #1a1a2e;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    word-break: break-all;
    flex: 1;
    min-width: 0;
}

#copy-id-btn {
    background: #2a2a2a;
    color: #ccc;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    flex-shrink: 0;
}

#copy-id-btn:hover {
    background: #3a3a3a;
}

/* -- Notes list ----------------------------------------------------- */
.empty-hint {
    color: #555;
    font-size: 0.85rem;
    text-align: center;
    padding: 1rem 0;
}

.empty-hint[hidden] {
    display: none;
}

.note-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    background: #111;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

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

.note-row-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    flex: 1;
}

.note-row-id {
    font-family: "SF Mono", "Fira Code", "Consolas", monospace;
    font-size: 0.85rem;
    color: #4a9eff;
    background: #1a1a2e;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    white-space: nowrap;
}

.note-row-date {
    color: #666;
    font-size: 0.8rem;
    white-space: nowrap;
}

.note-row-actions {
    display: flex;
    gap: 0.35rem;
    flex-shrink: 0;
}

.btn-view,
.btn-delete {
    padding: 0.3rem 0.65rem;
    font-size: 0.78rem;
    border-radius: 4px;
}

.btn-view {
    background: #1a3a5c;
    color: #4a9eff;
}

.btn-view:hover:not(:disabled) {
    background: #234a70;
}

.btn-delete {
    background: #3a1a1a;
    color: #f87171;
}

.btn-delete:hover:not(:disabled) {
    background: #4a2222;
}

/* -- Note detail ---------------------------------------------------- */
#note-detail-section h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.detail-id {
    font-family: "SF Mono", "Fira Code", "Consolas", monospace;
    font-size: 0.85rem;
    color: #4a9eff;
    font-weight: 400;
}

#note-detail-content {
    background: #111;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    padding: 0.75rem;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.5;
    color: #e0e0e0;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 0.75rem;
}

#detail-close-btn {
    background: #2a2a2a;
    color: #ccc;
    padding: 0.4rem 0.9rem;
    font-size: 0.8rem;
}

#detail-close-btn:hover {
    background: #3a3a3a;
    color: #fff;
}

#note-detail-section[hidden] {
    display: none;
}

/* -- Status messages ------------------------------------------------ */
.status {
    text-align: center;
    font-size: 0.85rem;
    padding: 0.5rem;
    border-radius: 6px;
    margin-top: 0.5rem;
    min-height: 1.8rem;
    transition: opacity 0.3s;
}

.status:empty {
    display: none;
}

.status.success {
    color: #4ade80;
    background: #0a2a1a;
    border: 1px solid #1a4a2a;
}

.status.error {
    color: #f87171;
    background: #2a0a0a;
    border: 1px solid #4a1a1a;
}

/* -- Responsive ----------------------------------------------------- */
@media (max-width: 480px) {
    body { padding: 1rem 0.5rem; }
    section { padding: 1rem; }
    .login-card { padding: 1.5rem 1rem; }
    h1 { font-size: 1.3rem; }
    .note-row { flex-direction: column; align-items: flex-start; gap: 0.4rem; }
    .note-row-actions { width: 100%; }
    .btn-view, .btn-delete { flex: 1; text-align: center; }
}
