/* Custom CSS styles will go here */

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa; /* Light gray background */
    display: flex;
    flex-direction: column;
    min-height: 100vh; /* Ensure footer is at bottom */
}

.container {
    max-width: 1280px; /* Wider layout for modern screens */
}

/* Header styles */
header.bg-dark {
    /* Bootstrap bg-dark is fine, maybe add a subtle border or shadow if desired later */
}

header h1 {
    font-size: 1.75rem; /* Slightly smaller than default Bootstrap h1 in a header */
}

/* Main content area */
main.container {
    flex-grow: 1; /* Allows main content to expand and push footer down */
    padding-top: 1rem;
    padding-bottom: 2rem;
}

/* Footer styles */
footer.footer {
    background-color: #e9ecef; /* Slightly different from default Bootstrap bg-light for contrast */
    border-top: 1px solid #dee2e6;
    font-size: 0.9rem;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    font-weight: 500;
}

h1 {
    font-size: 2.25rem;
}

h2 {
    font-size: 1.8rem;
}

h3 {
    font-size: 1.5rem;
}

a {
    color: #007bff; /* Bootstrap primary blue */
}

a:hover {
    color: #0056b3;
    text-decoration: none;
}

/* Search Form specific (can be moved to a component style later if needed) */
form[action*="search"] {
    margin-bottom: 2rem; /* More space below search form */
}

form[action*="search"] input[type="text"] {
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
    border-radius: 0.25rem;
    border: 1px solid #ced4da;
    transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out; /* For smooth focus transition */
}

form[action*="search"] input[type="text"]:focus {
    border-color: #80bdff; /* Bootstrap focus blue */
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25); /* Bootstrap focus shadow */
}

form[action*="search"] button[type="submit"] {
    padding: 0.5rem 1rem;
    font-size: 1rem;
    border-radius: 0.25rem;
    background-color: #007bff;
    color: white;
    border: 1px solid #007bff;
    cursor: pointer;
}

form[action*="search"] button[type="submit"]:hover {
    background-color: #0056b3;
    border-color: #0056b3;
}

/* Paper list item styling */
.paper-item {
    background-color: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    padding: 1.5rem;
    transition: box-shadow .2s ease;
    margin-bottom: 1.5rem;
    width: 100%;
}

.paper-item:hover {
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,.05);
}

.paper-item h3 {
    margin-top: 0; /* First heading in item */
}

.paper-item p {
    margin-bottom: 0.5rem;
}

.paper-item strong {
    color: #495057;
}

/* Pagination styling */
.pagination-nav {
    display: flex;
    justify-content: center;
    width: 100%;
}

.pagination-nav .pagination {
    margin: 0 auto 2rem auto;
}

.pagination a, .pagination span {
    padding: 0.5rem 0.75rem;
    margin: 0 0.25rem;
    border: 1px solid #dee2e6;
    text-decoration: none;
    color: #007bff;
    border-radius: 0.25rem;
}

.pagination a:hover {
    background-color: #e9ecef;
}

.pagination span.disabled {
    color: #6c757d;
    background-color: #f8f9fa;
    cursor: default;
}

.pagination span.current {
    color: #fff;
    background-color: #007bff;
    border-color: #007bff;
}

/* Error messages */
.error-message {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
    padding: 0.75rem 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: 0.25rem;
}

/* Loading Spinner (to be used with JavaScript later) */
.loading-spinner {
    border: 4px solid #f3f3f3; /* Light grey */
    border-top: 4px solid #007bff; /* Blue */
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 20px auto; /* Example positioning */
    display: none; /* Hidden by default, shown by JS */
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Design Rules */

/* Small devices (landscape phones, less than 768px) */
@media (max-width: 767.98px) {
    body {
        font-size: 0.95rem; /* Slightly smaller base font for small screens */
    }

    header h1 {
        font-size: 1.5rem; /* Adjust header title size */
        text-align: center;
    }

    main.container {
        padding-left: 15px;
        padding-right: 15px;
    }

    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.6rem;
    }

    h3 {
        font-size: 1.3rem;
    }

    form[action*="search"] input[type="text"] {
        width: 100%;
        margin-bottom: 0.5rem; /* Add space between input and button when stacked */
    }

    form[action*="search"] button[type="submit"] {
        width: 100%;
    }

    .paper-item {
        padding: 1rem;
    }

    #ai-summary-container {
        padding: 10px;
        margin-bottom: 15px;
    }

    #ai-summary-content {
        max-height: 300px; /* Adjust max-height for smaller screens */
        font-size: 0.9em; /* Slightly smaller text in summary on small screens */
    }

    #ai-summary-container h4 {
        font-size: 1.1rem; /* Adjust heading size in summary */
    }

    #close-summary-button {
        font-size: 1.1rem;
        padding: 0.2rem 0.4rem;
    }

    .pagination a, .pagination span {
        padding: 0.4rem 0.6rem;
        font-size: 0.9rem;
    }
}

/* Extra small devices (portrait phones, less than 576px) */
@media (max-width: 575.98px) {
    header h1 {
        font-size: 1.3rem;
    }
    
    .paper-item h3 {
        font-size: 1.2rem;
    }

    .paper-item p {
        font-size: 0.9rem;
    }

    #ai-summary-container {
        padding: 8px;
    }

    #ai-summary-content {
        max-height: 250px; /* Further adjust max-height */
        font-size: 0.85em;
    }

    #ai-summary-container h4 {
        font-size: 1rem;
    }

    #close-summary-button {
        font-size: 1rem;
        padding: 0.15rem 0.35rem;
    }

    .pagination {
        font-size: 0.85rem; /* Make pagination text even smaller */
    }

    .pagination a, .pagination span {
        padding: 0.3rem 0.5rem;
        margin: 0 0.15rem;
    }
}

/* AI Summary Specific Styles */
#ai-summary-container {
    /* Existing styles are good, ensure it behaves well responsively */
    /* Adding overflow for very long content that might not wrap nicely */
    overflow-x: hidden; /* Prevent horizontal scroll from unexpected content */
}

#ai-summary-container .loading-indicator-text {
    font-style: italic;
    color: #555;
}

#ai-summary-container .summary-error-text {
    color: #d9534f; /* Bootstrap danger color */
    font-weight: bold;
}

#ai-summary-container .summary-success-text {
    color: #5cb85c; /* Bootstrap success color */
}

#ai-summary-content {
    overflow-wrap: break-word; /* Help prevent layout breaks from long words/strings */
    word-wrap: break-word; /* Legacy browsers */
    max-height: 400px; /* Suggestion: Limit height and make scrollable if content is too long */
    overflow-y: auto;  /* Add scroll for overflowing content */
}

#close-summary-button {
    /* Basic styling, btn-light and btn-sm from Bootstrap should be mostly fine */
    /* Ensure it's not too small on touch devices if custom styling is added */
    padding: 0.25rem 0.5rem;
    font-size: 1.25rem; /* Make the 'x' a bit larger */
    line-height: 1;
    margin-left: 10px; /* Some space from the heading */
}

#summarize-button:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

/* Simple spinner for summary loading */
.summary-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0,0,0,.1);
    border-radius: 50%;
    border-top-color: #007bff; /* Primary color */
    animation: spin 1s ease-in-out infinite;
    margin-right: 8px;
    vertical-align: middle;
}

/* Ensure loading spinner from main search doesn't conflict if reused by name */
#search-results-block .loading-indicator p {
    /* Styles for main search loading text if any */
}

#search-results-block.is-loading .loading-indicator {
    /* Styles for main search loading container if any */
    padding: 20px;
    text-align: center;
    font-size: 1.2em;
}

/* Single Paper Summary Modal Styles */
.modal {
    position: fixed; /* Stay in place */
    z-index: 1050; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: hidden; /* Disable scroll on body when modal is open (handled by JS potentially) */
    background-color: rgba(0,0,0,0.5); /* Black w/ opacity for overlay */
    display: none; /* Hidden by default - controlled by JS */
}

.modal-dialog {
    position: relative;
    margin: 1.75rem auto; /* Centered, with some space from top/bottom */
    pointer-events: none; /* Let clicks pass through to modal-content */
    max-width: 800px; /* Default max-width for modal-lg */
}

.modal.show .modal-dialog {
    transform: none; /* For transitions if added */
}

.modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    pointer-events: auto;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid rgba(0,0,0,.2);
    border-radius: 0.3rem;
    outline: 0;
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 1rem 1rem;
    border-bottom: 1px solid #dee2e6;
    border-top-left-radius: calc(0.3rem - 1px);
    border-top-right-radius: calc(0.3rem - 1px);
}

.modal-header .close {
    padding: 1rem 1rem;
    margin: -1rem -1rem -1rem auto;
    background-color: transparent;
    border: 0;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    color: #000;
    text-shadow: 0 1px 0 #fff;
    opacity: .5;
}
.modal-header .close:hover {
    opacity: .75;
}

.modal-title {
    margin-bottom: 0;
    line-height: 1.5;
    font-size: 1.25rem;
}

.modal-body {
    position: relative;
    flex: 1 1 auto;
    padding: 1rem;
    max-height: 70vh; /* Limit height and make scrollable */
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    padding: 0.75rem;
    border-top: 1px solid #dee2e6;
    border-bottom-right-radius: calc(0.3rem - 1px);
    border-bottom-left-radius: calc(0.3rem - 1px);
}

.modal-footer > * {
    margin: 0.25rem;
}

/* Responsive adjustments for modal */
@media (max-width: 991.98px) { /* Corresponds to Bootstrap's lg breakpoint */
    .modal-dialog.modal-lg, .modal-dialog.modal-xl {
        max-width: 800px; 
    }
}

@media (max-width: 767.98px) { /* md breakpoint */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    .modal-content {
        height: calc(100vh - 1rem); /* Full height on small screens */
    }
    .modal-body {
        max-height: calc(100vh - 1rem - 56px - 53px); /* Adjust based on header/footer height */
    }
}

@media (max-width: 575.98px) { /* sm breakpoint */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 0.75rem;
    }
    .modal-title {
        font-size: 1.1rem;
    }
    .modal-body {
         max-height: calc(100vh - 1rem - 50px - 48px); /* Further adjust */
    }
}

/* --- Hero Section --- */
.hero {
    background: linear-gradient(135deg,#f8fbff 0%,#eef5ff 100%);
    border-radius: 8px;
    position: relative;
}
.hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: repeating-linear-gradient(135deg,rgba(255,255,255,0.15) 0 10px,transparent 10px 20px);
    border-radius: 8px;
    pointer-events: none;
}
.hero h1 {
    font-weight: 600;
}
.hero form {
    max-width: 600px;
    margin: 0 auto;
}
.hero input[type="text"] {
    height: 56px;
    font-size: 1.125rem;
}
.hero button[type="submit"] {
    height: 56px;
    font-size: 1.125rem;
    padding: 0 1.5rem;
}

/* Sticky summary adjustments */
#ai-summary-container .card {
    border: 1px solid #e0e0e0;
    border-radius: 0.5rem;
}

/* Summarize button embellishment */
#summarize-button.btn-primary:hover {
    box-shadow: 0 .5rem 1rem rgba(0,123,255,.25) !important;
}

.subscription-widget input[type="email"], .subscription-widget input[type="text"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
}
.subscription-widget .form-actions {
    display: flex;
    gap: 0.5rem;
}
@media (max-width: 575.98px) {
    .subscription-widget .form-actions {
        flex-direction: column;
    }
} 