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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    line-height: 1.6;
    color: #1d1d1f;
    background: linear-gradient(135deg, #f5f5f7 0%, #e8e8ed 100%);
    padding: 20px;
    min-height: 100vh;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    /* Top 200px in #ECECEB, rest stays light glass white */
    background: linear-gradient(#ECECEB 0px, #ECECEB 200px, rgba(255, 255, 255, 0.8) 200px);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

h1 {
    text-align: center;
    margin-bottom: 40px;
    color: #535B60;
    font-weight: 600;
    font-size: 2.5rem;
    letter-spacing: -0.02em;
}

/* Form Styles */
.header-section {
    margin-bottom: 30px;
    padding: 30px;
    background: #FFFFFF;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
}

.header-section .form-group {
    flex: 1;
    min-width: 300px;
    margin-right: 15px;
}

.header-section .form-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.keywords-section {
    width: 100%;
    padding: 0px;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.keywords-section h3 {
    margin-bottom: 15px;
    color: #1d1d1f;
    font-size: 1.2rem;
    font-weight: 600;
}

.keywords-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.keywords-section button {
    width: 100%;
    padding: 14px;
    font-size: 1.1rem;
    font-weight: 600;
}

.search-results {
    width: 100%;
    margin-top: 20px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.search-results h3 {
    margin-bottom: 15px;
    color: #1d1d1f;
    font-size: 1.2rem;
    font-weight: 600;
}

.keyword-results {
    margin-bottom: 1px;
    padding: 1px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.keyword-summary-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
}

.keyword-title {
    font-weight: 600;
    color: #1d1d1f;
    flex: 1;
}

.keyword-status {
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.9rem;
}

.keyword-status.success {
    background: rgba(40, 167, 69, 0.1);
    color: #28a745;
}

.keyword-status.warning {
    background: rgba(255, 193, 7, 0.1);
    color: #856404;
}

.keyword-status.error {
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

.expand-toggle {
    background: rgba(0, 122, 255, 0.1);
    color: #007aff;
    border: 1px solid rgba(0, 122, 255, 0.3);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.expand-toggle:hover {
    background: rgba(0, 122, 255, 0.2);
}

.keyword-details {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.domain-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.domain-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.domain-item.highlighted {
    background: rgba(0, 122, 255, 0.1);
    border-color: #007aff;
}

.domain-url {
    font-weight: 500;
    color: #1d1d1f;
}

.page-speed-btn {
    padding: 4px 8px;
    font-size: 0.8rem;
    background: linear-gradient(135deg, #34c759 0%, #28a745 100%);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.page-speed-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(52, 199, 89, 0.3);
}

.page-speed-btn.secondary {
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
    box-shadow: 0 2px 6px rgba(108, 117, 125, 0.3);
}

.page-speed-btn.secondary:hover {
    background: linear-gradient(135deg, #5a6268 0%, #495057 100%);
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.4);
}

.domain-item.error {
    background: rgba(220, 53, 69, 0.1);
    border-color: #dc3545;
}

.error-message {
    color: #dc3545;
    font-weight: 500;
}

.rank-badge {
    background: linear-gradient(135deg, #007aff 0%, #0056cc 100%);
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: bold;
    margin-left: 8px;
}

.keyword-summary {
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
}

.keyword-summary.success {
    background: rgba(40, 167, 69, 0.1);
    color: #28a745;
    border: 1px solid rgba(40, 167, 69, 0.3);
}

.keyword-summary.warning {
    background: rgba(255, 193, 7, 0.1);
    color: #856404;
    border: 1px solid rgba(255, 193, 7, 0.3);
}

.reviews-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.metric-box {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    text-align: center;
}

.metric-box label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #1d1d1f;
    font-size: 0.9rem;
}

.metric-box input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.8);
    color: #1d1d1f;
}

.page-speed-input {
    background: rgba(0, 122, 255, 0.1);
    border: 2px solid #007aff;
    font-size: 1.2rem;
    font-weight: bold;
    color: #007aff;
    text-align: center;
    width: 90px !important;
    padding: 8px 12px !important;
    flex: none !important;
}

.page-speed-input::placeholder {
    color: #666;
    font-weight: normal;
}

.api-status {
    font-size: 0.85rem;
    padding: 4px 8px;
    border-radius: 4px;
    margin-top: 5px;
    font-weight: 500;
}

.input-with-rewrite {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-with-rewrite textarea,
.input-with-rewrite div[contenteditable] {
    flex: 1;
}

.rewrite-single-btn {
    align-self: flex-start;
    padding: 6px 12px;
    background: linear-gradient(135deg, #007aff 0%, #0056cc 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0, 122, 255, 0.3);
}

.rewrite-single-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.4);
    background: linear-gradient(135deg, #0056cc 0%, #004499 100%);
}

.rewrite-single-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(0, 122, 255, 0.3);
}

.rewrite-single-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Form validation styles */
.form-group.error input,
.form-group.error select,
.form-group.error textarea {
    border-color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.form-group.success input,
.form-group.success select,
.form-group.success textarea {
    border-color: #28a745;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.1);
}

.validation-message {
    color: #dc3545;
    font-size: 0.85rem;
    margin-top: 4px;
    display: none;
}

.form-group.error .validation-message {
    display: block;
}

.sections-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

@media (max-width: 768px) {
    .sections-container {
        grid-template-columns: 1fr;
    }
    
    .header-section {
        flex-direction: column;
    }
    
    .header-section .form-group {
        width: 100%;
        margin-right: 0;
        margin-bottom: 15px;
    }
}

.form-section {
    margin-bottom: 25px;
    padding: 25px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    height: 100%;
    transition: all 0.3s ease;
}

/* Evidence box for Auto Analyze reasoning */
.evidence-box {
    font-size: 0.85rem;
    color: #6c757d;
    background: rgba(236, 236, 235, 0.7);
    border-left: 3px solid #007aff;
    padding: 8px 12px;
    border-radius: 10px;
    margin-bottom: 12px;
    white-space: pre-line; /* preserve newlines from backend text */
}

/* Layout for "Run Auto Analyze after search" option under Go button */
.auto-analyze-option {
    margin-top: 10px;
    font-size: 0.85rem;
    color: #424245;
    display: flex;
    align-items: center;
    gap: 6px;
}

.auto-analyze-option input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.auto-analyze-option label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 0;
    font-weight: 400;
}

.form-section:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
}

.form-section h2 {
    margin-bottom: 20px;
    font-size: 1.4rem;
    color: #1d1d1f;
    font-weight: 600;
    letter-spacing: -0.01em;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #424245;
    font-size: 0.95rem;
}

input[type="text"],
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    font-family: inherit;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

input[type="text"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #007aff;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
    background: rgba(255, 255, 255, 0.95);
}


select {
    cursor: pointer;
}

textarea {
    resize: vertical;
}

.form-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
}

button {
    padding: 12px 24px;
    background: linear-gradient(135deg, #007aff 0%, #0056cc 100%);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 122, 255, 0.4);
    background: linear-gradient(135deg, #0056cc 0%, #004499 100%);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
}

button[type="reset"] {
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3);
}

button[type="reset"]:hover {
    background: linear-gradient(135deg, #5a6268 0%, #495057 100%);
    box-shadow: 0 6px 20px rgba(108, 117, 125, 0.4);
}

/* PDF Preview Styles */
.hidden {
    display: none;
}

#pdfPreview {
    max-width: 900px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 0;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#reportCard {
    background-image: url('images/background.png');
    padding: 10px 30px 30px 0px; /* Reduced top padding */
    max-width: 100%;
    margin: 0 auto;
    page-break-inside: avoid;
    border-left: 100px solid #0056b3; /* Blue vertical bar on left */
    box-sizing: border-box;
}

.report-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px; /* Reduced margin */
    border-bottom: 2px solid #0056b3;
    padding-bottom: 10px; /* Reduced padding */
}

.logo-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.logo {
    font-weight: bold;
    color: #0056b3;
}

/* Brand row: logo left, title vertically centered with logo */
.brand-row {
    display: flex;
    align-items: center; /* vertical centering */
    gap: 16px;
    margin-bottom: 24px;
}

/* WebGrade logo in header */
.webgrade-logo {
    height: 120px;
    width: auto;
    display: block;
}

/* Brand text sits to the right of the logo */
.brand-text {
    display: flex;
    flex-direction: column;
    justify-content: center; /* vertical center of h1/h4 relative to logo */
}

/* Ensure title text is left-aligned inside brand row */
.brand-text h1 {
    text-align: left;
    margin-bottom: 4px;
}

.brand-text h4 {
    margin-top: 2px;           /* sit right under the h1 */
    text-align: left;
    color: #6c757d;            /* slightly softer than the h1 */
    font-weight: 400;
    font-size: 0.9rem;         /* smaller subheader / tag line */
    letter-spacing: 0.02em;
}

.patterson-logo {
    font-size: 1.5rem;
    margin-bottom: 5px;
    width: 200px;
}

.doctors-logo {
    font-size: 1.2rem;
        width: 200px;

}

.report-title {
    text-align: right;
}

.report-title h1 {
    font-size: 1.2rem;
    margin-bottom: 10px;
    text-align: right;
}

.report-title h2 {
    font-size: 1.8rem;
    color: #0056b3;
    margin-bottom: 5px;
}


.report-sections {
    display: flex;
    flex-direction: column;
    gap: 15px;
    page-break-inside: avoid;
}

.report-section {
    display: flex;
    gap: 15px;
    padding: 10px;
    page-break-inside: avoid;
    page-break-after: auto;
}

.section-icon {
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    background-color: white;
    padding: 5px;;
    border-radius: 50%;
}

.section-content {
    flex: 1;
}

.section-content h3 {
    margin-bottom: 5px;
    color: #0056b3;
}

.section-content h4 {
    margin-bottom: 10px;
    color: #6c757d;
}

.report-footer {
    margin-top: 30px;
    text-align: center;
    font-size: 0.9rem;
    color: #6c757d;
}

.report-summary {
    background-color: #e0e0e0; /* Gray background */
    padding: 15px 20px;
    margin: 20px 0 0 0;
    border-radius: 5px;
    page-break-inside: avoid;
    width: 100%;
    bottom: 0;
    left: 0;
    z-index: 99999999;
    clear: both;
    display: flex;
}
    


.preview-controls {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.modal-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
    padding: 0;
    animation: modalFadeIn 0.3s ease-out;
}

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

.modal-header {
    padding: 25px 30px 15px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    text-align: center;
}

.modal-header h3 {
    margin: 0;
    color: #1d1d1f;
    font-size: 1.4rem;
    font-weight: 600;
}

.modal-body {
    padding: 20px 30px 30px;
    text-align: center;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(0, 122, 255, 0.2);
    border-left: 4px solid #007aff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.modal-body p {
    margin: 10px 0;
    color: #424245;
    font-size: 1rem;
    line-height: 1.5;
}

.modal-status {
    font-size: 0.9rem !important;
    color: #6c757d !important;
    font-style: italic;
}

/* Grade Colors */
.grade-a { color: #28a745; }
.grade-b { color: #17a2b8; }
.grade-c { color: #ffc107; }
.grade-d { color: #fd7e14; }
.grade-f { color: #dc3545; }
/* Debug: Add red border to PDF preview container to check visibility */
#pdfPreview {
  border: 2px solid red !important;
}