:root {
    --primary-color: rgb(157, 157, 189);
    --background-color: #ffffff; /* Pure white background */
    --text-color: #0f172a;      /* Darker text */
    --text-secondary: #475569;   /* Slate gray */
    --border-color: #e2e3e4;    /* Light gray */
    --hover-bg: #f8fafc;        /* Subtle hover */
    --max-width: 1200px;         /* More compact max width */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background: white;
    padding: 1rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border-color);
}

header .header-container {
    max-width: var(--max-width);
    width: 100%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

header .header-container h1 {
    margin-bottom: 0;
    font-size: 1.5rem;
    cursor: pointer;
    max-width: 200px;
    width: 100%;
    text-align: left;
}

header .header-container h1:hover {
    color: #f97316;
}

.cursor {
    margin-left: 2px;
    animation: blink 1s infinite steps(2, start);
}
  
@keyframes blink {
    from {
        visibility: visible;
    }
    to {
        visibility: hidden;
    }
}

header .header-container .user-info {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    color: var(--text-secondary);
    max-width: 230px;
    width: 100%;
    gap: 0.5rem;
    animation: scaleIn 0.5s ease-in-out;
}

@keyframes scaleIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

header .header-container .user-info:hover {
    color: var(--primary-color);
    cursor: pointer;
}

header .header-container .user-info span {
    font-size: 0.85rem;
    font-weight: 500;
}

header .header-container .user-info i {
    font-size: 1.5rem;
}

header .header-container .user-info img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

header .header-container .user-info:hover img {
    box-shadow: 0 0 10px var(--primary-color);
}

h1 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
}

h1 i {
    margin-right: 0.5rem;
}

#search-container {
    max-width: 500px;
    width: 100%;
    display: flex;
    justify-content: center;
    animation: appear 0.5s ease-in-out;
    position: relative;
}

@keyframes appear {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.5);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.search-wrapper {
    position: relative;
    display: flex;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    z-index: 2;
    pointer-events: none;
}

#search-input {
    flex: 1;
    padding: 0.8rem 1rem 0.6rem 2.5rem;
    border: 2px solid var(--border-color);
    border-radius: 0.5rem 0 0 0.5rem;
    font-size: 1rem;
    outline: none;
    transition: all 0.2s ease-in-out;
}

#search-input:focus {
    border-color: var(--primary-color);
}

.search-label {
    position: absolute;
    left: 2.5rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    transition: all 0.2s ease-in-out;
    pointer-events: none;
    background-color: transparent;
    padding: 0 0.25rem;
    font-size: 1rem;
    opacity: 1;
    z-index: 3;
}

#search-input:not(:placeholder-shown) + label,
#search-input:focus + label {
    top: 0;
    left: 2.5rem;
    font-size: 0.75rem;
    color: var(--primary-color);
    background-color: white;
    opacity: 1;
    transform: translateY(-50%);
}

#search-button {
    padding: 0.6rem 1.25rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0 0.5rem 0.5rem 0;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
    white-space: nowrap;
}

#search-button:hover {
    background-color: var(--text-secondary); /* Darker blue */
}

main {
    flex: 1;
    padding: 2rem 1rem;
    max-width: var(--max-width);
    margin: 0 auto;
    width: 100%;
}

#papers-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.zotero-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.external-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.paper-item {
    background: white;
    padding: 0.8rem 1.25rem 1.25rem 1.25rem;
    border: 1px solid var(--border-color);
    border-radius: 3px 0.5rem 0.5rem 3px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    gap: 0.75rem;
    opacity: 0;
    transform: translateY(20px) scale(0.98);
    position: relative;
    overflow: hidden;
}

.paper-item::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 200%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.paper-item > * {
    position: relative;
    z-index: 1;
}

.paper-item.animate {
    animation: paperAppear 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes paperAppear {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }
    50% {
        transform: translateY(-5px) scale(1.02);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.paper-item.zotero {
    border-left: 4px solid #f97316;
}

.paper-item.external {
    border-left: 4px solid #3b82f6;
}

.paper-item.library {
    border-left: 4px solid #0bb11e;
}

.paper-item:hover {
    background: var(--hover-bg);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.paper-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.paper-meta {
    display: flex;
    flex-wrap: wrap;
    column-gap: 1.5rem;
    row-gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-bottom: 0.75rem;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.meta-item i {
    color: var(--primary-color);
    max-width: 8px;
    width: 100%;
}

.paper-link {
    padding: 0.2rem 0.75rem;
    font-size: 0.9rem;
    background-color: #f1f5f9;
    border: 1px solid var(--border-color);
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
    border-radius: 0.5rem;
    cursor: pointer;
    display: inline-flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 3;
    pointer-events: auto;
}

.paper-link.download {
    background-color: #f97316; /* Orange */
    color: white;
}
.paper-link.download:hover {
    background-color: #ea580c; /* Darker orange */
}

.paper-link.view {
    background-color: #0a546b76; /* Orange */
    color: white;
}
.paper-link.view:hover {
    background-color: #0c82eaa1; /* Darker orange */
}

.paper-link.copy {
    background-color: #57c8f8; /* Orange */
    color: white;
}
.paper-link.copy:hover {
    background-color: #18b5f8; /* Darker orange */
}

.paper-link.request {
    background-color: #3b82f6; /* Blue */
    color: white;
}
.paper-link.request:hover {
    background-color: #2563eb; /* Darker blue */
}

.paper-link:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

.pdf-viewer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    background-color: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    padding: 0;
    margin: 0;
}

.pdf-viewer.hidden {
    display: none;
}

.pdf-viewer-header {
    position: relative;
}

.pdf-viewer-header h2 {
    display: none;
}

.pdf-viewer-header .close-button {
    background: #e53935;
    color: white;
    border: none;
    font-size: 1rem;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    position: absolute;
    top: 5px;
    left: 5px;
    z-index: 200000;
}

.pdf-viewer-header .close-button:hover {
    background: #e98a8a;
    color: black;
    transform: scale(1.05);
}

.pdf-frame {
    flex: 1;
    width: 100%;
    height: 100vh;
    border: none;
}

.paper-footer {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 1rem;
    position: relative;
    z-index: 2;
}

.paper-footer p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.paper-footer .paper-type {
    font-size: 0.7rem;
    background-color: #c4ccd771;
    color: rgb(0, 0, 0);
    padding: 0.1rem 0.5rem;
    border-radius: 0.3rem;
    margin-left: auto;
    box-shadow: 0 0 2px rgba(0,0,0,0.5);
}

.paper-footer .available {
    color: #3561dc;
}

.paper-footer .unavailable {
    color: #d8291d;
}

footer {
    text-align: center;
    padding: 1rem;
    background: white;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    font-size: 0.9rem;
    transition: transform 0.3s ease-in-out;
    z-index: 99;
}

footer.hidden {
    transform: translateY(100%);
}

.loading {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
}

.skeleton-item {
    background: #f8fafc;
    padding: 1.25rem;
    border-radius: 0.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    position: relative;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px);
    animation: skeletonAppear 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes skeletonAppear {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.skeleton-item::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 200%;
    height: 100%;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.8) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-title {
    height: 1.5rem;
    width: 85%;
    background: #e2e8f0;
    margin-bottom: 1rem;
    border-radius: 0.25rem;
    position: relative;
}

.skeleton-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.skeleton-meta-item {
    height: 1rem;
    width: 140px;
    background: #e2e8f0;
    border-radius: 0.25rem;
    position: relative;
}

.skeleton-footer {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.skeleton-button {
    height: 2rem;
    width: 120px;
    background: #e2e8f0;
    border-radius: 0.5rem;
    position: relative;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(50%);
    }
}

@media (max-width: 640px) {
    header .header-container {
        display: grid;
        grid-template-areas: 
            "title user"
            "search search";
        gap: 1rem;
        width: 100%;
    }

    header .header-container h1 {
        grid-area: title;
        font-size: 1.25rem;
        margin: 0;
        text-align: left;
    }

    header .header-container .user-info {
        grid-area: user;
        justify-self: end;
        justify-content: flex-end;
    }

    #search-container {
        grid-area: search;
        width: 100%;
        padding: 0;
    }

    .search-wrapper {
        display: flex;
        width: 100%;
    }

    #search-input {
        border-radius: 0.5rem 0 0 0.5rem;
        flex: 2;
        width: 100%;
    }

    #search-button {
        border-radius: 0 0.5rem 0.5rem 0;
        padding: 0.6rem 1rem;
    }

    main {
        padding: 1rem;
    }

    .paper-item {
        padding: 1rem;
        border-radius: 0.5rem;
    }

    .paper-title {
        font-size: 1rem;
    }

    .paper-meta {
        flex-direction: column;
        gap: 0.5rem;
    }

    .meta-item {
        width: 100%;
        justify-content: flex-start;
    }

    .paper-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .paper-link {
        width: 100%;
        justify-content: center;
    }

    .paper-footer p {
        text-align: center;
    }

    .user-info {
        width: 100%;
        justify-content: center;
    }
}

/* Add styles for very small screens */
@media (max-width: 380px) {
    header .header-container h1 {
        font-size: 1.1rem;
    }

    .paper-item {
        padding: 0.75rem;
    }

    .paper-title {
        font-size: 0.95rem;
    }

    .meta-item {
        font-size: 0.75rem;
    }

    .paper-link {
        font-size: 0.8rem;
        padding: 0.15rem 0.5rem;
    }
}

.floating-extension {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.95);
    color: #f97316;
    text-decoration: none;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
}

.floating-extension:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
    background: #f9741625;
}

.floating-extension i {
    font-size: 1.2em;
}

.floating-extension span {
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
}

@media (max-width: 640px) {
    .floating-extension {
        bottom: 80px;
        right: 16px;
        padding: 10px 16px;
    }

    .scrolled {
        bottom: 20px;
    }
    
    .floating-extension span {
        display: none;
    }
    
    .floating-extension i {
        font-size: 1.4em;
    }
}

.alert {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    background-color: white;
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    max-width: 400px;
    display: none;
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.alert.show {
    display: block;
    animation: slideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.alert.hide {
    animation: slideOut 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.alert-message {
    color: var(--text-color);
    font-size: 0.95rem;
    line-height: 1.6;
    font-weight: 500;
}

@keyframes slideIn {
    from {
        transform: translateX(100%) translateY(0);
        opacity: 0;
    }
    to {
        transform: translateX(0) translateY(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0) translateY(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%) translateY(0);
        opacity: 0;
    }
}

/* Styles for Extension Information Section */
.extension-info {
    background-color: white;
    padding: 1.5rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.extension-info h2 {
    font-size: 1.75rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.extension-info h3 {
    font-size: 1.3rem;
    color: var(--text-color);
    margin-top: 1.25rem;
    margin-bottom: 0.75rem;
}

.extension-info p {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.extension-info ul,
.extension-info ol {
    padding-left: 1.5rem;
    margin: 1.25rem 0;
    color: var(--text-secondary);
}

.extension-info ul li,
.extension-info ol li {
    margin-bottom: 0.6rem;
}

.extension-info code {
    background-color: var(--hover-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.2rem 0.4rem;
    color: var(--text-color);
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9rem;
}

/* Links Section */
.links {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px dashed var(--border-color);
}

.links ul {
    list-style-type: none;
    padding-left: 0;
}

.links ul li {
    margin-bottom: 0.75rem;
}

.links a, .url {
    font-weight: 500;
    color: #3b82f6;
    text-decoration: none;
}

.links a:hover, .url:hover {
    color: #2563eb;
    border-bottom: 1px solid var(--primary-color);
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .extension-info {
        padding: 1rem;
    }

    .extension-info h2 {
        font-size: 1.4rem;
    }

    .extension-info h3 {
        font-size: 1.2rem;
    }

    .extension-info p,
    .extension-info ul,
    .extension-info ol {
        font-size: 0.9rem;
    }

    .extension-info code {
        font-size: 0.8rem;
    }
}
