:root {
    /* Mocha Theme */
    --mocha-base: #1e1e2e;
    --mocha-base-rgb: 30, 30, 46;
    --mocha-surface0: #313244;
    --mocha-surface1: #45475a;
    --mocha-text: #cdd6f4;
    --mocha-blue: #89b4fa;
    --mocha-pink: #f5c2e7;

    /* Macchiato Theme */
    --macchiato-base: #24273a;
    --macchiato-base-rgb: 36, 39, 58;
    --macchiato-surface0: #363a4f;
    --macchiato-surface1: #494d64;
    --macchiato-text: #cad3f5;
    --macchiato-blue: #8aadf4;
    --macchiato-pink: #f5bde6;

    /* Frappe Theme */
    --frappe-base: #303446;
    --frappe-base-rgb: 48, 52, 70;
    --frappe-surface0: #414559;
    --frappe-surface1: #51576d;
    --frappe-text: #c6d0f5;
    --frappe-blue: #8caaee;
    --frappe-pink: #f4b8e4;

    /* Latte Theme */
    --latte-base: #eff1f5;
    --latte-base-rgb: 239, 241, 245;
    --latte-surface0: #ccd0da;
    --latte-surface1: #bcc0cc;
    --latte-text: #4c4f69;
    --latte-blue: #1e66f5;
    --latte-pink: #ea76cb;

    /* Femboy Pink Theme */
    --femboy-pink-base: #ffeef5;
    --femboy-pink-base-rgb: 255, 238, 245;
    --femboy-pink-surface0: #ffccd5;
    --femboy-pink-surface1: #ffb3c1;
    --femboy-pink-text: #8b4668;
    --femboy-pink-blue: #7c6ee8;
    --femboy-pink-pink: #ff6eb1;

    /* Default theme (Mocha) */
    --base: var(--mocha-base);
    --base-rgb: var(--mocha-base-rgb);
    --surface0: var(--mocha-surface0);
    --surface1: var(--mocha-surface1);
    --text: var(--mocha-text);
    --blue: var(--mocha-blue);
    --pink: var(--mocha-pink);
}

@font-face {
    font-family: 'MapleMono';
    src: url('fonts/maplemono.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background-color: var(--base);
    font-family: var(--font-family, 'Arial, sans-serif');
    color: var(--text);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    overflow: hidden; /* Prevent body scrolling */
}

/* Enhanced Container Styles */
.container {
    max-width: 900px;
    margin: 2rem auto;
    padding: 2.5rem;
    background-color: rgba(var(--base-rgb), var(--container-opacity, 0.85));
    border-radius: 24px;
    backdrop-filter: var(--container-blur, blur(12px));
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    max-height: calc(100vh - 8rem); /* Account for margins */
    overflow-y: auto; /* Change from hidden to auto */
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: var(--surface1) transparent; /* Firefox */
}

/* Improved Search Box */
.search-box {
    margin: 2.5rem auto;
    max-width: 600px;
}

#search-input {
    width: 100%;
    padding: 1.2rem 1.5rem;
    border-radius: 12px;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#search-input:focus {
    box-shadow: 0 4px 16px rgba(var(--base-rgb), 0.2),
                0 0 0 3px var(--blue);
    transform: translateY(-1px);
}

.links-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
}

/* Enhanced Category Cards */
.category {
    background-color: var(--surface0);
    padding: 1.8rem;
    border-radius: 16px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

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

.category h2 {
    font-size: 1.3rem;
    margin-bottom: 1.2rem;
    padding-bottom: 0.8rem;
    border-bottom: 2px solid var(--surface1);
}

.category ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.category li {
    margin-bottom: 0.5rem;
}

/* Main startpage links only */
.container .links-container .category li a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text);
    text-decoration: none;
    transition: all 0.2s;
    font-size: var(--link-size, 16px);
    line-height: 1.5;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.container .links-container .category li a:hover {
    background-color: var(--surface1);
    transform: translateX(4px);
    color: var(--pink);
}

.container .links-container .category li a i,
.container .links-container .category li a img {
    width: var(--link-size, 16px);
    height: var(--link-size, 16px);
    min-width: var(--link-size, 16px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--link-size, 16px);
}

/* Default link styles for all other links */
a:not(.container .links-container .category li a) {
    color: var(--text);
    text-decoration: none;
    transition: color 0.2s;
    font-size: inherit;
}

a:not(.container .links-container .category li a):hover {
    color: var(--pink);
}

.category a {
    color: var(--text);
    text-decoration: none;
    transition: color 0.2s;
}

.category a:hover {
    color: var(--pink);
}

/* Clock Section Enhancement */
.clock-section {
    text-align: center;
    margin: 1rem 0 3rem;
}

.clock {
    font-size: 4rem;
    font-weight: 300;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin: 0;
    color: var(--pink);
    font-family: var(--font-mono, 'MapelMono, monospace');
}

#greeting {
    font-size: 1.4rem;
    font-weight: 500;
    margin-bottom: 0.8rem;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    color: var(--blue);
}

.image-controls {
    text-align: center;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--surface0);
}

.image-button {
    background-color: var(--surface0);
    color: var(--text);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    margin: 0 0.5rem;
    transition: background-color 0.2s;
}

.image-button:hover {
    background-color: var(--surface1);
}

/* Settings Button Animation */
.settings-button {
    position: fixed;
    top: 1rem;
    right: 1rem;
    backdrop-filter: blur(8px);
    background-color: rgba(var(--base-rgb), 0.8);
    color: var(--text);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s, background-color 0.2s;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.settings-button:hover {
    background-color: var(--surface1);
    transform: rotate(90deg) scale(1.1);
}

/* Settings Modal Improvements */
.settings-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    backdrop-filter: blur(5px);
}

.settings-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: var(--base);
    padding: 2.5rem;
    border-radius: 20px;
    min-width: 300px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
    scrollbar-width: thin;
    scrollbar-color: var(--surface1) transparent;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.3);
}

.settings-content::-webkit-scrollbar {
    width: 8px;
}

.settings-content::-webkit-scrollbar-track {
    background: transparent;
}

.settings-content::-webkit-scrollbar-thumb {
    background-color: var(--surface1);
    border-radius: 4px;
}

.settings-content::-webkit-scrollbar-thumb:hover {
    background-color: var(--surface0);
}

/* Enhanced Settings Section */
.settings-section {
    margin: 1.5rem 0;
    padding: 1.5rem;
    background-color: var(--surface0);
    border-radius: 12px;
    transition: all 0.2s ease;
}

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

.settings-section h4 {
    margin: 0 0 1rem 0;
    color: var(--blue);
}

/* Better Button Styles */
.settings-btn {
    background-color: var(--surface1);
    color: var(--text);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
    margin: 0.5rem 0;
    width: 100%;
    transition: all 0.2s ease;
    font-weight: 500;
}

.settings-btn:hover {
    background-color: #585b70;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    background-color: var(--blue);
}

#bgImage {
    display: block;
    margin: 1rem 0;
    width: 100%;
    color: var(--text);
}

.show {
    display: block !important;
}

/* New styles for preset backgrounds */
.preset-backgrounds {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.8rem;
    margin: 1rem 0;
}

.preset-bg-option {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 4px;
    cursor: pointer;
    background-size: cover;
    background-position: center;
    border: 2px solid var(--surface1);
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.preset-bg-option:hover {
    border-color: var(--pink);
    transform: translateY(-2px);
}

.preset-bg-option.active {
    border-color: var(--blue);
    box-shadow: 0 0 0 2px var(--blue);
}

.preset-bg-option.none {
    background: var(--surface0);
    position: relative;
}

.preset-bg-option.none::after {
    content: '✕';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    color: var(--text);
    opacity: 0.5;
}

/* New styles for name input */
.settings-input {
    width: calc(100% - 1rem); /* Account for padding */
    padding: 0.5rem;
    margin: 0.5rem 0;
    border: none;
    border-radius: 4px;
    background-color: var(--surface0);
    color: var(--text);
    font-size: 1rem;
    box-sizing: border-box;
    transition: all 0.2s;
}

.settings-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--blue);
    background-color: var(--surface1);
}

.settings-input::placeholder {
    color: var(--text);
    opacity: 0.5;
}

/* Link Management Styles */
.link-item, .category-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--surface1);
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.link-item input, .category-item input {
    flex: 1;
}

/* Search Engines Styles */
.search-engine {
    display: grid;
    grid-template-columns: 1fr 2fr auto auto;
    gap: 0.5rem;
    align-items: center;
    background: var(--surface0);
    padding: 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.search-engine input[type="text"] {
    background: var(--surface1);
    border: none;
    padding: 0.5rem;
    border-radius: 4px;
    color: var(--text);
}

/* Keyboard Shortcuts */
.shortcut-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

/* CSS Editor */
.css-editor {
    margin-top: 1rem;
}

.code {
    font-family: var(--font-mono, 'MapelMono, monospace');
    white-space: pre;
    resize: vertical;
    min-height: 100px;
}

/* Layout Variations */
[data-layout="list"] .links-container {
    display: block;
}

[data-layout="list"] .category {
    margin-bottom: 1rem;
}

/* Additional styles for the links editor */
.category-item {
    margin-bottom: 1rem;
}

.category-item h5 {
    margin: 0 0 0.5rem 0;
    color: var(--blue);
}

.category-links {
    margin-left: 1rem;
}

.settings-btn.small {
    width: auto;
    padding: 0.25rem 0.5rem;
    margin: 0 0.25rem;
}

.link-item {
    display: grid;
    grid-template-columns: 24px 1fr 2fr 24px;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

.link-item input {
    background: var(--surface0);
    border: none;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    color: var(--text);
}

/* New styles for icon picker */
.icon-select {
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.icon-select:hover {
    background-color: var(--surface1);
}

.icon-picker-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.icon-picker-content {
    background: var(--surface0);
    padding: 20px;
    border-radius: 8px;
    max-width: 80%;
    max-height: 80vh;
    overflow-y: auto;
}

.icon-picker-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.icon-picker-tabs button {
    background-color: var(--surface0);
    color: var(--text);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
}

.icon-picker-tabs button.active {
    background-color: var(--blue);
}

.brand-icons,
.solid-icons {
    display: grid;
    grid-template-rows: repeat(10, 1fr);
    grid-auto-flow: column;
    grid-auto-columns: 80px;
    gap: 1rem;
    padding: 1rem;
    overflow-x: auto;
    max-height: 400px;
    align-items: start;
}

.brand-icons i,
.solid-icons i {
    font-size: 1.5rem;
    padding: 1rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--surface0);
    transition: all 0.2s;
    aspect-ratio: 1;
}

/* Custom icon upload */
.custom-icons-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--surface1);
}

.custom-icons-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
    min-height: 150px;  /* Increased height */
    background: var(--surface0);
    padding: 1.5rem;    /* Increased padding */
    border-radius: 8px;
}

.custom-icon {
    width: 40px;
    height: 40px;
    object-fit: contain;
    background: var(--surface0);
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
}

.custom-icon:hover {
    background: var(--surface1);
}

/* Icon Picker Styles */
.icon-picker-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.icon-picker-content {
    background: var(--base);
    padding: 2rem;
    border-radius: 12px;
    max-width: 800px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.icon-picker-header {
    position: sticky;
    top: 0;
    background: var(--base);
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--surface0);
    z-index: 2;
}

.icon-picker-header h3 {
    margin: 0 0 1rem 0;
    color: var(--blue);
}

.icon-picker-tabs {
    display: flex;
    gap: 0.5rem;
}

.icon-picker-tabs button {
    padding: 0.5rem 1rem;
    background: var(--surface0);
    border: none;
    border-radius: 4px;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
}

.icon-picker-tabs button.active {
    background: var(--blue);
}

.icon-sections {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.icon-section {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 1rem;
    padding: 1rem;
}

.icon-item {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.75rem;
    background: var(--surface0);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    aspect-ratio: 1;
}

.icon-item:hover {
    background: var(--surface1);
    transform: translateY(-2px);
}

.icon-item i {
    font-size: 1.5rem;
    text-align: center;
}

/* Custom icons section */
.custom-section {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.custom-icons-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
    padding: 2rem;
    background: var(--surface0);
    border-radius: 8px;
    min-height: 200px;
}

.custom-icons-grid:empty::before {
    content: 'No custom icons yet';
    color: var(--text);
    opacity: 0.5;
    grid-column: 1 / -1;
    text-align: center;
    font-size: 1.1rem;
}

.custom-icon-item {
    position: relative;
    aspect-ratio: 1;
    background: var(--surface1);
    border-radius: 8px;
    transition: all 0.2s;
    cursor: pointer;
}

.custom-icon-item img {
    width: 60%;
    height: 60%;
    object-fit: contain;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.custom-icon-item:hover {
    transform: translateY(-2px);
    background: var(--surface0);
}

.delete-icon {
    position: absolute;
    top: -0.5rem;
    right: -0.5rem;
    background: var(--surface1);
    color: var(--text);
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 14px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.custom-icon-item:hover .delete-icon {
    display: flex;
}

.delete-icon:hover {
    background: #f87171;
    color: white;
}

.upload-icon-btn {
    width: auto;
    margin: 0 auto;
    padding: 0.75rem 2rem;
    font-size: 1rem;
}

/* Icon select button in link items */
.icon-select {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface0);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.icon-select:hover {
    background: var(--surface1);
    color: var(--blue);
    transform: scale(1.1);
}

/* Scrollbar styles for icon picker */
.icon-picker-content::-webkit-scrollbar {
    width: 8px;
}

.icon-picker-content::-webkit-scrollbar-track {
    background: var(--surface0);
    border-radius: 4px;
}

.icon-picker-content::-webkit-scrollbar-thumb {
    background: var(--surface1);
    border-radius: 4px;
}

.icon-picker-content::-webkit-scrollbar-thumb:hover {
    background: var(--blue);
}

/* Disable settings button */
.settings-button.disabled {
    pointer-events: none;
    opacity: 0.6;
}

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

.custom-icons-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
    min-height: 150px;
    background: var(--surface0);
    padding: 1.5rem;
    border-radius: 8px;
}

.custom-icon-item {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    background: var(--surface1);
    border-radius: 8px;
    padding: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-icon-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: all 0.2s;
}

.custom-icon-item:hover {
    transform: translateY(-2px);
    background: var(--surface0);
}

/* Smooth Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--surface1);
    border-radius: 5px;
    border: 3px solid var(--base);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--blue);
}

/* Toggle Switch Styles - Updated */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 100px; /* Reduced from 44px */
    height: 20px; /* Reduced from 24px */
    margin: 0 4px; /* Reduced from 8px */
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-switch label {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--surface0);
    transition: .3s;
    border-radius: 20px;
}

.toggle-switch label:before {
    position: absolute;
    content: "";
    height: 14px; /* Reduced from 16px */
    width: 14px; /* Reduced from 16px */
    left: 3px; /* Adjusted from 4px */
    bottom: 3px; /* Adjusted from 4px */
    background-color: var(--text);
    transition: .3s;
    border-radius: 50%;
}

.toggle-switch input:checked + label {
    background-color: var(--blue);
}

.toggle-switch input:checked + label:before {
    transform: translateX(16px); /* Adjusted from 20px */
}

/* Blur and Transparency Controls */
.setting-group {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 0.8rem;
    border-radius: 8px;
    background: var(--surface1);
}

.setting-group label {
    min-width: 100px;
    font-weight: 500;
}

/* Blur Controls - Updated */
.blur-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    margin-left: 0.25rem; /* Added small margin */
}

.blur-controls input[type="range"] {
    flex: 1;
}

.blur-controls span {
    min-width: 45px;
    text-align: right;
}

.toggle-switch {
    min-width: 44px;
    margin: 0;
}

.setting-group input[type="range"] {
    flex: 1;
}

.setting-group span {
    min-width: 50px;
    text-align: right;
}

.setting-group input[type="range"]:disabled {
    cursor: not-allowed;
}
