* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', sans-serif;
    background: #0d0d0d;
    color: #fff;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    transition: background 0.3s, color 0.3s;
}

body.light {
    background: #f0f0f0;
    color: #333;
}

#particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(20, 20, 40, 0.8), rgba(0, 0, 0, 1));
    z-index: -1;
}

body.light #particles {
    background: radial-gradient(circle, rgba(200, 200, 220, 0.8), rgba(240, 240, 240, 1));
}

.container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background: rgba(20, 20, 20, 0.95);
    padding: 40px 20px 20px;
    transition: transform 0.3s ease, box-shadow 0.3s;
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    z-index: 10;
}

body.light .sidebar {
    background: rgba(255, 255, 255, 0.95);
}

.sidebar:hover {
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.5);
}

.sidebar.hidden {
    transform: translateX(-100%);
}

.sidebar h1 {
    font-size: 28px;
    margin-bottom: 10px;
    color: #00d4ff;
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
    position: relative;
    top: 0;
    left: 0;
}

.sidebar .clock, .sidebar .weather {
    font-size: 14px;
    color: #ccc;
    margin-bottom: 10px;
    display: block;
}

.sidebar-section {
    margin: 20px 0;
}

.sidebar-section h2 {
    font-size: 18px;
    color: #00d4ff;
    margin-bottom: 10px;
}

#cardSearch {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 14px;
    transition: box-shadow 0.3s;
}

#cardSearch:focus {
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
    outline: none;
}

body.light #cardSearch {
    background: rgba(0, 0, 0, 0.1);
    color: #333;
}

/* Sidebar Inputs */
.sidebar-section label {
    display: block;
    color: #ccc;
    font-size: 14px;
    margin-bottom: 5px;
}

body.light .sidebar-section label {
    color: #666;
}

#gridColumns, #gridRows, #cardSize, #webSearchToggle, #webSearchEngine {
    width: 100%;
    padding: 6px;
    border: none;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 12px;
    transition: box-shadow 0.3s, background 0.3s;
}

#gridColumns:focus, #gridRows:focus, #cardSize:focus, #webSearchEngine:focus {
    box-shadow: 0 0 8px rgba(0, 212, 255, 0.5);
    outline: none;
}

body.light #gridColumns, body.light #gridRows, body.light #cardSize, 
body.light #webSearchToggle, body.light #webSearchEngine {
    background: rgba(0, 0, 0, 0.1);
    color: #333;
}

#webSearchToggle {
    width: auto;
    margin-right: 10px;
}

/* Updated #webSearchEngine Styles */
#webSearchEngine {
    background: #333; /* Dark grey background */
    color: #ddd; /* Light grey text */
    appearance: none; /* Remove default arrow */
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg fill="%23ddd" height="10" width="10" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M5 7l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 25px; /* Space for arrow */
}

#webSearchEngine option {
    background: #333; /* Dark grey for options */
    color: #ddd; /* Light grey text */
}

#webSearchEngine:hover {
    background: #444; /* Slightly lighter grey on hover */
}

body.light #webSearchEngine {
    background: #ccc; /* Light grey in light mode */
    color: #333; /* Dark text */
    background-image: url('data:image/svg+xml;utf8,<svg fill="%23333" height="10" width="10" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M5 7l5 5 5-5z"/></svg>');
}

body.light #webSearchEngine option {
    background: #ccc;
    color: #333;
}

body.light #webSearchEngine:hover {
    background: #bbb; /* Slightly darker grey on hover */
}

.sidebar-settings button {
    color: #ccc;
    text-decoration: none;
    font-size: 16px;
    background: none;
    border: none;
    cursor: pointer;
    transition: color 0.3s;
    padding: 5px 10px;
    display: block;
    width: 100%;
    text-align: left;
}

body.light .sidebar-settings button {
    color: #666;
}

.sidebar-settings button:hover {
    color: #00d4ff;
}

/* Toggle Button */
.toggle-btn {
    position: fixed;
    top: 10px;
    left: 260px;
    z-index: 20;
    background: #00d4ff;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    color: #000;
    font-size: 18px;
    transition: left 0.3s;
}

.toggle-btn.hidden {
    left: 10px;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 80px 40px 40px;
    margin-left: 250px;
    transition: margin-left 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.main-content.full {
    margin-left: 0;
}

.greeting {
    font-size: 48px;
    text-align: center;
    margin-bottom: 20px;
    color: #00d4ff;
    text-shadow: 0 0 15px rgba(0, 212, 255, 0.7);
    animation: fadeIn 1s ease-in-out;
}

@keyframes fadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

/* Web Search Form */
#webSearchForm {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

#webSearchInput {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 16px;
    transition: box-shadow 0.3s;
}

#webSearchInput:focus {
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
    outline: none;
}

body.light #webSearchInput {
    background: rgba(0, 0, 0, 0.1);
    color: #333;
}

#webSearchForm button {
    padding: 10px 20px;
    background: #00d4ff;
    border: none;
    border-radius: 5px;
    color: #000;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

#webSearchForm button:hover {
    background: #00b8d4;
}

.card-grid {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 20px;
    display: grid;
    gap: 5px;
    justify-content: center;
    align-content: start;
}

.card {
    background: transparent;
    text-align: center;
    text-decoration: none;
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    width: var(--card-width, 100px);
    height: var(--card-height, 130px);
    overflow: hidden;
}

.card:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.7);
    background: rgba(0, 212, 255, 0.1);
}

.card img {
    width: var(--card-width, 100px);
    height: calc(var(--card-height, 130px) - 30px);
    object-fit: cover;
    border-radius: 5px;
}

.card h3 {
    font-size: calc(var(--card-width, 100px) / 10);
    color: #00d4ff;
    margin-top: 5px;
    word-wrap: break-word;
    max-width: 100%;
}

.card .tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    padding: 5px 10px;
    border-radius: 5px;
    font-size: calc(var(--card-width, 100px) / 12);
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s;
    top: calc(-40px + (var(--card-height, 130px) / -10));
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
}

body.light .card .tooltip {
    background: rgba(255, 255, 255, 0.8);
    color: #333;
}

.card:hover .tooltip {
    visibility: visible;
    opacity: 1;
}

/* Edit and Delete Buttons */
.card .edit-btn,
.card .delete-btn {
    position: absolute;
    top: 2px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: calc(var(--card-width, 100px) / 10);
    color: #fff;
    transition: color 0.3s;
    padding: 0 2px;
    visibility: hidden;
}

body.edit-mode .card .edit-btn,
body.edit-mode .card .delete-btn {
    visibility: visible;
}

.card .edit-btn:hover,
.card .delete-btn:hover {
    color: #ffdd00;
}

.card .edit-btn {
    right: calc(var(--card-width, 100px) / 6);
}

.card .delete-btn {
    right: 2px;
}

/* Add Card Form */
#add-card-form {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

#add-card-form input {
    padding: 6px;
    border: none;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 12px;
    transition: box-shadow 0.3s;
}

#add-card-form input:focus {
    box-shadow: 0 0 8px rgba(0, 212, 255, 0.5);
    outline: none;
}

body.light #add-card-form input {
    background: rgba(0, 0, 0, 0.1);
    color: #333;
}

#add-card-form button {
    padding: 6px;
    background: #00d4ff;
    border: none;
    border-radius: 4px;
    color: #000;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.3s;
}

#add-card-form button:hover {
    background: #00b8d4;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 50;
}

.modal-content {
    background: rgba(20, 20, 20, 0.95);
    padding: 20px;
    border-radius: 5px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
}

body.light .modal-content {
    background: rgba(255, 255, 255, 0.95);
}

.modal-content input, .modal-content button {
    width: 100%;
    margin: 5px 0;
    padding: 6px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
}

.modal-content input {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

body.light .modal-content input {
    background: rgba(0, 0, 0, 0.1);
    color: #333;
}

.modal-content button[type="submit"] {
    background: #00d4ff;
    color: #000;
}

.modal-content button[type="button"] {
    background: #ccc;
    color: #000;
}

/* Undo Toast */
.undo-toast {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 20, 20, 0.95);
    padding: 10px 20px;
    border-radius: 5px;
    color: #fff;
    z-index: 40;
}

body.light .undo-toast {
    background: rgba(255, 255, 255, 0.95);
    color: #333;
}

.undo-toast button {
    background: #00d4ff;
    border: none;
    padding: 5px 10px;
    margin-left: 10px;
    border-radius: 4px;
    color: #000;
    cursor: pointer;
}

/* Context Menu */
.context-menu {
    display: none;
    position: absolute;
    background: rgba(30, 30, 30, 0.95);
    border-radius: 5px;
    z-index: 60;
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

body.light .context-menu {
    background: rgba(255, 255, 255, 0.95);
}

.context-menu ul {
    list-style: none;
    padding: 10px;
}

.context-menu li {
    padding: 5px 10px;
    cursor: pointer;
    color: #ccc;
}

body.light .context-menu li {
    color: #666;
}

.context-menu li:hover {
    color: #00d4ff;
}

/* Back to Top */
.back-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #00d4ff;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    color: #000;
    cursor: pointer;
    display: none;
}

.back-to-top.visible {
    display: block;
}

/* Loading Animation */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0d0d0d;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    transition: opacity 0.5s;
}

body.light .loading {
    background: #f0f0f0;
}

.loading.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #00d4ff;
    border-top: 5px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .card-grid {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
        grid-template-rows: auto;
    }
    .card {
        width: var(--card-width, 80px);
        height: var(--card-height, 110px);
    }
    .card img {
        width: var(--card-width, 80px);
        height: calc(var(--card-height, 110px) - 30px);
    }
    .card h3 {
        font-size: calc(var(--card-width, 80px) / 10);
    }
    .card .edit-btn, .card .delete-btn {
        font-size: calc(var(--card-width, 80px) / 10);
    }
    #webSearchForm {
        max-width: 500px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 200px;
    }
    .main-content {
        margin-left: 0;
        padding: 60px 20px 20px;
    }
    .toggle-btn {
        left: 210px;
    }
    .toggle-btn.hidden {
        left: 10px;
    }
    .greeting {
        font-size: 32px;
    }
    #webSearchForm {
        flex-direction: column;
        gap: 5px;
    }
    #webSearchInput {
        width: 100%;
    }
    #webSearchForm button {
        width: 100%;
    }
}