/*--------------------------------------------------------------
 * Notion WP Sync Pro — Frontend Styles
 *
 * Two modes:
 *   .nwsp-notion-style  → Mimics Notion's native look
 *   .nwsp-theme-style   → Inherits the active WP theme
 *
 * Toggle via admin setting or frontend JS toggle.
 *--------------------------------------------------------------*/

/* ============================================================
   CSS Custom Properties (Notion palette)
   ============================================================ */

:root {
    /* Notion-style defaults */
    --nwsp-font-sans:       -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    --nwsp-font-mono:       'SFMono-Regular', Menlo, Consolas, 'Liberation Mono', monospace;
    --nwsp-font-serif:      Lyon-Text, Georgia, 'YuMincho', 'Yu Mincho', serif;

    --nwsp-text-color:      #37352f;
    --nwsp-text-muted:      #6b6b6b;
    --nwsp-bg:              #ffffff;
    --nwsp-border:          #e9e9e7;
    --nwsp-radius:          6px;
    --nwsp-spacing:         1rem;

    /* Notion callout backgrounds */
    --notion-callout-bg:    #f5f5f5;
    --notion-callout-text:  #37352f;
}

/* ============================================================
   Notion Vibe Style (.nwsp-notion-style)
   ============================================================ */

.nwsp-notion-style {
    font-family: var(--nwsp-font-sans);
    color: var(--nwsp-text-color);
    line-height: 1.7;
}

/* --- Callout (Notion style) --- */
.notion-callout.nwsp-notion-style {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 16px 16px 14px;
    border-radius: var(--nwsp-radius);
    background-color: var(--notion-callout-bg, #f5f5f5);
    color: var(--notion-callout-text, #37352f);
    margin-bottom: var(--nwsp-spacing);
    font-size: 0.95rem;
}

.notion-callout-icon {
    flex-shrink: 0;
    font-size: 1.3em;
    line-height: 1;
    margin-top: 2px;
}

.notion-callout-icon img {
    width: 22px;
    height: 22px;
    object-fit: contain;
}

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

/* --- Toggle (Notion style) --- */
.notion-toggle.nwsp-notion-style {
    margin-bottom: var(--nwsp-spacing);
    border: none;
}

.notion-toggle.nwsp-notion-style summary {
    cursor: pointer;
    font-weight: 600;
    padding: 6px 0;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.notion-toggle.nwsp-notion-style summary::before {
    content: '▶';
    font-size: 0.65em;
    transition: transform 0.2s ease;
    display: inline-block;
    color: var(--nwsp-text-muted);
}

.notion-toggle.nwsp-notion-style[open] > summary::before {
    transform: rotate(90deg);
}

.notion-toggle.nwsp-notion-style summary::-webkit-details-marker {
    display: none;
}

/* --- Quote (Notion style) --- */
.notion-quote.nwsp-notion-style {
    border-left: 3px solid var(--nwsp-text-color);
    padding: 4px 0 4px 16px;
    margin: var(--nwsp-spacing) 0;
    font-size: 1.1em;
}

/* ============================================================
   WordPress Theme Style (.nwsp-theme-style)
   Minimal overrides — let the theme handle everything.
   ============================================================ */

.notion-callout.nwsp-theme-style {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 1em;
    border-radius: 4px;
    border: 1px solid var(--nwsp-border, #ddd);
    margin-bottom: 1em;
}

.notion-toggle.nwsp-theme-style {
    margin-bottom: 1em;
}

.notion-toggle.nwsp-theme-style summary {
    cursor: pointer;
    font-weight: 600;
}

.notion-quote.nwsp-theme-style {
    /* Let theme blockquote styles apply. */
}

/* ============================================================
   Notion text colors (both modes)
   ============================================================ */

.nwsp-color-gray          { color: #9b9a97; }
.nwsp-color-brown         { color: #64473a; }
.nwsp-color-orange        { color: #d9730d; }
.nwsp-color-yellow        { color: #dfab01; }
.nwsp-color-green         { color: #0f7b6c; }
.nwsp-color-blue          { color: #0b6e99; }
.nwsp-color-purple        { color: #6940a5; }
.nwsp-color-pink          { color: #ad1a72; }
.nwsp-color-red           { color: #e03e3e; }

.nwsp-color-gray_background   { background-color: #ebeced; padding: 2px 6px; border-radius: 3px; }
.nwsp-color-brown_background  { background-color: #e9e5e3; padding: 2px 6px; border-radius: 3px; }
.nwsp-color-orange_background { background-color: #faebdd; padding: 2px 6px; border-radius: 3px; }
.nwsp-color-yellow_background { background-color: #fbf3db; padding: 2px 6px; border-radius: 3px; }
.nwsp-color-green_background  { background-color: #ddedea; padding: 2px 6px; border-radius: 3px; }
.nwsp-color-blue_background   { background-color: #ddebf1; padding: 2px 6px; border-radius: 3px; }
.nwsp-color-purple_background { background-color: #eae4f2; padding: 2px 6px; border-radius: 3px; }
.nwsp-color-pink_background   { background-color: #f4dfeb; padding: 2px 6px; border-radius: 3px; }
.nwsp-color-red_background    { background-color: #fbe4e4; padding: 2px 6px; border-radius: 3px; }

/* ============================================================
   Refresh Button
   ============================================================ */

.nwsp-refresh-wrapper {
    margin: 2rem 0;
    text-align: center;
}

.nwsp-refresh-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    background: #2271b1;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}

.nwsp-refresh-btn:hover {
    background: #135e96;
}

.nwsp-refresh-btn:active {
    transform: scale(0.97);
}

.nwsp-refresh-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.nwsp-refresh-btn .nwsp-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: nwsp-spin 0.6s linear infinite;
}

.nwsp-refresh-btn.loading .nwsp-spinner {
    display: inline-block;
}

@keyframes nwsp-spin {
    to { transform: rotate(360deg); }
}

.nwsp-refresh-message {
    margin-top: 0.75rem;
    font-size: 0.85rem;
}

.nwsp-refresh-message.success {
    color: #0f7b6c;
}

.nwsp-refresh-message.error {
    color: #e03e3e;
}

/* ============================================================
   Frontend Style Toggle Button
   ============================================================ */

.nwsp-style-toggle-wrapper {
    margin: 1rem 0;
    text-align: right;
}

.nwsp-style-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--nwsp-text-muted, #6b6b6b);
    background: transparent;
    border: 1px solid var(--nwsp-border, #e9e9e7);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nwsp-style-toggle-btn:hover {
    color: var(--nwsp-text-color, #37352f);
    border-color: var(--nwsp-text-muted, #aaa);
}

/* ============================================================
   Database View — Shared
   ============================================================ */

.nwsp-database-view {
    margin: 2rem 0;
    font-family: var(--nwsp-font-sans);
    color: var(--nwsp-text-color);
}

.nwsp-dbv-title {
    margin: 0 0 1rem;
    font-size: 1.25rem;
    font-weight: 700;
}

.nwsp-dbv-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 1rem;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--nwsp-border, #e9e9e7);
}

.nwsp-dbv-view-switcher {
    display: flex;
    gap: 2px;
}

.nwsp-dbv-view-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--nwsp-text-muted, #6b6b6b);
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.nwsp-dbv-view-btn:hover {
    background: rgba(55,53,47,0.08);
    color: var(--nwsp-text-color);
}

.nwsp-dbv-view-btn.active {
    background: rgba(55,53,47,0.08);
    color: var(--nwsp-text-color);
    font-weight: 600;
}

/* Tags */
.nwsp-dbv-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
}

.nwsp-dbv-tag-default   { background: #e3e2e0; color: #37352f; }
.nwsp-dbv-tag-gray      { background: #e3e2e0; color: #37352f; }
.nwsp-dbv-tag-brown     { background: #eee0da; color: #442f21; }
.nwsp-dbv-tag-orange    { background: #fadec9; color: #73400c; }
.nwsp-dbv-tag-yellow    { background: #fdecc8; color: #7c5c00; }
.nwsp-dbv-tag-green     { background: #dbeddb; color: #1a5c2c; }
.nwsp-dbv-tag-blue      { background: #d3e5ef; color: #183b56; }
.nwsp-dbv-tag-purple    { background: #e8deee; color: #412b6e; }
.nwsp-dbv-tag-pink      { background: #f5e0e9; color: #6e1f4a; }
.nwsp-dbv-tag-red       { background: #ffe2dd; color: #6e2120; }

/* ── Table View ─────────────────────────────── */

.nwsp-dbv-table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--nwsp-border, #e9e9e7);
    border-radius: var(--nwsp-radius, 6px);
}

.nwsp-dbv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.nwsp-dbv-table th {
    background: #f7f6f3;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--nwsp-text-muted, #6b6b6b);
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid var(--nwsp-border);
    white-space: nowrap;
}

.nwsp-dbv-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: top;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nwsp-dbv-table tr:last-child td {
    border-bottom: none;
}

.nwsp-dbv-table tr:hover td {
    background: #fafafa;
}

/* ── Gallery View ───────────────────────────── */

.nwsp-dbv-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.nwsp-dbv-gallery-card {
    border: 1px solid var(--nwsp-border, #e9e9e7);
    border-radius: var(--nwsp-radius, 6px);
    overflow: hidden;
    transition: box-shadow 0.2s;
    background: #fff;
}

.nwsp-dbv-gallery-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

.nwsp-dbv-gallery-cover {
    height: 160px;
    overflow: hidden;
    background: #f7f6f3;
}

.nwsp-dbv-gallery-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.nwsp-dbv-gallery-body {
    padding: 14px;
}

.nwsp-dbv-gallery-title {
    margin: 0 0 8px;
    font-size: 0.95rem;
    font-weight: 600;
}

.nwsp-dbv-gallery-prop {
    display: flex;
    gap: 6px;
    margin-top: 4px;
    font-size: 0.8rem;
}

.nwsp-dbv-prop-label {
    color: var(--nwsp-text-muted, #6b6b6b);
    flex-shrink: 0;
}

/* ── List View ──────────────────────────────── */

.nwsp-dbv-list {
    display: flex;
    flex-direction: column;
}

.nwsp-dbv-list-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.15s;
}

.nwsp-dbv-list-item:hover {
    background: #fafafa;
}

.nwsp-dbv-list-title {
    font-weight: 600;
    font-size: 0.9rem;
    min-width: 200px;
    flex-shrink: 0;
}

.nwsp-dbv-list-props {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    font-size: 0.8rem;
    color: var(--nwsp-text-muted);
}

.nwsp-dbv-list-prop .nwsp-dbv-prop-label {
    font-weight: 500;
}

/* ── Kanban View ────────────────────────────── */

.nwsp-dbv-kanban {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.nwsp-dbv-kanban-column {
    min-width: 260px;
    max-width: 300px;
    flex-shrink: 0;
    background: #f7f6f3;
    border-radius: var(--nwsp-radius, 6px);
    padding: 0;
}

.nwsp-dbv-kanban-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--nwsp-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.nwsp-dbv-kanban-count {
    background: rgba(55,53,47,0.08);
    border-radius: 10px;
    padding: 0 8px;
    font-size: 0.75rem;
}

.nwsp-dbv-kanban-cards {
    padding: 0 8px 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nwsp-dbv-kanban-card {
    background: #fff;
    border-radius: 4px;
    padding: 10px 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
    transition: box-shadow 0.15s;
}

.nwsp-dbv-kanban-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.nwsp-dbv-kanban-card-title {
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 4px;
}

.nwsp-dbv-kanban-card-prop {
    font-size: 0.8rem;
    color: var(--nwsp-text-muted);
    margin-top: 2px;
}

/* Error / empty states */
.nwsp-db-error,
.nwsp-db-empty {
    padding: 1rem;
    text-align: center;
    color: var(--nwsp-text-muted);
    font-style: italic;
}
