/* Case Study Selector Component Styles */

.student-profile-selector {
    position: relative;
    width: 100%;
    /* font-family inherited from body */
}

/* Trigger Button - Match .sidebar-resource-btn exactly */
.student-profile-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #4b5563;
    font-size: var(--font-size-sidebar-agent-name);
    text-align: left;
    font-weight: 500;
    min-height: 36px;
}

.student-profile-trigger:hover {
    background: #f3f4f6;
    color: #1f2937;
}

.student-profile-trigger.open {
    background: transparent;
}

.student-profile-trigger.has-selection {
    background: transparent;
}

.student-profile-trigger.has-selection:hover {
    background: #f3f4f6;
}

/* Icon styling - match .sidebar-resource-btn i */
.student-profile-trigger i {
    font-size: var(--font-size-sm);
    width: 24px;
    text-align: center;
    color: #4b5563;
}

.student-profile-trigger:hover i {
    color: #2563eb;
}

/* Text styling - match .sidebar-resource-btn span */
.trigger-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
    color: inherit;
}

.trigger-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    background: #059669;
    color: white;
    border-radius: 11px;
    font-size: 12px;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(5, 150, 105, 0.3);
}

.selection-count {
    padding: 2px 8px;
    background: #f3f4f6;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 400;
    color: #4b5563;
}

.selection-count.valid {
    background: #dcfce7;
    color: #16a34a;
}

body.dark-mode .selection-count {
    background: #374151;
    color: #9ca3af;
}

body.dark-mode .selection-count.valid {
    background: #064e3b;
    color: #34d399;
}

/* Panel - Modal Popup Style */
.student-profile-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1200;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.student-profile-panel.open {
    display: flex;
}

.student-profile-panel-content {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 95%;
    max-width: 1400px;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.panel-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    background: white;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 16px 16px 0 0;
}

.panel-header h3 {
    margin: 0;
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: #1f2937;
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-header h3 i {
    font-size: var(--font-size-lg);
    color: #374151;
}

.panel-subtitle {
    display: none;
}

.panel-close-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4b5563;
    font-size: var(--font-size-lg);
    transition: all 0.2s ease;
    border-radius: 8px;
}

.panel-close-btn:hover {
    background: #f3f4f6;
    color: #374151;
}

/* Selected Preview - hidden to match Manipulatives style */
.selected-students-preview {
    display: none;
}

.no-selection {
    color: #9ca3af;
    font-size: var(--font-size-xs);
    font-style: italic;
    margin: 0;
}

.selected-avatars {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.selected-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: var(--font-size-xs);
}

.selected-avatar .remove-btn {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ef4444;
    border: 2px solid white;
    color: white;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.selected-avatar:hover .remove-btn {
    opacity: 1;
}

/* Card Grid - Using Flexbox for proper content flow */
.student-profile-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    align-content: flex-start;
}

/* Cards have fixed width */
.student-profile-grid>.student-profile-card {
    flex: 0 0 calc(50% - 8px);
    max-width: calc(50% - 8px);
}

/* Case Study Card */
.student-profile-card {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    overflow: visible;
    transition: all 0.2s ease;
    min-height: 200px;
}

.student-profile-card:hover {
    border-color: #93c5fd;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
}

.student-profile-card.selected {
    border-color: #3b82f6;
    background: white;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Force card-body to always be visible */
.student-profile-card>.card-body,
.student-profile-card .card-body {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    max-height: none !important;
    overflow: visible !important;
}


.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    cursor: pointer;
    background: transparent;
    transition: background 0.2s;
}

.card-header:hover {
    background: rgba(99, 102, 241, 0.05);
}

.student-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: var(--font-size-sm);
    flex-shrink: 0;
}

.student-info {
    flex: 1;
    min-width: 0;
}

.student-name {
    margin: 0 0 4px 0;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: #111827;
}

.disability-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    border: 1px solid;
}

/* Custom Checkbox */
.card-checkbox {
    position: relative;
}

.card-checkbox input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.card-checkbox label {
    display: block;
    width: 24px;
    height: 24px;
    border: 2px solid #d1d5db;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
}

.card-checkbox input:checked+label {
    background: #3b82f6;
    border-color: #3b82f6;
}

.card-checkbox input:checked+label::after {
    content: '';
    position: absolute;
    left: 8px;
    top: 4px;
    width: 6px;
    height: 12px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Card Body */
.card-body {
    display: block;
    padding: 0 16px 16px;
}

.disability-name {
    margin: 0 0 8px 0;
    font-size: var(--font-size-xs);
    color: #4b5563;
}

.additional-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.tag {
    padding: 3px 8px;
    background: #fef3c7;
    color: #92400e;
    border-radius: 4px;
    font-size: var(--font-size-xs);
    font-weight: 500;
}

.expand-btn {
    width: 100%;
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: #374151;
    font-size: var(--font-size-xs);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
}

.expand-btn:hover {
    background: #f9fafb;
    border-color: #9ca3af;
    color: #111827;
}

.expand-btn i {
    transition: transform 0.2s;
}

/* Card Details - Hidden by default, shown when expanded */
.card-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease, margin 0.3s ease;
    padding: 0 12px;
    margin-top: 0;
    background: #f8fafc;
    border-radius: 8px;
}

.card-details.expanded {
    max-height: 1000px;
    overflow: visible;
    padding: 12px;
    margin-top: 12px;
    border: 1px solid #e2e8f0;
    position: relative;
    z-index: 10;
}

/* Ensure cards with expanded details are above others */
.student-profile-card:has(.card-details.expanded) {
    z-index: 5;
    position: relative;
}

.detail-section {
    margin-bottom: 12px;
}

.detail-section:last-child {
    margin-bottom: 0;
}

.detail-section h5 {
    margin: 0 0 6px 0;
    font-size: var(--font-size-sm, 1rem);
    font-weight: 600;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 6px;
}

.detail-section h5 i {
    color: #3b82f6;
    font-size: var(--font-size-xs, 0.875rem);
}

.detail-section ul {
    margin: 0;
    padding-left: 18px;
}

.detail-section li {
    font-size: var(--font-size-sm, 1rem);
    color: #4b5563;
    line-height: 1.5;
    margin-bottom: 4px;
}

/* Panel Footer */
.panel-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid #e5e7eb;
    background: white;
}

.btn-secondary {
    padding: 8px 20px;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: #374151;
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

.btn-primary {
    padding: 8px 20px;
    background: #22c55e;
    border: none;
    border-radius: 6px;
    color: #fff;
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary:hover:not(:disabled) {
    background: #16a34a;
}

.btn-primary:disabled {
    background: #d1d5db;
    color: #9ca3af;
    cursor: not-allowed;
}

/* Responsive */
@media (max-width: 768px) {
    .student-profile-panel {
        padding: 12px;
    }

    .student-profile-panel-content {
        width: 100%;
        max-width: 100%;
        max-height: 90vh;
        border-radius: 12px;
    }

    .student-profile-grid {
        gap: 12px;
        padding: 16px;
    }

    .student-profile-grid>.student-profile-card {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .trigger-text {
        font-size: var(--font-size-xs);
    }

    .panel-header {
        padding: 12px 16px;
    }

    .panel-close-btn {
        width: 44px;
        height: 44px;
    }

    .panel-footer {
        padding: 12px 16px;
        flex-direction: column;
    }

    .btn-secondary,
    .btn-primary {
        width: 100%;
        min-height: 44px;
    }
}

@media (max-width: 480px) {
    .student-profile-panel {
        padding: 8px;
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }

    .student-profile-panel-content {
        max-height: 95vh;
        border-radius: 8px;
    }

    .student-profile-trigger {
        padding: 10px 12px;
    }

    .trigger-content {
        gap: 8px;
    }

    .trigger-content i {
        font-size: var(--font-size-sm);
    }

    .trigger-text {
        font-size: var(--font-size-xs);
    }

    .selection-count {
        padding: 3px 8px;
        font-size: var(--font-size-xs);
    }

    .student-profile-grid {
        padding: 12px;
        gap: 10px;
    }

    .student-avatar {
        width: 40px;
        height: 40px;
        font-size: var(--font-size-xs);
    }

    .student-name {
        font-size: var(--font-size-xs);
    }

    .disability-badge {
        font-size: var(--font-size-xs);
        padding: 2px 6px;
    }

    .card-header {
        padding: 12px;
        gap: 10px;
    }

    .card-body {
        padding: 0 12px 12px;
    }

    .student-profile-card {
        min-height: auto;
    }

    .expand-btn {
        padding: 8px 10px;
    }
}

/* Collapsed Sidebar Support - match .sidebar.collapsed .sidebar-resource-btn */
.sidebar.collapsed .student-profile-trigger {
    width: 44px;
    height: 44px;
    padding: 0;
    justify-content: center;
}

.sidebar.collapsed .student-profile-trigger .trigger-text,
.sidebar.collapsed .student-profile-trigger .trigger-badge {
    display: none;
}

.sidebar.collapsed .student-profile-trigger i {
    font-size: var(--font-size-lg);
}

/* Dark Mode Support */
body.dark-mode .student-profile-selector {
    --bg-primary: #1f2937;
    --bg-secondary: #374151;
    --border-color: #4b5563;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
}

/* Dark mode - match body.dark-mode .sidebar-resource-btn */
body.dark-mode .student-profile-trigger {
    color: #e5e7eb;
}

body.dark-mode .student-profile-trigger:hover {
    background: #2a2a2a;
    color: #d1d5db;
}

body.dark-mode .student-profile-trigger i {
    color: #d1d5db;
}

body.dark-mode .student-profile-trigger:hover i {
    color: #818cf8;
}

body.dark-mode .trigger-text {
    color: inherit;
}


body.dark-mode .selection-count {
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

body.dark-mode .student-profile-panel {
    background: rgba(0, 0, 0, 0.6);
}

body.dark-mode .panel-header {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

body.dark-mode .panel-header h3 {
    color: var(--text-primary);
}

body.dark-mode .panel-subtitle {
    color: var(--text-secondary);
}

body.dark-mode .selected-students-preview {
    border-color: var(--border-color);
}

body.dark-mode .student-profile-card {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

body.dark-mode .student-profile-card.selected {
    background: #312e81;
    border-color: #3b82f6;
}

body.dark-mode .student-name {
    color: var(--text-primary);
}

body.dark-mode .disability-name {
    color: var(--text-secondary);
}

body.dark-mode .expand-btn {
    background: #4b5563;
    color: var(--text-secondary);
}

body.dark-mode .expand-btn:hover {
    background: #4b5563;
}

body.dark-mode .card-checkbox label {
    background: var(--bg-secondary);
    border-color: #4b5563;
}

body.dark-mode .detail-section h5 {
    color: var(--text-primary);
}

body.dark-mode .detail-section li {
    color: var(--text-secondary);
}

body.dark-mode .panel-footer {
    background: #1f2937;
    border-color: var(--border-color);
}

body.dark-mode .btn-secondary {
    background: #374151;
    border-color: #4b5563;
    color: #e5e7eb;
}

body.dark-mode .btn-secondary:hover {
    background: #4b5563;
}

body.dark-mode .btn-primary:disabled {
    background: #4b5563;
    color: #4b5563;
}

@media (max-width: 768px) {
    .card-checkbox label {
        width: 32px;
        height: 32px;
    }

    .card-checkbox input:checked+label::after {
        left: 10px;
        top: 5px;
    }
}

@media (max-width: 480px) {
    .profile-cards-grid {
        grid-template-columns: 1fr;
    }

    .card-details.expanded {
        padding: 10px;
    }

    .detail-section h5 {
        font-size: var(--font-size-xs, 0.875rem);
    }

    .detail-section li {
        font-size: var(--font-size-xs, 0.875rem);
    }
}