/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --background: hsl(220, 20%, 97%);
    --foreground: hsl(220, 25%, 10%);
    --card: hsl(0, 0%, 100%);
    --card-foreground: hsl(220, 25%, 10%);
    --primary: hsl(250, 65%, 55%);
    --primary-foreground: hsl(0, 0%, 100%);
    --secondary: hsl(220, 15%, 93%);
    --secondary-foreground: hsl(220, 25%, 10%);
    --muted: hsl(220, 15%, 93%);
    --muted-foreground: hsl(220, 10%, 45%);
    --accent: hsl(165, 60%, 45%);
    --destructive: hsl(0, 72%, 55%);
    --border: hsl(220, 15%, 88%);
    --input: hsl(220, 15%, 88%);
    --ring: hsl(250, 65%, 55%);
    --radius: 0.75rem;
}

body {
    font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--background);
    color: var(--foreground);
    line-height: 1.6;
    min-height: 100vh;
}

/* Container */
.container {
    max-width: 56rem;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header */
.header {
    background-color: var(--card);
    border-bottom: 1px solid var(--border);
}

.header-content {
    padding: 3rem 0 4rem;
}

.logo-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.logo-icon {
    background-color: var(--primary);
    border-radius: var(--radius);
    padding: 0.625rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-icon .icon {
    width: 1.5rem;
    height: 1.5rem;
    color: var(--primary-foreground);
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.subtitle {
    color: var(--muted-foreground);
    font-size: 1.125rem;
    max-width: 36rem;
}

/* Main Content */
.main-content {
    padding: 2rem 0;
}

.section {
    margin-bottom: 2rem;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.section-header-with-action {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-title-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-icon {
    width: 1.25rem;
    height: 1.25rem;
    color: var(--primary);
}

.section h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.count-badge {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--muted-foreground);
    margin-left: 0.5rem;
}

/* Card */
.card {
    background-color: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

/* Form Styles */
.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

@media (min-width: 640px) {
    .form-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group:not(:has(.form-grid)) {
    margin-bottom: 1rem;
}

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

label {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted-foreground);
}

input,
textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--input);
    border-radius: calc(var(--radius) - 0.25rem);
    background-color: var(--background);
    color: var(--foreground);
    font-family: inherit;
    font-size: 0.875rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
textarea:focus {
    outline: none;
    border-color: var(--ring);
    box-shadow: 0 0 0 3px hsla(250, 65%, 55%, 0.1);
}

input::placeholder,
textarea::placeholder {
    color: var(--muted-foreground);
}

textarea {
    resize: vertical;
    min-height: 60px;
}

.file-upload-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.file-name {
    font-size: 0.875rem;
    color: var(--muted-foreground);
    flex: 1;
}

.form-help {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    margin-top: -0.25rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: calc(var(--radius) - 0.25rem);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background-color: var(--primary);
    color: var(--primary-foreground);
}

.btn-primary:hover:not(:disabled) {
    background-color: hsl(250, 65%, 50%);
}

.btn-secondary {
    background-color: var(--secondary);
    color: var(--secondary-foreground);
}

.btn-secondary:hover:not(:disabled) {
    background-color: hsl(220, 15%, 88%);
}

.btn-ghost {
    background-color: transparent;
    color: var(--foreground);
}

.btn-ghost:hover:not(:disabled) {
    background-color: var(--accent);
    color: var(--primary-foreground);
}

.btn-full {
    width: 100%;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-icon {
    padding: 0.5rem;
    width: 2.25rem;
    height: 2.25rem;
}

.icon {
    width: 1rem;
    height: 1rem;
    stroke-width: 2;
}

.btn-sm .icon {
    width: 0.875rem;
    height: 0.875rem;
}

/* Professor List */
.professor-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.professor-card {
    background-color: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: box-shadow 0.2s;
}

.professor-card:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.professor-info {
    flex: 1;
    min-width: 0;
}

.professor-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.25rem;
}

.professor-name h3 {
    font-size: 1rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    background-color: var(--secondary);
    color: var(--secondary-foreground);
    border-radius: calc(var(--radius) - 0.25rem);
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.professor-email {
    font-size: 0.875rem;
    color: var(--muted-foreground);
    font-family: 'JetBrains Mono', monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.professor-university {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    margin-top: 0.125rem;
}

.professor-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 0.75rem;
    flex-shrink: 0;
}

.professor-actions .btn-icon .icon.destructive {
    color: var(--destructive);
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 1rem;
    text-align: center;
}

.empty-icon {
    background-color: var(--muted);
    border-radius: 50%;
    padding: 1rem;
    margin-bottom: 1rem;
}

.empty-icon .icon {
    width: 2rem;
    height: 2rem;
    color: var(--muted-foreground);
}

.empty-state p {
    color: var(--muted-foreground);
    font-size: 0.875rem;
}

.empty-subtext {
    font-size: 0.75rem !important;
    margin-top: 0.25rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background-color: var(--card);
    border-radius: var(--radius);
    max-width: 42rem;
    width: calc(100% - 2rem);
    max-height: calc(100vh - 4rem);
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--muted-foreground);
    border-radius: calc(var(--radius) - 0.25rem);
    transition: background-color 0.2s;
}

.modal-close:hover {
    background-color: var(--secondary);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding: 1.5rem;
    border-top: 1px solid var(--border);
}

/* Template Selector */
.template-selector {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background-color: var(--secondary);
    border-radius: calc(var(--radius) - 0.25rem);
}

.template-selector label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--foreground);
}

.template-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background-color: var(--background);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 0.25rem);
    color: var(--foreground);
    font-size: 0.875rem;
    font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    cursor: pointer;
    transition: border-color 0.2s;
}

.template-select:hover {
    border-color: var(--primary);
}

.template-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.1);
}

.template-help {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    line-height: 1.5;
    margin: 0;
}

/* Email Preview */
.email-preview {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.email-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.email-field strong {
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

.email-field span {
    font-size: 0.875rem;
}

.email-field pre {
    background-color: var(--secondary);
    padding: 1rem;
    border-radius: calc(var(--radius) - 0.25rem);
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 0.875rem;
    line-height: 1.6;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background-color: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    max-width: 24rem;
    opacity: 0;
    transform: translateY(1rem);
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
    z-index: 2000;
}

.toast.active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.toast-title {
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.toast-description {
    font-size: 0.8125rem;
    color: var(--muted-foreground);
}

.toast.error {
    border-color: var(--destructive);
}

.toast.error .toast-title {
    color: var(--destructive);
}

/* Responsive */
@media (max-width: 640px) {
    .header h1 {
        font-size: 1.75rem;
    }

    .subtitle {
        font-size: 1rem;
    }

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

    .modal-footer {
        flex-direction: column-reverse;
    }

    .modal-footer .btn {
        width: 100%;
    }

    .toast {
        right: 1rem;
        left: 1rem;
        bottom: 1rem;
    }
}

/* Search Results Styles */
.search-results {
    margin-top: 1.5rem;
}

.search-results-count {
    font-size: 0.875rem;
    color: var(--muted-foreground);
    margin-bottom: 1rem;
}

#searchResultsList {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.search-result-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    transition: all 0.2s;
}

.search-result-card:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.search-result-info {
    flex: 1;
    min-width: 0;
}

.search-result-name {
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.search-result-email {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    font-family: monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-result-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    background: var(--secondary);
    color: var(--secondary-foreground);
    border-radius: calc(var(--radius) * 0.5);
    font-size: 0.75rem;
    font-weight: 500;
}

.error-message {
    margin-top: 1rem;
    padding: 0.75rem;
    background: hsl(0, 72%, 96%);
    border: 1px solid hsl(0, 72%, 85%);
    border-radius: var(--radius);
    color: var(--destructive);
    font-size: 0.875rem;
}

.btn-loading {
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-loading .icon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Professor Details Modal */
.modal-large {
    max-width: 700px;
    max-height: 85vh;
}

.modal-scroll {
    max-height: 70vh;
    overflow-y: auto;
}

.detail-email {
    font-size: 0.875rem;
    color: var(--muted);
    font-family: 'Courier New', monospace;
    margin-top: 0.25rem;
}

.details-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 1.5rem;
    gap: 0.75rem;
}

.spinner {
    width: 2rem;
    height: 2rem;
    animation: spin 1s linear infinite;
    color: var(--primary);
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.details-loading p {
    font-size: 0.875rem;
    color: var(--muted);
}

.details-error {
    padding: 2rem;
    text-align: center;
    color: var(--destructive);
    font-size: 0.875rem;
}

.details-content {
    padding-top: 0.5rem;
}

.detail-section {
    margin-bottom: 1.5rem;
}

.detail-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.detail-subtitle {
    font-size: 0.875rem;
    color: var(--muted);
    margin-bottom: 0.5rem;
}

.detail-bio {
    font-size: 0.875rem;
    line-height: 1.6;
    margin-top: 0.5rem;
}

.stats-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    text-decoration: none;
    color: inherit;
}

.stat-card-link {
    cursor: pointer;
    transition: box-shadow 0.2s;
}

.stat-card-link:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stat-icon {
    width: 1rem;
    height: 1rem;
    color: var(--primary);
    flex-shrink: 0;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--muted);
    margin: 0;
}

.stat-value {
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0;
}

.detail-heading {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.badge-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.detail-empty {
    font-size: 0.875rem;
    color: var(--muted);
}

.publications-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.publication-card {
    padding: 0.75rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
}

.publication-title {
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.4;
    margin: 0 0 0.375rem 0;
}

.publication-link {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s ease;
    cursor: pointer;
}

.publication-link:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.publication-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
}

.publication-year {
    padding: 0.125rem 0.5rem;
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    font-weight: 500;
}

.publication-venue {
    color: var(--muted);
    font-style: italic;
}

.publication-citations {
    color: var(--muted);
}

.publication-coauthors {
    font-size: 0.75rem;
    color: var(--muted);
    margin: 0.25rem 0 0 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
