/* --- Material Design 3 High-Contrast Dark Theme --- */
:root {
    --border-radius-sm: 8px;
    --border-radius-md: 16px;
    --border-radius-lg: 24px;
}

/* --- Theme Definitions --- */
body.theme-default {
    --md-sys-color-primary: #0085D0;
    --md-sys-color-on-primary: #000000;
    --md-sys-color-primary-container: #4F378B;
    --md-sys-color-on-primary-container: #EADDFF;
    --md-sys-color-secondary: #03DAC6;
    --md-sys-color-on-secondary: #000000;
    --md-sys-color-secondary-container: #03DAC6;
    --md-sys-color-on-secondary-container: #000000;
    --md-sys-color-background: #121212;
    --md-sys-color-on-background: #E1E1E1;
    --md-sys-color-surface: #1E1E1E;
    --md-sys-color-surface-variant: #252525;
    --md-sys-color-on-surface: #E1E1E1;
    --md-sys-color-on-surface-variant: #C9C9C9;
    --md-sys-color-outline: #3E3E3E;
    --md-sys-color-error: #CF6679;
}

body.theme-regular {
    /* GitHub Dark Theme (Dimmed) */
    --md-sys-color-primary: #58A6FF;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: #1F6FEB;
    --md-sys-color-on-primary-container: #FFFFFF;
    --md-sys-color-secondary: #3FB950;
    --md-sys-color-on-secondary: #FFFFFF;
    --md-sys-color-secondary-container: #308146;
    --md-sys-color-on-secondary-container: #FFFFFF;
    --md-sys-color-background: #0D1117;
    --md-sys-color-on-background: #C9D1D9;
    --md-sys-color-surface: #161B22;
    --md-sys-color-surface-variant: #21262D;
    --md-sys-color-on-surface: #C9D1D9;
    --md-sys-color-on-surface-variant: #8B949E;
    --md-sys-color-outline: #30363D;
    --md-sys-color-error: #F85149;
}

body.theme-contrast {
    /* High Contrast Github Theme */
    --md-sys-color-primary: #1F6FEB;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: #0C2D64;
    --md-sys-color-on-primary-container: #FFFFFF;
    --md-sys-color-secondary: #238636;
    --md-sys-color-on-secondary: #FFFFFF;
    --md-sys-color-secondary-container: #004D1B;
    --md-sys-color-on-secondary-container: #FFFFFF;
    --md-sys-color-background: #06090F;
    --md-sys-color-on-background: #F0F6FC;
    --md-sys-color-surface: #0D1117;
    --md-sys-color-surface-variant: #161B22;
    --md-sys-color-on-surface: #F0F6FC;
    --md-sys-color-on-surface-variant: #C9D1D9;
    --md-sys-color-outline: #21262D;
    --md-sys-color-error: #DA3633;
}


/* --- Global & Theme --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-on-background);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

h1 {
    color: var(--md-sys-color-primary);
    font-weight: 400;
}

a {
    color: var(--md-sys-color-primary);
    text-decoration: none;
    transition: opacity 0.3s ease;
}

a:hover {
    opacity: 0.8;
}

.material-symbols-outlined {
  font-variation-settings:
  'FILL' 0,
  'wght' 300,
  'GRAD' 0,
  'opsz' 24
}

/* --- Header & Controls --- */
.header {
    background-color: var(--md-sys-color-surface);
    padding: 16px 30px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    border-bottom: 1px solid var(--md-sys-color-outline);
}

.header-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.controls-container {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    flex-grow: 1;
    justify-content: flex-start;
}

.settings-container {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.input-group {
    display: flex;
    align-items: center;
    background-color: var(--md-sys-color-surface);
    border: 1px solid var(--md-sys-color-outline);
    border-radius: var(--border-radius-lg);
    padding: 8px 16px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.input-group:focus-within {
    border-color: var(--md-sys-color-primary);
    box-shadow: 0 0 0 2px var(--md-sys-color-primary-container);
}

.input-group .material-symbols-outlined {
    color: var(--md-sys-color-on-surface-variant);
    margin-right: 8px;
}

input[type="text"],
input[type="password"],
input[type="number"] {
    background: none;
    border: none;
    outline: none;
    color: var(--md-sys-color-on-surface);
    font-size: 16px;
    width: 200px;
}

input[type="number"] {
    width: 100px;
}

/* Remove number input spinners */
input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { 
  -webkit-appearance: none; 
  margin: 0; 
}
input[type=number] {
  -moz-appearance: textfield;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: var(--border-radius-lg);
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.btn:hover {
    filter: brightness(1.1);
}

.btn-filled {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border-color: var(--md-sys-color-primary);
}

.btn-outlined {
    background-color: transparent;
    color: var(--md-sys-color-primary);
    border-color: var(--md-sys-color-outline);
}

.btn-outlined:hover {
    background-color: rgba(187, 134, 252, 0.08);
}

.btn-icon {
    padding: 8px;
    border-radius: 50%;
    background-color: transparent;
    color: var(--md-sys-color-on-surface-variant);
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
}
.btn-icon:hover {
    background-color: var(--md-sys-color-surface-variant);
}
.btn-icon.active {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}
#sort-direction-btn.desc {
    transform: rotate(0deg);
}
#sort-direction-btn.asc {
    transform: rotate(180deg);
}

/* --- Main Content & Filters --- */
.main-content {
    padding: 24px 30px;
    max-width: 1600px;
    margin: 0 auto;
}

.filter-sort-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.filter-group {
    flex-grow: 1;
}
.commit-filter-group input {
    width: 110px;
}
.commit-filter-group input:first-of-type {
    margin-right: 8px;
}


.sort-group {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
}

.select-wrapper {
    position: relative;
}

.select-wrapper .material-symbols-outlined {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--md-sys-color-on-surface-variant);
}

.styled-select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    border: 1px solid var(--md-sys-color-outline);
    border-radius: var(--border-radius-lg);
    padding: 10px 36px 10px 16px;
    font-size: 14px;
    outline: none;
    cursor: pointer;
    height: 44px;
}
.theme-switcher .styled-select {
    padding: 8px 36px 8px 0px;
    border: none;
    height: auto;
}
.theme-switcher {
    padding-left: 12px;
}


.styled-select:focus {
    border-color: var(--md-sys-color-primary);
}

/* --- Profile Section --- */
.profile-container {
    display: flex;
    align-items: flex-start;
    gap: 24px;
    background-color: var(--md-sys-color-surface);
    border-radius: var(--border-radius-md);
    padding: 24px;
    margin-bottom: 24px;
    border: 1px solid var(--md-sys-color-outline);
    flex-wrap: wrap;
}

.profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 3px solid var(--md-sys-color-primary);
    flex-shrink: 0;
}

.profile-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-grow: 1;
}

/* Styles for the profile link */
.profile-name-link {
    text-decoration: none;
    transition: opacity 0.3s ease;
    display: inline-block;
}
.profile-name-link:hover {
    opacity: 0.8;
}
.profile-name-link:hover .profile-name {
    text-decoration: underline;
}
.profile-name {
    font-size: 28px;
    font-weight: 700;
    color: var(--md-sys-color-primary);
}
.profile-login {
    font-size: 18px;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 8px;
}

.profile-bio {
    font-size: 16px;
    color: var(--md-sys-color-on-surface-variant);
    margin-top: 4px;
    max-width: 60ch;
}

.profile-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 12px;
    color: var(--md-sys-color-on-surface-variant);
}

.profile-stats .stat-item {
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.download-profile-btn {
    margin: 0;
    padding: 4px;
    width: 32px;
    height: 32px;
    align-self: center;
}

.download-profile-btn .material-symbols-outlined {
    font-size: 20px;
}

/* --- Download modal styles --- */
.download-controls {
    padding-bottom: 12px;
    border-bottom: 1px solid var(--md-sys-color-outline);
    margin-bottom: 16px;
}
.download-select-all-label {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
}
.download-select-all-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.download-list-container {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    max-height: 50vh;
    overflow-y: auto;
    padding-right: 8px;
    margin-bottom: 24px;
}

.download-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--border-radius-sm);
    background-color: var(--md-sys-color-surface);
    border: 1px solid var(--md-sys-color-outline);
    flex-basis: 300px;
    flex-grow: 1;
}
.download-item:hover {
     background-color: var(--md-sys-color-surface-variant);
}

.download-item-info {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    flex-grow: 1;
}
.download-item-info input[type="checkbox"] {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}
.download-item-info span {
    word-break: break-all;
}

.btn-download-single {
    flex-shrink: 0;
}

.modal-footer {
    margin-top: auto; 
    padding-top: 16px;
    border-top: 1px solid var(--md-sys-color-outline);
    display: flex;
    justify-content: flex-end;
}

.profile-readme-container {
    background-color: var(--md-sys-color-surface-variant);
    border-radius: var(--border-radius-md);
    padding: 24px;
    margin-bottom: 24px;
    border: 1px solid var(--md-sys-color-outline);
}

/* --- Repo List & Cards --- */
.repo-list {
    display: grid;
    gap: 20px;
    grid-template-columns: 1fr;
}

/* 2. Tablets / Small Desktops: 3 columns */
@media (min-width: 768px) {
    .repo-list {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* 3. Large Desktops: 4 columns */
@media (min-width: 1200px) {
    .repo-list {
        grid-template-columns: repeat(4, 1fr);
    }
}


.repo-card {
    background-color: var(--md-sys-color-surface-variant);
    border-radius: var(--border-radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    border: 1px solid var(--md-sys-color-outline);
    transition: transform 0.3s ease, background-color 0.3s ease;
    cursor: pointer;
    animation: fadeIn 0.4s ease-out;
}

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

.repo-list .repo-card:hover {
    transform: translateY(-4px);
    background-color: #333333;
}

.repo-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.repo-card-header h3 {
    font-size: 20px;
    font-weight: 500;
    word-break: break-all;
    flex-grow: 1;
}

.repo-card-header h3 a {
    color: var(--md-sys-color-primary);
}

.repo-card-links {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}
.repo-card-links a {
    color: var(--md-sys-color-on-surface-variant);
}


.repo-card .description {
    font-size: 14px;
    color: var(--md-sys-color-on-surface-variant);
    flex-grow: 1;
    line-height: 1.5;
    min-height: 42px;
}

.repo-topics {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.topic-tag {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    padding: 4px 10px;
    border-radius: var(--border-radius-sm);
    font-size: 12px;
    font-weight: 500;
}

.repo-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 14px;
    color: var(--md-sys-color-on-surface-variant);
    border-top: 1px solid var(--md-sys-color-outline);
    padding-top: 16px;
    margin-top: auto;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.stat-item .material-symbols-outlined {
    font-size: 18px;
}
.commit-count .loader-small {
    width: 14px;
    height: 14px;
    border-width: 2px;
}

.language-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.repo-card-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}
.repo-card-actions .btn {
    flex-grow: 1;
    padding: 8px 16px;
    font-size: 12px;
    border-radius: var(--border-radius-md);
}

/* Copy button style */
.repo-card-actions .btn-copy {
    flex-grow: 0;
    padding: 8px 12px;
}
.repo-card-actions .btn-copy .material-symbols-outlined {
    margin: 0;
    font-size: 18px;
}


/* --- Loader & Messages --- */
.loader-container {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 40px 0;
}

.loader {
    width: 48px;
    height: 48px;
    border: 4px solid var(--md-sys-color-surface-variant);
    border-top-color: var(--md-sys-color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
.loader-small {
    width: 24px;
    height: 24px;
    border: 3px solid var(--md-sys-color-surface-variant);
    border-top-color: var(--md-sys-color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.error-message {
    color: var(--md-sys-color-error);
    text-align: center;
    font-size: 18px;
    padding: 20px;
}

/* --- Skeleton Loader --- */
@keyframes pulse {
    0% { background-color: var(--md-sys-color-surface-variant); }
    50% { background-color: #333; }
    100% { background-color: var(--md-sys-color-surface-variant); }
}
.skeleton-card {
    background-color: var(--md-sys-color-surface-variant);
    border-radius: var(--border-radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    border: 1px solid var(--md-sys-color-outline);
}
.skeleton-text-lg {
    width: 60%;
    height: 24px;
    background-color: var(--md-sys-color-surface);
    border-radius: var(--border-radius-sm);
    animation: pulse 1.5s infinite ease-in-out;
}
.skeleton-text-sm {
    width: 90%;
    height: 16px;
    background-color: var(--md-sys-color-surface);
    border-radius: var(--border-radius-sm);
    animation: pulse 1.5s infinite ease-in-out;
}
.skeleton-card .skeleton-text-sm:nth-child(3) {
    width: 70%;
}
.skeleton-stats {
    display: flex;
    gap: 16px;
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--md-sys-color-outline);
}
.skeleton-stats .skeleton-text-sm {
    width: 25%;
}


/* --- README Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background-color: var(--md-sys-color-surface-variant);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    border: 1px solid var(--md-sys-color-outline);
    display: flex;
    flex-direction: column;
}

.modal-title {
    color: var(--md-sys-color-on-surface);
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--md-sys-color-outline);
}

.modal-close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: var(--md-sys-color-on-surface-variant);
    cursor: pointer;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
    z-index: 10;
}
.modal-close-btn:hover {
    background-color: rgba(255,255,255,0.1);
}

.modal-content .readme-container {
    margin-top: 0;
}

/* Styles for rendered Markdown content */
.readme-container h1, .readme-container h2 {
    border-bottom: 1px solid var(--md-sys-color-outline);
    padding-bottom: .3em;
    margin-top: 24px;
    margin-bottom: 16px;
}
.readme-container h1 { font-size: 2em; }
.readme-container h2 { font-size: 1.5em; }
.readme-container h3 { font-size: 1.25em; margin-bottom: 12px; }
.readme-container p { margin-bottom: 16px; }
.readme-container ul, .readme-container ol { margin-left: 20px; margin-bottom: 16px; }
.readme-container li { margin-bottom: 8px; }
.readme-container pre {
    background-color: var(--md-sys-color-background);
    padding: 16px;
    border-radius: var(--border-radius-sm);
    overflow-x: auto;
    margin-bottom: 16px;
    border: 1px solid var(--md-sys-color-outline);
}
.readme-container code {
    font-family: 'Courier New', Courier, monospace;
    background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-secondary);
    padding: .2em .4em;
    border-radius: 6px;
    border: 1px solid var(--md-sys-color-outline);
}
.readme-container pre code {
    padding: 0;
    background: none;
    color: inherit;
    border: none;
}

.readme-container blockquote {
    padding: 0 1em;
    color: var(--md-sys-color-on-surface-variant);
    border-left: .25em solid var(--md-sys-color-outline);
    margin: 0 0 16px;
}
.readme-container table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
}
.readme-container th, .readme-container td {
    padding: 8px;
    border: 1px solid var(--md-sys-color-outline);
}
.readme-container th {
    background-color: var(--md-sys-color-surface);
}

/* --- Commits Modal --- */
.commits-list-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.commit-item {
    display: flex;
    gap: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--md-sys-color-outline);
}
.commit-item:last-child {
    border-bottom: none;
}
.commit-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
}
.commit-details {
    display: flex;
    flex-direction: column;
}
.commit-message {
    font-size: 16px;
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
    margin-bottom: 4px;
}
.commit-author {
    font-size: 14px;
    color: var(--md-sys-color-on-surface-variant);
}
.commit-author span {
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
}
.commit-sha {
    font-family: monospace;
    font-size: 12px;
    color: var(--md-sys-color-primary);
    margin-left: auto;
    padding-left: 16px;
    align-self: flex-start;
}

/* --- Toast Notification --- */
.toast {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    padding: 12px 24px;
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    font-weight: 500;
    z-index: 2000;
    transition: bottom 0.5s ease;
}
.toast.show {
    bottom: 30px;
}


/* --- Responsive Overrides --- */
@media (max-width: 480px) {
    .main-content {
        padding: 16px;
    }

    .header {
        padding: 16px;
    }

    .controls-container, .settings-container {
        width: 100%;
        gap: 8px;
    }

    .input-group {
        width: 100%;
    }

    input[type="text"], input[type="password"] {
        width: 100%;
    }

    .sort-group {
        width: 100%;
    }

    .select-wrapper {
        flex-grow: 1;
    }
    .styled-select {
        width: 100%;
    }
}


/* Legacy Banner Styles */
#legacy-banner {
    background-color: #ff9800; /* Orange for visibility */
    color: #000;
    text-align: center;
    padding: 12px;
    font-family: sans-serif;
    font-size: 14px;
    position: sticky;
    top: 0;
    z-index: 9999;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#legacy-banner a {
    color: #000;
    font-weight: bold;
    text-decoration: underline;
    margin-left: 10px;
    padding: 4px 8px;
    background: rgba(255,255,255,0.3);
    border-radius: 4px;
    transition: background 0.2s;
}

#legacy-banner a:hover {
    background: rgba(255,255,255,0.6);
}