/* Shared styles for Dissertation Generator and Editor */

/* --- Card & Section Styles --- */
.card {
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid var(--border-color, #e5e7eb);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary, #111827);
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.section-title i {
    color: var(--primary-color, #127ae0);
    opacity: 0.9;
}

.section-description {
    color: var(--text-secondary, #6b7280);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 1.25rem;
}

/* --- Form Elements --- */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary, #212529);
}

.form-group textarea,
.form-group input[type="text"],
.form-group input[type="number"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.2s;
}

.form-group textarea:focus,
.form-group input:focus {
    outline: none;
    border-color: var(--primary-color, #127ae0);
    box-shadow: 0 0 0 3px rgba(18, 122, 224, 0.1);
}

/* --- Grid System (from criteria.js & editor) --- */
.criteria-standard-card {
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
    padding: 1.25rem;
}

.criteria-standard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.criteria-standard-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-primary, #0f172a);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.criteria-standard-total {
    background: #0ea5e9;
    color: #fff;
    border-radius: 10px;
    padding: 0.4rem 0.75rem;
    font-weight: 800;
    font-size: 0.95rem;
}

.criteria-standard-desc {
    margin: 0.35rem 0 1rem 0;
    color: var(--text-secondary, #475569);
    font-size: 0.95rem;
}

.criteria-standard-list {
    display: grid;
    gap: 0.65rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.criteria-standard-item {
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 10px;
    background: #f8fafc;
    overflow: hidden;
    transition: all 0.2s ease;
}

.criteria-standard-item.expanded {
    background: #fff;
    border-color: #cbd5e1;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.criteria-item-header {
    padding: 0.85rem 0.95rem;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.75rem;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.criteria-item-header:hover {
    background-color: #f1f5f9;
}

.criteria-expand-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: #64748b;
    border-radius: 50%;
    transition: transform 0.2s ease;
    font-size: 0.9rem;
}

.criteria-standard-item.expanded .criteria-expand-btn {
    transform: rotate(180deg);
    color: #0f172a;
    background: #e2e8f0;
}

.criteria-standard-name {
    font-weight: 700;
    color: var(--text-primary, #0f172a);
    margin: 0;
}

.criteria-standard-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-left: auto;
}

.criteria-standard-weight {
    font-weight: 800;
    color: var(--text-primary, #0f172a);
    background: #e0f2fe;
    padding: 0.25rem 0.55rem;
    border-radius: 8px;
}

.criteria-standard-guide-summary {
    grid-column: 2/-1;
    margin: 0;
    color: var(--text-secondary, #475569);
    font-size: 0.9rem;
}

.criteria-barem-btn {
    border: 1px solid rgba(59, 130, 246, 0.35);
    color: #2563eb;
    background: #fff;
    border-radius: 8px;
    padding: 0.35rem 0.65rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    z-index: 2;
    position: relative;
}

.criteria-barem-btn:hover {
    background: rgba(59, 130, 246, 0.08);
}

/* Expanded Details */
.criteria-details-panel {
    display: none;
    border-top: 1px solid #e2e8f0;
    padding: 1rem 1.25rem;
    background: #fff;
    animation: slideDown 0.2s ease-out;
}

.criteria-standard-item.expanded .criteria-details-panel {
    display: block;
}

.criteria-details-section {
    margin-bottom: 1rem;
}

.criteria-details-section:last-child {
    margin-bottom: 0;
}

.criteria-details-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 0.5rem;
}

.criteria-details-text {
    font-size: 0.95rem;
    color: #334155;
    line-height: 1.6;
    margin: 0;
}

.criteria-levels-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 0.75rem;
}

.criteria-level-item {
    display: flex;
    gap: 1rem;
    padding: 0.5rem;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid #f1f5f9;
}

.criteria-level-points {
    font-weight: 700;
    color: #2563eb;
    min-width: 3rem;
}

.criteria-level-info {
    flex: 1;
}

.criteria-level-name {
    font-weight: 700;
    color: #0f172a;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.criteria-level-desc {
    font-size: 0.9rem;
    color: #475569;
    line-height: 1.5;
    margin: 0;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Popups (Bareme & Rubric) --- */
.bareme-popup-overlay,
.criteria-levels-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    padding: 1rem;
}

.bareme-popup-overlay[style*="flex"],
.bareme-popup-overlay.show,
.criteria-levels-overlay.show {
    display: flex !important;
}

.bareme-popup-content,
.criteria-levels-modal {
    background: white;
    border-radius: 12px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.3);
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.bareme-popup-header,
.criteria-levels-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.bareme-popup-header h2,
.criteria-levels-title {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-primary, #212529);
}

.bareme-popup-close,
.criteria-levels-close {
    background: rgba(15, 23, 42, 0.08);
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.bareme-popup-close:hover,
.criteria-levels-close:hover {
    background: rgba(15, 23, 42, 0.15);
    color: var(--text-primary, #212529);
}

.bareme-popup-body,
.criteria-levels-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.criteria-level-row {
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 10px;
    padding: 0.75rem 0.9rem;
    background: #f8fafc;
    margin-bottom: 0.65rem;
}

.criteria-level-row .top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.criteria-level-row .name {
    font-weight: 800;
    color: var(--text-primary, #0f172a);
}

.criteria-level-row .pts {
    font-weight: 800;
    color: #2563eb;
}

.criteria-level-row .desc {
    margin: 0.4rem 0 0 0;
    color: var(--text-primary, #0f172a);
    line-height: 1.5;
}

/* --- Lexical Tags & Extras --- */
.lexical-tag {
    background-color: #fef2f2;
    color: #ef4444;
    border: 1px solid #fecaca;
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.lexical-tag i {
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.lexical-tag i:hover {
    opacity: 1;
}

.btn-tertiary {
    width: 100%;
    padding: 0.75rem;
    border: 2px dashed #cbd5e1;
    background: transparent;
    color: var(--text-muted, #64748b);
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-tertiary:hover {
    border-color: var(--primary-color, #127ae0);
    color: var(--primary-color, #127ae0);
    background: #eff6ff;
}

/* --- Actions & Misc --- */
.form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.ai-correction-section {
    background: white;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ai-correction-section h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-primary, #212529);
}

.btn-remove-criterion {
    background: transparent;
    border: none;
    color: var(--error-color, #dc2626);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

.btn-remove-criterion:hover {
    background: rgba(220, 38, 38, 0.1);
    transform: scale(1.1);
}

@media (max-width: 640px) {
    .ai-correction-section {
        padding: 1.5rem;
    }

    .ai-correction-section h2 {
        font-size: 1.25rem;
    }
}

/* --- Generator Specifics --- */
#classSelectionContainer {
    display: block !important;
}

#classCheckboxes {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 0.75rem;
}

.ai-correction-section .form-group {
    margin-bottom: 1.5rem;
}

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

@media (max-width: 640px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .generate-actions {
        flex-direction: column;
    }

    .generate-actions .btn-primary {
        width: 100%;
    }

    .criterion-item {
        grid-template-columns: 1fr;
    }
}

/* --- Shared Utility Classes (Refactored from inline styles) --- */

.penalties-box {
    padding: 1rem;
    background: #fff7ed;
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: 8px;
}

.warning-box {
    padding: 16px;
    background: #fff7ed;
    border: 2px solid #f59e0b;
    border-radius: 8px;
    margin-bottom: 1.25rem;
}

.warning-box-content {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.warning-icon {
    color: #f59e0b;
    font-size: 1.25rem;
    margin-top: 2px;
    flex-shrink: 0;
}

.warning-text {
    color: #f59e0b;
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0;
}

.info-box {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--bg-subtle, #f8fafc);
    border-radius: 8px;
}

.rubric-item-card {
    background: #f9fafb;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: white;
    border-radius: 6px;
    border: 1px solid rgba(226, 232, 240, 0.9);
}

.checkbox-row label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1;
}

.card-dashed {
    background: #f8fafc;
    border-style: dashed;
}

.input-label-sm {
    display: block;
    font-size: 0.875rem;
    color: #6b7280;
    margin-bottom: 0.25rem;
}

.selection-container {
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 12px;
    padding: 1rem;
    background: #f9fafb;
}

.custom-textarea {
    width: 100%;
    min-height: 120px;
    padding: 0.9rem 1rem;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 12px;
    font-size: 1rem;
    resize: vertical;
}

.form-select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    font-size: 0.95rem;
    background: white;
}

.ai-correction-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.ai-icon-container {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--primary-color, #127ae0);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}