/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6200EE;
    --primary-dark: #3700B3;
    --secondary-color: #03DAC6;
    --error-color: #B00020;
    --success-color: #00C853;
    --background: #FAFAFA;
    --surface: #FFFFFF;
    --on-surface: #000000;
    --text-secondary: #666666;
    --border: #E0E0E0;
    --shadow: rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    color: var(--on-surface);
    line-height: 1.6;
    padding: 20px;
}

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

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
    padding: 30px 20px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px var(--shadow);
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.9;
    margin-bottom: 20px;
}

/* Status Bar */
.status-bar {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9em;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s infinite;
}

.status-disconnected {
    background: #999;
    animation: none;
}

.status-connecting {
    background: #FFA726;
}

.status-connected {
    background: var(--success-color);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Card */
.card {
    background: var(--surface);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px var(--shadow);
}

.card h2 {
    margin-bottom: 20px;
    color: var(--primary-color);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
}

input[type="text"],
input[type="password"],
textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s;
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.mono-input {
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.input-with-button {
    display: flex;
    gap: 8px;
}

.input-with-button input {
    flex: 1;
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-block;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

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

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

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

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

.btn-secondary {
    background: var(--border);
    color: var(--on-surface);
}

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

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

.btn-small {
    padding: 8px 16px;
    font-size: 0.9em;
}

.icon-button {
    background: transparent;
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 1.2em;
    transition: all 0.3s;
}

.icon-button:hover {
    background: var(--border);
}

.button-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* Info Box */
.info-box {
    background: #F5F5F5;
    border-left: 4px solid var(--secondary-color);
    padding: 16px;
    border-radius: 8px;
    margin: 20px 0;
}

.info-box h3 {
    margin-bottom: 12px;
    color: var(--on-surface);
    font-size: 1em;
}

.pubkey-container {
    display: flex;
    align-items: center;
    gap: 12px;
    background: white;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 8px;
}

.pubkey-container code {
    flex: 1;
    word-break: break-all;
    font-size: 0.85em;
}

.help-text {
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* Stats Section */
.stats-section {
    display: flex;
    justify-content: space-around;
    gap: 20px;
    text-align: center;
}

.stat-item {
    flex: 1;
}

.stat-label {
    display: block;
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.stat-value {
    display: block;
    font-size: 2em;
    font-weight: bold;
    color: var(--primary-color);
}

/* Notifications List */
.notifications-list {
    max-height: 500px;
    overflow-y: auto;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.notification-item {
    background: #F9F9F9;
    border-left: 4px solid var(--primary-color);
    padding: 16px;
    margin-bottom: 12px;
    border-radius: 8px;
    transition: all 0.3s;
}

.notification-item:hover {
    background: #F0F0F0;
    transform: translateX(4px);
}

.notification-item.priority-urgent {
    border-left-color: #D32F2F;
    background: #FFEBEE;
}

.notification-item.priority-high {
    border-left-color: #F57C00;
    background: #FFF3E0;
}

.notification-item.priority-low {
    border-left-color: #7B1FA2;
}

.notification-item.priority-min {
    border-left-color: #999;
    opacity: 0.7;
}

.notification-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 8px;
}

.notification-title {
    font-weight: 600;
    font-size: 1.1em;
    color: var(--on-surface);
}

.notification-time {
    font-size: 0.85em;
    color: var(--text-secondary);
    white-space: nowrap;
}

.notification-message {
    margin-bottom: 8px;
    line-height: 1.5;
}

.notification-meta {
    display: flex;
    gap: 12px;
    font-size: 0.85em;
    color: var(--text-secondary);
}

.notification-badge {
    background: var(--primary-color);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8em;
}

/* Instructions */
.instructions ol {
    padding-left: 24px;
}

.instructions li {
    margin-bottom: 12px;
}

.instructions pre {
    background: #2D2D2D;
    color: #F8F8F2;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin-top: 12px;
}

.instructions code {
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

/* Footer */
footer {
    text-align: center;
    padding: 24px;
    color: var(--text-secondary);
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.toast {
    background: var(--surface);
    color: var(--on-surface);
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    margin-bottom: 12px;
    min-width: 300px;
    animation: slideIn 0.3s ease-out;
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--error-color);
}

.toast.info {
    border-left: 4px solid var(--secondary-color);
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    header h1 {
        font-size: 1.8em;
    }

    .stats-section {
        flex-direction: column;
        gap: 16px;
    }

    .button-group {
        flex-direction: column;
    }

    .button-group .btn {
        width: 100%;
    }

    .pubkey-container {
        flex-direction: column;
    }

    .section-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
}

/* Signer bar */
.signer-bar {
    margin-top: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.signer-bar .btn-small {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.signer-bar .btn-small:hover {
    background: rgba(255, 255, 255, 0.25);
}

.signer-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.15);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 0.9em;
}

.signer-status code {
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
}

.signer-label {
    opacity: 0.85;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border);
}

.tab {
    background: transparent;
    border: none;
    padding: 12px 24px;
    font-size: 1em;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.tab:hover {
    color: var(--primary-color);
}

.tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab.has-unread::after {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success-color);
    margin-left: 8px;
    vertical-align: middle;
    animation: pulse 2s infinite;
}

.tab-panel {
    display: none;
}

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

/* Topics list */
.topics-list {
    list-style: none;
    padding: 0;
    margin: 8px 0 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.topics-list:empty::before {
    content: "No topics yet — add one below to start receiving.";
    color: var(--text-secondary);
    font-size: 0.9em;
    font-style: italic;
}

.topic-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--primary-color);
    color: white;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 0.9em;
}

.topic-chip code {
    font-family: 'Courier New', monospace;
}

.topic-chip button {
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 1.1em;
    line-height: 1;
    padding: 0 2px;
    opacity: 0.7;
}

.topic-chip button:hover {
    opacity: 1;
}

.notification-item .notification-sender {
    font-size: 0.8em;
    font-family: 'Courier New', monospace;
    color: var(--text-secondary);
}

/* Write-mode additions */
select {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1em;
    background: white;
    cursor: pointer;
}

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

input[type="range"] {
    width: 100%;
    accent-color: var(--primary-color);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.help-inline {
    font-weight: normal;
    font-size: 0.85em;
    color: var(--text-secondary);
}

.relay-list {
    list-style: none;
    padding: 0;
    margin: 8px 0 12px;
}

.relay-list li {
    padding: 6px 0;
    font-size: 0.9em;
}

#result-eventid {
    word-break: break-all;
    font-size: 0.85em;
}

@media (max-width: 640px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

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

.notifications-list::-webkit-scrollbar-track {
    background: var(--border);
    border-radius: 4px;
}

.notifications-list::-webkit-scrollbar-thumb {
    background: var(--text-secondary);
    border-radius: 4px;
}

.notifications-list::-webkit-scrollbar-thumb:hover {
    background: var(--on-surface);
}
