/**
 * Common V2 - Shared UI components
 *
 * Requires: theme.css (provides CSS variables)
 */

/* ─────────────────────────────────────────────
   Modal
   ───────────────────────────────────────────── */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--overlay-color);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 16px;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px var(--shadow-color);
}

.modal-content-sm {
    max-width: 360px;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close img {
    width: 20px;
    height: 20px;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.full-app-body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.modal-body p {
    margin: 0 0 10px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

.modal-body a {
    color: var(--accent-primary);
    text-decoration: none;
}

.modal-body a:hover {
    text-decoration: underline;
}

.modal-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-actions .btn {
    flex: 1;
}

.modal-body.notifications {
    padding: 0;
}

.modal-refresh {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, color 0.2s ease;
}

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

.modal-refresh.spinning {
    animation: modal-spin 0.6s linear;
}

@keyframes modal-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.modal-refresh img {
    width: 20px;
    height: 20px;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 0 10px;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    background: var(--bg-card);
    flex-shrink: 0;
    height: 0;
    opacity: 0;
    visibility: hidden;
    transition: height 0.3s ease, opacity 0.3s ease, padding 0.3s ease, visibility 0s 0.3s;
}

.modal-footer.visible {
    height: auto;
    opacity: 1;
    visibility: visible;
    padding: 10px;
    transition: height 0.3s ease, opacity 0.3s ease, padding 0.3s ease, visibility 0s 0s;
}

/* Notification/List Item Styles */
.no-notifications {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.notification-item {
    padding: 15px;
    display: flex;
    gap: 12px;
    transition: background 0.2s ease;
    cursor: pointer;
    position: relative;
}

.notification-item:not(:last-child) {
    border-bottom: 1px solid var(--border-color);
}

.notification-left-area {
    flex-shrink: 0;
    width: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding-top: 6px;
}

.notification-indicator {
    flex-shrink: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-primary);
}

.notification-indicator.read {
    background: transparent;
}

.notification-checkmark {
    width: 16px;
    height: 16px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.notification-item.selected .notification-checkmark {
    opacity: 1;
}

@media (prefers-color-scheme: dark) {
    .notification-checkmark {
        filter: invert(1);
    }
}

.notification-content {
    flex: 1;
    min-width: 0;
}

.notification-type {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.notification-text {
    font-size: 0.95rem;
    color: var(--text-primary);
    line-height: 1.4;
}

.notification-text strong {
    font-weight: 600;
}

.notification-title {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.notification-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.notification-action-text {
    color: var(--text-primary);
    margin-right: auto;
}

.notification-action-link {
    font-weight: 600;
    color: var(--text-primary);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 4px 8px;
    transition: background 0.2s ease;
    border-radius: 4px;
}

.notification-action-link:hover {
    background: var(--bg-hover);
}

/* ─────────────────────────────────────────────
   Links
   ───────────────────────────────────────────── */

.universal-ai a {
    color: var(--link-color);
    text-decoration: none;
}

.universal-ai a:hover {
    text-decoration: underline;
}

/* ─────────────────────────────────────────────
   Markdown
   ───────────────────────────────────────────── */

.markdown ul,
.markdown ol {
    padding-left: 2rem;
    margin: 0.5em 0;
}

.markdown li {
    margin-bottom: 0.25em;
}

.markdown li:last-child {
    margin-bottom: 0;
}

.markdown ul ul,
.markdown ul ol,
.markdown ol ul,
.markdown ol ol {
    margin: 0.25em 0;
}

.markdown li>p:last-child {
    margin-bottom: 0;
}

.markdown .table-scroll {
    overflow-x: auto;
    margin: 0.75em 0;
    -webkit-overflow-scrolling: touch;
}

.markdown .table-scroll table {
    margin: 0;
}

.markdown table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.75em 0;
    font-size: 0.9em;
}

.markdown th,
.markdown td {
    padding: 0.5em 0.75em;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.markdown th {
    font-weight: 600;
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    padding-bottom: 0.6em;
}

.markdown tr:last-child td {
    border-bottom: none;
}

.markdown h1,
.markdown h2,
.markdown h3 {
    margin: 0.75em 0 0.5em;
    font-weight: 600;
}

.markdown h1 {
    font-size: 1.5em;
}

.markdown h2 {
    font-size: 1.3em;
}

.markdown h3 {
    font-size: 1.1em;
}

.markdown p {
    margin: 0.5em 0;
}

.markdown a {
    word-break: break-all;
}

.markdown code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Courier New', 'Courier', monospace;
    font-size: 0.85em;
    border: 1px solid var(--border-color);
}

.markdown pre {
    background: rgba(0, 0, 0, 0.1);
    padding: 8px 10px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 0.5em 0;
    border: 1px solid var(--border-color);
    line-height: 1.4;
}

.markdown pre code {
    background: transparent;
    padding: 0;
    border: none;
    font-size: 0.85em;
    white-space: pre-wrap;
    word-break: break-word;
}

.markdown blockquote {
    border-left: 3px solid var(--border-color);
    padding-left: 12px;
    margin: 0.5em 0;
    opacity: 0.9;
}

/* ─────────────────────────────────────────────
   Buttons
   ───────────────────────────────────────────── */

.btn {
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background 0.15s ease, opacity 0.15s ease;
}

.btn-primary {
    background: var(--accent-primary);
    color: var(--text-on-accent);
}

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

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

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

.btn-danger:hover {
    opacity: 0.9;
}

.btn-round {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--accent-primary);
    color: var(--text-on-accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.btn-round:active {
    background: var(--accent-primary-hover);
}

.btn-round img {
    width: 20px;
    height: 20px;
    filter: brightness(0) invert(1);
}

/* ─────────────────────────────────────────────
   Forms
   ───────────────────────────────────────────── */

.form-group {
    margin-bottom: 16px;
}

.form-group:last-child {
    margin-bottom: 0;
}

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

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.95rem;
    box-sizing: border-box;
    transition: border-color 0.15s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}
