/* Custom styles for Algorithm1 Web App */

/* Base styles */

/* Loading spinner */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #2563eb;
    animation: spin 1s ease-in-out infinite;
    margin-right: 8px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #475569;
    --accent-color: #0ea5e9;
    --light-bg: #f8fafc;
    --dark-text: #1e293b;
    --light-text: #64748b;
    --border-color: #e2e8f0;
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --card-hover-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    line-height: 1.6;
    background-color: var(--light-bg);
    color: var(--dark-text);
}

.container {
    max-width: 100%;
}

.page-header {
    text-align: left;
    margin: 0;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, #4f46e5 100%);
    border-radius: 0;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    color: white;
}

.page-header.sticky {
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    background: none;
    -webkit-background-clip: unset;
    -webkit-text-fill-color: unset;
    background-clip: unset;
    color: white;
}

.page-header p {
    display: none;
}

.status-control {
    display: inline-flex;
    gap: 0.5rem;
}

.status-btn {
    border: 1px solid var(--border-color);
    padding: 0.25rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    background: #f8fafc;
    color: #334155;
}

.status-btn.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

.status-display {
    font-size: 0.75rem;
    color: #64748b;
}

/* Chapter card styles */
.chapter-card {
    transition: all 0.2s ease;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: white;
    box-shadow: var(--card-shadow);
    overflow: hidden;
    opacity: 1;
    transform: translateY(0);
}

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

.chapter-card h3 {
    color: var(--dark-text);
    margin-bottom: 0.5rem;
}

.chapter-card p {
    color: var(--light-text);
    font-size: 0.9rem;
}

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



/* Grid layout for chapter cards */
.chapters-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-top: 1rem;
    width: 100%;
}

@media (max-width: 1200px) {
    .chapters-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 900px) {
    .chapters-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .chapters-grid {
        grid-template-columns: 1fr;
    }
}

/* Algorithm detail styles */
#algorithm-detail {
    background: white;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    padding: 2rem;
}

#personal-center {
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    background: white;
}

.pc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.pc-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--dark-text);
}

.pc-stats {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.pc-stat {
    padding: 0.4rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 500;
}

.pc-green { background: #dcfce7; color: #166534; }
.pc-yellow { background: #fef9c3; color: #854d0e; }
.pc-red { background: #fee2e2; color: #991b1b; }
.pc-gray { background: #e5e7eb; color: #374151; }

.pc-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

@media (max-width: 1200px) {
    .pc-list { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 700px) {
    .pc-list { grid-template-columns: 1fr; }
}

.pc-card {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.pc-card-title {
    font-size: 0.95rem;
    color: var(--dark-text);
    font-weight: 500;
}

.pc-card-sub {
    font-size: 0.75rem;
    color: var(--light-text);
}

.pc-badge {
    padding: 0.25rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    border: 1px solid var(--border-color);
}

#algorithm-detail h2 {
    color: var(--dark-text);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
    font-size: 1.75rem;
    font-weight: 700;
}

#back-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.3rem 0.6rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: inline-flex;
    align-items: center;
    font-weight: 500;
    font-size: 0.8rem;
}

#back-btn:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

#back-btn svg {
    margin-right: 0.5rem;
}

.algorithm-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background-color: #f8fafc;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.algorithm-section:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.algorithm-section:last-child {
    margin-bottom: 0;
}

.algorithm-section h3 {
    color: var(--dark-text);
    margin-bottom: 1rem;
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Tab styles */
.tab-container {
    display: flex;
    min-height: 280px;
    background: white;
    border-radius: 8px;
    overflow: visible;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.tab-buttons {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    background-color: #f1f5f9;
}

.tab-button {
    transition: all 0.2s ease;
    border: none;
    background: transparent;
    padding: 1rem 1.5rem;
    font-weight: 500;
    color: var(--light-text);
    position: relative;
}

.tab-button.active {
    color: var(--primary-color);
    background: white;
}

.tab-button.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 3px;
    background-color: var(--primary-color);
}

.tab-button:hover:not(.active) {
    color: var(--dark-text);
    background-color: #e2e8f0;
}

.tab-content {
    display: none;
    padding: 0.75rem;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

.tab-content-wrapper {
    min-height: 220px;
    height: 100%;
}

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

/* Input/Output styles */
.input-output {
    background-color: transparent;
    border: none;
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    box-shadow: none;
}

/* Compact the Tailwind container used in description tab */
.tab-content .bg-gray-50 {
    padding: 0.75rem !important;
}

.input-output h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--dark-text);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
}

.input-output h4::before {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--primary-color);
    margin-right: 0.5rem;
}

.input-output pre {
    background-color: transparent;
    border-radius: 6px;
    padding: 0.5rem;
    overflow-x: auto;
    font-size: 0.85rem;
    line-height: 1.4;
    border: none;
}

/* LeetCode link button */
.leetcode-link {
    display: inline-flex;
    align-items: center;
    background-color: var(--primary-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.leetcode-link:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.leetcode-link svg {
    margin-right: 0.25rem;
}

/* Code block styles */
.code-container {
    background-color: #ffffff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
}

.code-container .code-header {
    background-color: #f1f5f9;
    color: #334155;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e2e8f0;
}

/* Problem link click styles */
.problem-link {
    transition: all 0.2s ease;
}
.problem-link.visited {
    background-color: #f3f4f6 !important;
    color: #4b5563 !important;
    border: 1px solid #e5e7eb;
}
.problem-link.visited:hover {
    background-color: #e5e7eb !important;
}
.problem-link.frequent {
    background-color: #fff7ed !important;
    color: #c2410c !important;
    border: 1px solid #fed7aa;
}
.problem-link.frequent:hover {
    background-color: #ffedd5 !important;
}

.code-container .code-header .copy-btn {
    background-color: #e2e8f0;
    color: #334155;
    border: none;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    font-size: 0.75rem;
    transition: background-color 0.2s;
}

.code-container .code-header .copy-btn:hover {
    background-color: #cbd5e1;
}

pre[class*="language-"] {
    border-radius: 0;
    margin: 0;
    padding: 0.75rem;
    font-size: 0.88rem;
    line-height: 1.45;
    overflow-x: auto;
    background: #ffffff !important;
    color: #334155;
}

pre[class*="language-"]::-webkit-scrollbar {
    height: 8px;
}

pre[class*="language-"]::-webkit-scrollbar-track {
    background: #0f172a;
}

pre[class*="language-"]::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 4px;
}

pre[class*="language-"]::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* Step visualization styles */
.step-container {
    background-color: white;
    border-radius: 8px;
    padding: 1rem;
    margin: 0.5rem 0;
    border-left: none;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.steps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 0.75rem 0.75rem;
    margin-top: 0.5rem;
}

.step-container:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateX(3px);
}

.step {
    display: flex;
    align-items: flex-start;
}

.step-number {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-right: 0.75rem;
    font-size: 0.8rem;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.step-content {
    flex: 1;
}

.step-content h4 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
    font-weight: 600;
    color: var(--dark-text);
}

.step-content p {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    line-height: 1.5;
    color: var(--light-text);
}

.step-content .mt-2 {
    margin-top: 0.5rem;
}

/* Example code styles */
.example-code {
    background-color: transparent;
    border-radius: 8px;
    padding: 0.75rem;
    margin: 0.75rem 0;
    border: none;
    box-shadow: none;
}

.example-code h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--dark-text);
    margin-bottom: 0.75rem;
}

/* Responsive adjustments */
@media (max-width: 1100px) {
    /* Stack tab container vertically to avoid squeezing */
    .tab-container {
        flex-direction: column;
        gap: 1rem;
        min-height: 300px;
    }

    /* Left column (tabs/content) goes full width */
    .tab-container > div:first-child {
        width: 100%;
        margin-right: 0;
        margin-bottom: 1rem;
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
    }

    /* Right column (code area) becomes full width and non-sticky */
    .tab-container > div:last-child {
        width: 100%;
        max-width: 100% !important;
        position: static;
        top: auto;
        align-self: auto;
        order: -1; /* show code first on small screens */
    }
}
@media (max-width: 768px) {
    .step {
        flex-direction: column;
    }
    
    .step-number {
        margin-right: 0;
        margin-bottom: 0.5rem;
    }
    
    /* Make tab container stack vertically on small screens */
    .tab-container {
        flex-direction: column;
        min-height: 300px;
    }
    
    /* Adjust width of tab sidebar on small screens */
    .tab-container > div:first-child {
        width: 100%;
        flex-direction: row;
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
        margin-right: 0;
        margin-bottom: 1rem;
    }

    /* Ensure code area fills width on very small screens */
    .tab-container > div:last-child {
        width: 100%;
        max-width: 100%;
        position: static;
        top: auto;
        align-self: auto;
    }
    
    /* Adjust tab button styles on small screens */
    .tab-button {
        text-align: center;
        flex: 1;
        padding: 0.6rem;
        font-size: 0.75rem;
    }
    
    .tab-button.active {
        border-right: none;
        border-bottom: 3px solid #3730a3;
    }
    
    /* Adjust content area on small screens */
    .tab-content-wrapper {
        min-height: 250px;
        padding: 0.5rem;
    }
    

    
    /* Even smaller steps on mobile */
    .step-container {
        padding: 0.4rem;
        margin: 0.2rem 0;
    }
    
    .step-content h4 {
        font-size: 0.8rem;
    }
    
    .step-content p {
        font-size: 0.7rem;
    }
}
.pc-filters {
    display: flex;
    gap: 0.5rem;
    margin: 0.5rem 0 1rem 0;
}

.pc-filter {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    background: #ffffff;
    color: #334155;
    cursor: pointer;
}

.pc-filter.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}
.detail-sticky {
    position: sticky;
    top: 0;
    z-index: 40;
    background: #ffffff;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.mastered-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #16a34a;
    display: inline-block;
    box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.2);
}

.chapters-filters {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.filters-bar {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.search-input {
    flex: 1 1 280px;
    max-width: 420px;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9rem;
    background: #ffffff;
    color: var(--dark-text);
}

.select {
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9rem;
    background: #ffffff;
    color: var(--dark-text);
}
