:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 0.75rem;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    margin-bottom: 3rem;
    text-align: center;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--border-color);
}

.tab {
    background: none;
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
    font-family: inherit;
    display: flex;
    align-items: center;
}

.tab:hover {
    color: var(--text-main);
}

.tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.search-wrapper {
    flex: 1;
    position: relative;
    min-width: 300px;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

input[type="text"],
select {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    background-color: var(--card-bg);
    transition: all 0.2s;
    font-family: inherit;
}

select {
    padding-left: 1rem;
    cursor: pointer;
}

input[type="text"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.card-header {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.rank-badge {
    display: inline-block;
    background-color: #eff6ff;
    color: var(--primary-color);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    margin-bottom: 0.5rem;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}

.card-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

.card-body {
    flex: 1;
}

.info-row {
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.info-label {
    font-weight: 600;
    color: var(--text-main);
    display: block;
    margin-bottom: 0.1rem;
}

.info-value {
    color: var(--text-secondary);
}

.score-badge {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: #f0fdf4;
    color: #166534;
    font-weight: 700;
    padding: 0.5rem;
    border-radius: 0.5rem;
    font-size: 1.1rem;
    border: 1px solid #bbf7d0;
}

/* Favorite Button */
.favorite-btn {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 10;
}

.favorite-btn:hover {
    border-color: #ef4444;
    transform: scale(1.1);
}

.favorite-btn svg {
    width: 1.25rem;
    height: 1.25rem;
    stroke: #6b7280;
    fill: none;
    transition: all 0.2s;
}

.favorite-btn.favorited {
    border-color: #ef4444;
    background: #fef2f2;
}

.favorite-btn.favorited svg {
    fill: #ef4444;
    stroke: #ef4444;
}

/* Empty State */
.empty-state {
    grid-column: 1/-1;
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 4rem;
    height: 4rem;
    margin: 0 auto 1rem;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.empty-state p {
    font-size: 1rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    overflow-y: auto;
}

.modal-content {
    background-color: var(--card-bg);
    margin: 3rem auto;
    padding: 2.5rem;
    border-radius: var(--radius);
    width: 90%;
    max-width: 800px;
    position: relative;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

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

.close-modal {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    font-size: 2rem;
    font-weight: 300;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
}

.close-modal:hover {
    color: var(--text-main);
}

.modal-header {
    margin-bottom: 2rem;
}

.modal-h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 1.5rem 0 0.75rem 0;
    color: var(--text-main);
    border-left: 4px solid var(--primary-color);
    padding-left: 0.75rem;
}

.pub-item {
    background: #f8fafc;
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 0.75rem;
    border: 1px solid var(--border-color);
}

.pub-title {
    font-weight: 600;
    color: var(--primary-color);
    text-decoration: none;
    display: block;
    margin-bottom: 0.25rem;
}

.pub-title:hover {
    text-decoration: underline;
}

.tag {
    display: inline-block;
    background: #e2e8f0;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.email-box {
    background: #ffffff;
    padding: 1.5rem;
    border-radius: 0.5rem;
    font-family: 'Inter', sans-serif;
    white-space: pre-wrap;
    margin-top: 0;
    border: 2px solid #cbd5e1;
    font-size: 0.9rem;
    line-height: 1.6;
    cursor: text;
    transition: all 0.2s;
    min-height: 200px;
}

.email-box:hover {
    border-color: var(--primary-color);
    background: #fafbfc;
}

.email-box:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    background: #ffffff;
}

.action-btn {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    text-decoration: none;
    font-weight: 500;
    margin-top: 2rem;
    transition: background 0.2s;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
}

.action-btn:hover {
    background: var(--primary-hover);
}

.copy-ai-btn {
    background: #10b981;
}

.copy-ai-btn:hover {
    background: #059669;
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: #1e293b;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    opacity: 0;
    transform: translateY(1rem);
    transition: all 0.3s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.toast-success {
    background: #10b981;
}

.toast.toast-error {
    background: #ef4444;
}

/* ===================================================
   MOBILE RESPONSIVE STYLES
   =================================================== */

/* Small tablets and large phones (landscape) */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    header {
        margin-bottom: 2rem;
    }

    h1 {
        font-size: 1.75rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    /* Tabs */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .tabs::-webkit-scrollbar {
        display: none;
    }

    .tab {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
        white-space: nowrap;
    }

    /* Controls */
    .controls {
        flex-direction: column;
    }

    .search-wrapper {
        min-width: 100%;
    }

    /* Grid */
    .grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* Modal */
    .modal-content {
        margin: 1rem;
        padding: 1.5rem;
        width: calc(100% - 2rem);
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
    }

    .modal-h1 {
        font-size: 1.5rem;
    }

    .close-modal {
        top: 1rem;
        right: 1rem;
        font-size: 1.5rem;
    }

    /* Workflow section in modal */
    .workflow-section h3 {
        font-size: 1rem;
    }

    .workflow-section>div {
        grid-template-columns: 1fr !important;
    }

    /* Email box */
    .email-box {
        font-size: 0.85rem;
        padding: 1rem;
        min-height: 150px;
    }

    /* Action buttons */
    .action-btn {
        width: 100%;
        text-align: center;
        padding: 0.75rem;
        margin-top: 1rem;
    }

    .modal-content>div>div[style*="display: flex"] {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }

    /* Score badge positioning */
    .score-badge {
        top: 1rem;
        right: 1rem;
        font-size: 1rem;
        padding: 0.4rem;
    }

    /* Favorite button in modal */
    .modal-header .favorite-btn {
        top: 1rem !important;
        right: 3.5rem !important;
    }

    /* Section titles */
    .section-title {
        font-size: 1rem;
    }

    /* Info rows */
    .info-row {
        font-size: 0.85rem;
    }

    /* Publication items */
    .pub-item {
        padding: 0.75rem;
    }

    /* Toast on mobile */
    .toast {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
        width: calc(100% - 2rem);
    }
}

/* Mobile phones (portrait) */
@media (max-width: 480px) {
    .container {
        padding: 0.75rem;
    }

    h1 {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    .card {
        padding: 1rem;
    }

    .card-title {
        font-size: 1.1rem;
    }

    .modal-content {
        margin: 0.5rem;
        padding: 1rem;
        width: calc(100% - 1rem);
        border-radius: 0.5rem;
    }

    .modal-h1 {
        font-size: 1.25rem;
        padding-right: 3rem;
    }

    .rank-badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
    }

    input[type="text"],
    select {
        font-size: 16px;
        /* Prevents zoom on iOS */
        padding: 0.65rem 1rem 0.65rem 2.5rem;
    }

    select {
        padding-left: 0.75rem;
    }

    .email-box {
        font-size: 14px;
        /* Prevents zoom on iOS */
    }

    /* Make modal header more compact */
    .modal-header>div {
        flex-direction: column !important;
        align-items: flex-start !important;
    }

    .modal-header>div>div:last-child {
        margin-top: 0.5rem;
        text-align: left !important;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {

    /* Larger tap targets for touch devices */
    .tab {
        padding: 1rem 1.5rem;
    }

    .favorite-btn {
        width: 3rem;
        height: 3rem;
    }

    .action-btn {
        padding: 1rem 1.5rem;
        min-height: 44px;
        /* iOS recommended touch target */
    }

    input[type="text"],
    select,
    textarea {
        min-height: 44px;
    }

    /* Remove hover effects on touch devices */
    .card:hover {
        transform: none;
    }

    .favorite-btn:hover {
        transform: none;
    }
}