/**
 * WRENN Similarity Search Styles
 *
 * Design system (matches search-widget.css):
 * - Font: Palatino Linotype (serif)
 * - Primary color: #EC0505 (WRENN red)
 * - Border radius: 6px (inputs), 8px (containers)
 */

/* ============================================
   CONTAINER
   ============================================ */

.sim-widget {
    font-family: 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
    max-width: 100%;
    padding: 20px;
    box-sizing: border-box;
    color: #1a1a1a;
    line-height: 1.7;
}

.sim-widget * {
    box-sizing: border-box;
}

/* ============================================
   HEADER
   ============================================ */

.sim-header h2 {
    margin: 0 0 20px 0;
    color: #1a1a1a;
    font-size: 1.4rem;
    font-weight: normal;
}

/* ============================================
   SEARCH FORM
   ============================================ */

.sim-form {
    background: #fafafa;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

/* Text input area */
.sim-text-group {
    margin-bottom: 16px;
    position: relative;
}

.sim-text-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    color: #6b7280;
}

.sim-text-input {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    background: white;
    resize: vertical;
    transition: border-color 0.15s;
    line-height: 1.5;
}

.sim-text-input:focus {
    outline: none;
    border-color: #EC0505;
    box-shadow: 0 0 0 3px rgba(236, 5, 5, 0.1);
}

.sim-text-input:disabled {
    background: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
}

.sim-text-input::placeholder {
    color: #9ca3af;
    font-style: italic;
}

/* Lock overlay for disabled text search */
.sim-lock-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(249, 250, 251, 0.85);
    border-radius: 6px;
    cursor: default;
    z-index: 2;
}

.sim-lock-overlay span {
    font-size: 0.9rem;
    color: #6b7280;
    padding: 8px 16px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
}

/* Context bar — shown when searching from a building page */
.sim-context-bar {
    text-align: center;
    padding: 10px 0;
    margin-bottom: 16px;
    font-size: 0.9rem;
    color: #6b7280;
    border-top: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
}

.sim-context-bar strong {
    color: #1a1a1a;
}

/* Filter rows */
.sim-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 16px;
}

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

.sim-filter-group {
    flex: 1;
    min-width: 150px;
}

.sim-filter-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    color: #6b7280;
}

.sim-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    background: white;
    transition: border-color 0.15s;
    appearance: auto;
}

.sim-select:focus {
    outline: none;
    border-color: #EC0505;
    box-shadow: 0 0 0 3px rgba(236, 5, 5, 0.1);
}

.sim-select:disabled {
    background: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
}

/* Button row */
.sim-button-row {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 8px;
}

.sim-search-btn {
    background: #EC0505;
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.15s;
}

.sim-search-btn:hover {
    background: #B00404;
}

.sim-search-btn:disabled {
    background: #d1d5db;
    cursor: not-allowed;
}

.sim-export-btn {
    background: white;
    color: #1a1a1a;
    border: 1px solid #d1d5db;
    padding: 10px 24px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.15s;
}

.sim-export-btn:hover {
    border-color: #EC0505;
    color: #EC0505;
}

/* ============================================
   SCOPE TABS
   ============================================ */

.sim-scope-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid #e5e7eb;
}

.sim-scope-tab {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-size: 0.95rem;
    font-family: inherit;
    color: #6b7280;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.sim-scope-tab:hover {
    color: #1a1a1a;
}

.sim-scope-tab--active {
    color: #EC0505;
    border-bottom-color: #EC0505;
    font-weight: 600;
}

.sim-scope-tab--locked {
    color: #d1d5db;
    cursor: default;
    position: relative;
}

.sim-scope-tab--locked::after {
    content: '\1F512';
    font-size: 0.7rem;
    margin-left: 4px;
}

.sim-scope-tab--locked:hover {
    color: #d1d5db;
}

.sim-tab-count {
    font-size: 0.8rem;
    color: #9ca3af;
    margin-left: 4px;
}

/* ============================================
   RESULTS
   ============================================ */

.sim-results {
    min-height: 100px;
}

.sim-result-count {
    font-size: 0.85rem;
    color: #6b7280;
    margin-bottom: 16px;
}

/* Result card */
.sim-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 12px;
    transition: box-shadow 0.15s;
}

.sim-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Card header: badge + name + grade */
.sim-card-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 6px;
}

.sim-badge {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1;
}

.sim-badge--high {
    background: #EC0505;
}

.sim-badge--good {
    background: #DD4444;
}

.sim-badge--moderate {
    background: #888888;
}

.sim-card-title {
    flex: 1;
    min-width: 0;
}

.sim-card-name {
    font-size: 1.05rem;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0;
    line-height: 1.3;
}

.sim-card-name a {
    color: inherit;
    text-decoration: none;
}

.sim-card-name a:hover {
    color: #EC0505;
}

.sim-card-grade {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    vertical-align: middle;
    margin-left: 8px;
}

.sim-card-grade--I {
    background: #D4A017;
}

.sim-card-grade--IIstar {
    background: #6B7B8D;
}

.sim-card-grade--II {
    background: #A67B5B;
}

/* Card metadata line */
.sim-card-meta {
    font-size: 0.85rem;
    color: #6b7280;
    margin: 4px 0 8px 58px;
}

.sim-card-meta span + span::before {
    content: ' \00B7 ';
    color: #d1d5db;
}

/* Card description excerpt */
.sim-card-excerpt {
    font-size: 0.88rem;
    color: #4b5563;
    margin: 0 0 10px 58px;
    font-style: italic;
    line-height: 1.5;
}

/* Application summary line */
.sim-card-apps {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 10px 0 0 58px;
    padding-top: 10px;
    border-top: 1px solid #f3f4f6;
    font-size: 0.85rem;
    color: #6b7280;
}

.sim-view-apps-btn {
    background: none;
    border: 1px solid #d1d5db;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-family: inherit;
    color: #6b7280;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.sim-view-apps-btn:hover {
    border-color: #EC0505;
    color: #EC0505;
}

.sim-view-apps-btn--loading {
    pointer-events: none;
    color: #d1d5db;
}

/* Expanded application list */
.sim-app-list {
    margin: 10px 0 0 58px;
    padding: 0;
    list-style: none;
}

.sim-app-item {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 6px 0;
    font-size: 0.85rem;
    border-bottom: 1px solid #f9fafb;
}

.sim-app-item:last-child {
    border-bottom: none;
}

.sim-app-icon {
    flex-shrink: 0;
    font-size: 0.8rem;
}

.sim-app-icon--approved { color: #2D8A4E; }
.sim-app-icon--refused { color: #EC0505; }
.sim-app-icon--withdrawn { color: #888888; }
.sim-app-icon--pending { color: #D4A017; }

.sim-app-desc {
    flex: 1;
    min-width: 0;
    color: #4b5563;
}

.sim-app-decision {
    flex-shrink: 0;
    font-size: 0.8rem;
    padding: 1px 6px;
    border-radius: 3px;
}

.sim-app-decision--approved {
    color: #2D8A4E;
    background: #ecfdf5;
}

.sim-app-decision--refused {
    color: #EC0505;
    background: #fef2f2;
}

.sim-app-decision--withdrawn {
    color: #888888;
    background: #f3f4f6;
}

.sim-app-decision--pending {
    color: #D4A017;
    background: #fffbeb;
}

.sim-app-year {
    flex-shrink: 0;
    color: #9ca3af;
    font-size: 0.8rem;
    min-width: 40px;
    text-align: right;
}

.sim-app-attrs {
    margin: 4px 0 0 20px;
}

.sim-app-attr-tag {
    display: inline-block;
    font-size: 0.7rem;
    padding: 1px 6px;
    background: #f3f4f6;
    border-radius: 3px;
    color: #6b7280;
    margin: 2px 2px 0 0;
}

/* ============================================
   STATES: LOADING, EMPTY, ERROR, SIGN-IN
   ============================================ */

.sim-loading {
    text-align: center;
    padding: 40px 0;
    color: #6b7280;
}

.sim-spinner {
    display: inline-block;
    width: 28px;
    height: 28px;
    border: 3px solid #e5e7eb;
    border-top-color: #EC0505;
    border-radius: 50%;
    animation: sim-spin 0.6s linear infinite;
    margin-bottom: 10px;
}

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

.sim-empty,
.sim-error {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
    font-size: 0.95rem;
}

.sim-error {
    color: #EC0505;
}

.sim-signin-prompt {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
}

.sim-signin-prompt a {
    color: #EC0505;
    text-decoration: none;
    font-weight: 600;
}

.sim-signin-prompt a:hover {
    text-decoration: underline;
}

/* ============================================
   UPGRADE BANNER
   ============================================ */

.sim-upgrade-banner {
    background: #fafafa;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px 20px;
    margin-top: 20px;
    text-align: center;
    font-size: 0.9rem;
    color: #6b7280;
}

.sim-upgrade-banner a {
    color: #EC0505;
    text-decoration: none;
    font-weight: 600;
}

.sim-upgrade-banner a:hover {
    text-decoration: underline;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .sim-widget {
        padding: 12px;
    }

    .sim-form {
        padding: 14px;
    }

    .sim-filter-row {
        gap: 10px;
    }

    .sim-filter-group {
        min-width: 120px;
    }

    .sim-scope-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .sim-scope-tab {
        padding: 8px 14px;
        font-size: 0.88rem;
    }

    .sim-card {
        padding: 14px;
    }

    .sim-card-meta,
    .sim-card-excerpt,
    .sim-card-apps,
    .sim-app-list {
        margin-left: 0;
    }

    .sim-card-header {
        gap: 10px;
    }

    .sim-badge {
        width: 38px;
        height: 38px;
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .sim-filter-row {
        flex-direction: column;
    }

    .sim-filter-group {
        min-width: 100%;
    }

    .sim-card-apps {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .sim-app-item {
        flex-wrap: wrap;
    }
}
