/* ============================================================
   RULES OF PLAY GENERATOR STYLES
   ============================================================ */

/* Bento card glow for ROP */
.rop-glow { background: radial-gradient(circle at 30% 30%, rgba(99,91,255,0.12), transparent 60%); }
.bento-icon.rop { background: rgba(99,91,255,0.15); color: #635BFF; }

/* Container */
.rop-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    width: 100%;
    overflow-y: auto;
    padding: 24px 20px 60px;
}

/* Views */
.rop-view { animation: ropFadeIn 0.2s ease; }
@keyframes ropFadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Page header */
.rop-page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}
.rop-page-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 4px 0 0;
}

/* List view */
.rop-list-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    gap: 16px;
}
.rop-list-header .btn-primary {
    white-space: nowrap;
}

.rop-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}
.rop-empty-state h3 { color: var(--text-primary); margin: 12px 0 8px; }
.rop-empty-state p { font-size: 0.9rem; }

/* Disclaimer */
.rop-disclaimer {
    background: #FFF8E1;
    border: 1px solid #FFE082;
    border-radius: var(--radius-md);
    padding: 12px 16px;
    font-size: 0.82rem;
    color: #5D4037;
    margin-bottom: 24px;
    line-height: 1.5;
}

/* Drafts table */
.rop-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}
.rop-table th {
    text-align: left;
    padding: 10px 12px;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}
.rop-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}
.rop-draft-row {
    cursor: pointer;
    transition: background 0.15s;
}
.rop-draft-row:hover {
    background: var(--bg-alt);
}
.rop-draft-name {
    font-weight: 500;
}
.rop-type-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: var(--radius-pill);
    font-size: 0.76rem;
    font-weight: 500;
    background: color-mix(in srgb, var(--type-color, #888) 15%, transparent);
    color: var(--type-color, #888);
}
.rop-status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: var(--radius-pill);
    font-size: 0.76rem;
    font-weight: 500;
    text-transform: capitalize;
}
.rop-status-draft { background: #f0f0f0; color: #666; }
.rop-status-generated { background: rgba(16,185,129,0.12); color: #059669; }
.rop-status-finalized { background: rgba(59,130,246,0.12); color: #2563eb; }
.rop-status-in_review { background: rgba(245,158,11,0.12); color: #d97706; }
.rop-status-approved { background: rgba(16,185,129,0.12); color: #047857; }

.rop-delete-btn,
.rop-clone-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    opacity: 0.4;
    transition: opacity 0.15s;
    padding: 4px 8px;
}
.rop-delete-btn:hover { opacity: 1; color: var(--danger); }
.rop-clone-btn:hover { opacity: 1; color: var(--cta); }

/* Back button */
.rop-back-btn {
    background: none;
    border: none;
    color: var(--cta);
    cursor: pointer;
    font-size: 0.88rem;
    padding: 0;
    margin-bottom: 16px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.rop-back-btn:hover { text-decoration: underline; }

/* Type cards */
.rop-type-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.rop-type-card {
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--bg-primary);
}
.rop-type-card:hover {
    border-color: var(--cta);
    box-shadow: var(--shadow-md);
}
.rop-type-card.selected {
    border-color: var(--cta);
    box-shadow: 0 0 0 3px rgba(99,91,255,0.15);
}
.rop-type-card h4 {
    margin: 12px 0 6px;
    font-size: 1rem;
    color: var(--text-primary);
}
.rop-type-card p {
    margin: 0;
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.4;
}
.rop-type-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

/* Jurisdiction */
.rop-jurisdiction-row {
    display: flex;
    gap: 12px;
}
.rop-select {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
}
.rop-coming-soon {
    margin-top: 12px;
    padding: 16px;
    background: var(--bg-alt);
    border-radius: var(--radius-md);
    text-align: center;
    font-size: 0.88rem;
    color: var(--text-secondary);
}
.rop-coming-soon .btn-primary { margin-top: 12px; }

.rop-proceed-btn {
    margin-top: 24px;
    width: 100%;
    padding: 14px;
    font-size: 1rem;
}

/* Sections */
.rop-section {
    margin-bottom: 20px;
}
.rop-section-label {
    display: block;
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* Form */
.rop-form-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.rop-form-header-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.rop-form-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.rop-badge {
    display: inline-block;
    padding: 3px 12px;
    border-radius: var(--radius-pill);
    font-size: 0.76rem;
    font-weight: 500;
    background: color-mix(in srgb, var(--type-color, #888) 15%, transparent);
    color: var(--type-color, #888);
}
.rop-autosave-status {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.rop-progress-bar-wrapper {
    margin-bottom: 20px;
    padding: 12px 16px;
    background: var(--bg-alt);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}
.rop-progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.rop-progress-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.rop-progress-pct {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--cta);
}
.rop-progress-track {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}
.rop-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #635BFF, #8B5CF6);
    border-radius: 3px;
    transition: width 0.4s ease;
}

/* Section completion indicator */
.rop-section-header .rop-section-check {
    font-size: 0.75rem;
    margin-left: 8px;
    color: #059669;
}

/* ============================================================
   WORKFLOW / APPROVAL BAR
   ============================================================ */
.rop-workflow-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 20px;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.rop-workflow-steps {
    display: flex;
    align-items: center;
    gap: 0;
}
.rop-wf-step {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    transition: all 0.2s;
    white-space: nowrap;
}
.rop-wf-step.active {
    color: var(--cta);
    font-weight: 600;
}
.rop-wf-step.completed {
    color: #059669;
}
.rop-wf-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    flex-shrink: 0;
}
.rop-wf-step.active .rop-wf-dot {
    background: var(--cta);
    box-shadow: 0 0 0 3px rgba(99,91,255,0.2);
}
.rop-wf-step.completed .rop-wf-dot {
    background: #059669;
}
.rop-wf-line {
    width: 24px;
    height: 2px;
    background: var(--border);
    flex-shrink: 0;
}
.rop-workflow-actions {
    display: flex;
    gap: 8px;
}
.rop-wf-action-btn {
    font-size: 0.78rem;
    padding: 6px 12px;
}

/* ============================================================
   REFINEMENT BUTTONS
   ============================================================ */
.rop-refinement-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.rop-refinement-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.rop-refine-btn {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 5px 14px;
    font-size: 0.78rem;
    font-family: inherit;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.rop-refine-btn:hover {
    border-color: var(--cta);
    color: var(--cta);
    background: rgba(99,91,255,0.06);
}
.rop-refine-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.rop-refine-btn.loading {
    pointer-events: none;
    opacity: 0.6;
}

/* ============================================================
   EDIT / PREVIEW TOGGLE
   ============================================================ */
.rop-output-mode-toggle {
    display: flex;
    gap: 0;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    width: fit-content;
}
.rop-mode-btn {
    background: var(--bg-primary);
    border: none;
    padding: 7px 20px;
    font-size: 0.82rem;
    font-family: inherit;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s;
}
.rop-mode-btn:not(:last-child) {
    border-right: 1px solid var(--border);
}
.rop-mode-btn.active {
    background: var(--cta);
    color: #fff;
    font-weight: 500;
}

/* Rich Preview */
.rop-output-preview {
    width: 100%;
    min-height: 500px;
    padding: 32px 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: #fff;
    font-size: 0.92rem;
    line-height: 1.8;
    color: var(--text-primary);
    overflow-y: auto;
    box-sizing: border-box;
}
.rop-output-preview h1 {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0 0 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border);
    color: var(--text-primary);
}
.rop-output-preview h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 24px 0 10px;
    color: var(--text-primary);
}
.rop-output-preview h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 18px 0 8px;
    color: var(--text-primary);
}
.rop-output-preview p {
    margin: 0 0 10px;
}
.rop-output-preview ul, .rop-output-preview ol {
    margin: 0 0 12px;
    padding-left: 24px;
}
.rop-output-preview li {
    margin-bottom: 4px;
}
.rop-output-preview strong {
    font-weight: 600;
}
.rop-output-preview hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}
.rop-output-preview table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 0.86rem;
}
.rop-output-preview th, .rop-output-preview td {
    padding: 8px 12px;
    border: 1px solid var(--border);
    text-align: left;
}
.rop-output-preview th {
    background: var(--bg-alt);
    font-weight: 600;
}

/* ============================================================
   EXPORT DROPDOWN
   ============================================================ */
.rop-export-dropdown {
    position: relative;
}
.rop-export-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    min-width: 160px;
    overflow: hidden;
}
.rop-export-menu.open {
    display: block;
}
.rop-export-option {
    display: block;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: none;
    text-align: left;
    font-size: 0.84rem;
    font-family: inherit;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s;
}
.rop-export-option:hover {
    background: var(--bg-alt);
}

/* ============================================================
   VERSION HISTORY
   ============================================================ */
.rop-version-list {
    margin-bottom: 24px;
}
.rop-version-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    background: var(--bg-primary);
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.rop-version-card:hover {
    border-color: var(--cta);
    box-shadow: var(--shadow-sm);
}
.rop-version-card.active {
    border-color: var(--cta);
    box-shadow: 0 0 0 2px rgba(99,91,255,0.15);
}
.rop-version-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.rop-version-label {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-primary);
}
.rop-version-meta {
    font-size: 0.76rem;
    color: var(--text-muted);
}
.rop-version-actions {
    display: flex;
    gap: 8px;
}
.rop-version-badge {
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    background: rgba(99,91,255,0.1);
    color: #635BFF;
    font-weight: 500;
}
.rop-version-badge.current {
    background: rgba(16,185,129,0.12);
    color: #059669;
}

/* Diff display */
.rop-diff-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.rop-diff-header h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary);
}
.rop-diff-content {
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: #fff;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.82rem;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre-wrap;
}
.rop-diff-add {
    background: rgba(16,185,129,0.1);
    color: #047857;
}
.rop-diff-remove {
    background: rgba(239,68,68,0.1);
    color: #dc2626;
    text-decoration: line-through;
}

/* Form sections (collapsible) */
.rop-form-section {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    background: var(--bg-primary);
    overflow: hidden;
}
.rop-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}
.rop-section-header:hover { background: var(--bg-alt); }
.rop-section-header h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
}
.rop-section-toggle {
    font-size: 0.7rem;
    color: var(--text-muted);
    transition: transform 0.2s;
}
.rop-form-section.collapsed .rop-section-body { display: none; }
.rop-form-section.collapsed .rop-section-toggle { transform: rotate(-90deg); }

.rop-section-body {
    padding: 4px 20px 20px;
}

/* Form fields */
.rop-form-group {
    margin-bottom: 14px;
}
.rop-field-label {
    display: block;
    font-weight: 500;
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.rop-input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-primary);
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.rop-input:focus {
    outline: none;
    border-color: var(--cta);
    box-shadow: 0 0 0 3px rgba(99,91,255,0.1);
}
textarea.rop-input { resize: vertical; min-height: 60px; }

.rop-prefilled-field .rop-input {
    background: var(--bg-alt);
}
.rop-prefilled {
    background: var(--bg-alt);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-size: 0.84rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 14px;
}

.rop-field-hint {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: 0 0 12px;
    line-height: 1.5;
}

.rop-toggle-row {
    margin-bottom: 10px;
}
.rop-toggle-row label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.86rem;
    color: var(--text-primary);
    cursor: pointer;
}

/* Repeatable groups */
.rop-subsection {
    margin-bottom: 14px;
}
.rop-repeatable-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.rop-repeat-field {
    flex: 1;
    min-width: 120px;
}
.rop-repeat-field label {
    display: block;
    font-size: 0.76rem;
    color: var(--text-muted);
    margin-bottom: 2px;
}
.rop-repeat-field .rop-input {
    font-size: 0.84rem;
    padding: 7px 10px;
}
.rop-remove-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 6px;
    flex-shrink: 0;
    transition: color 0.15s;
}
.rop-remove-btn:hover { color: var(--danger); }
.rop-add-btn {
    background: none;
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 8px 16px;
    cursor: pointer;
    color: var(--cta);
    font-size: 0.82rem;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s;
    width: 100%;
    margin-top: 4px;
}
.rop-add-btn:hover { background: var(--bg-alt); border-color: var(--cta); }

/* 50/50 Draw blocks */
.rop-draw-block {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 12px;
    background: var(--bg-alt);
}
.rop-draw-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.rop-draw-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.rop-draw-fields .rop-repeat-field { min-width: auto; }

/* Upload area */
.rop-upload-area {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
#ropUploadStatus {
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* Output view */
.rop-output-textarea {
    width: 100%;
    min-height: 500px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.88rem;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    resize: vertical;
    box-sizing: border-box;
}
.rop-output-textarea:focus {
    outline: none;
    border-color: var(--cta);
    box-shadow: 0 0 0 3px rgba(99,91,255,0.1);
}

/* Generating spinner */
.rop-generating {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-secondary);
}
.rop-generating h3 { color: var(--text-primary); margin: 20px 0 8px; }
.rop-generating p { font-size: 0.88rem; }
.rop-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--cta);
    border-radius: 50%;
    margin: 0 auto;
    animation: ropSpin 0.8s linear infinite;
}
@keyframes ropSpin { to { transform: rotate(360deg); } }

/* Button styles - reuse existing .btn-primary, .btn-secondary from design system */
.rop-form-actions .btn-secondary {
    padding: 8px 14px;
    font-size: 0.82rem;
}
.rop-form-actions .btn-primary {
    padding: 8px 18px;
    font-size: 0.82rem;
}

/* Responsive */
@media (max-width: 768px) {
    .rop-type-cards { grid-template-columns: 1fr; }
    .rop-jurisdiction-row { flex-direction: column; }
    .rop-form-header { flex-direction: column; align-items: flex-start; }
    .rop-draw-fields { grid-template-columns: 1fr; }
    .rop-list-header { flex-direction: column; }
    .rop-table { font-size: 0.82rem; }
    .rop-table th:nth-child(3),
    .rop-table td:nth-child(3),
    .rop-table th:nth-child(5),
    .rop-table td:nth-child(5) { display: none; }
    .rop-workflow-bar { flex-direction: column; }
    .rop-refinement-bar { gap: 6px; }
    .rop-refine-btn { padding: 4px 10px; font-size: 0.74rem; }
}
