:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-surface: #ffffff;
    --text-primary: #202124;
    --text-secondary: #5f6368;
    --border-color: #dadce0;
    --hover-bg: #f1f3f4;
    --shadow: 0 1px 6px rgba(32, 33, 36, 0.28);
    --shadow-hover: 0 2px 8px rgba(32, 33, 36, 0.35);
    --active-bg: #e8f0fe;
    --active-text: #1a73e8;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #202124;
        --bg-secondary: #303134;
        --bg-surface: #303134;
        --text-primary: #e8eaed;
        --text-secondary: #9aa0a6;
        --border-color: #5f6368;
        --hover-bg: #3c4043;
        --shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
        --shadow-hover: 0 2px 8px rgba(0, 0, 0, 0.6);
        --active-bg: #1a73e8;
        --active-text: #8ab4f8;
    }
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 15px 20px;
    gap: 15px;
}

header a {
    color: var(--text-primary);
    text-decoration: none;
    font-size: 13px;
    padding: 5px 10px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

header a.apps-link:hover {
    text-decoration: underline;
}

.apps-button {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    color: var(--text-primary);
}

.apps-button:hover {
    background-color: var(--hover-bg);
}

.apps-grid-icon {
    width: 24px;
    height: 24px;
    display: block;
}

/* Apps Panel */
.apps-panel {
    position: absolute;
    top: 60px;
    right: 20px;
    width: 320px;
    max-height: 500px;
    background-color: var(--bg-surface);
    border-radius: 8px;
    box-shadow: var(--shadow-hover);
    padding: 10px;
    display: none;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    overflow-y: auto;
    z-index: 1000;
    border: 1px solid var(--border-color);
    /* Custom scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

/* WebKit scrollbar styles */
.apps-panel::-webkit-scrollbar {
    width: 8px;
}

.apps-panel::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 4px;
}

.apps-panel::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.apps-panel::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-secondary);
    background-clip: padding-box;
}

.apps-panel.visible {
    display: grid;
}

.app-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 10px;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    color: var(--text-primary);
    transition: background-color 0.2s;
}

.app-item:hover {
    background-color: var(--hover-bg);
}

.app-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 8px;
    background-repeat: no-repeat;
    background-position: center;
}

.app-label {
    font-size: 12px;
    text-align: center;
}

/* Main Content */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 5vh 20px 40px;
    gap: 30px;
}

.hero-image {
    max-width: 420px;
    width: 100%;
    height: auto;
    margin-bottom: 20px;
}

.hero-image-img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
}

/* Search Container */
.search-container {
    width: 100%;
    max-width: 723px;
    position: relative;
}

.search-box {
    display: flex;
    align-items: center;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 0 16px;
    height:52px;
    transition: box-shadow 0.2s;
}

.search-box:hover {
    box-shadow: var(--shadow);
}

.search-box:focus-within {
    box-shadow: var(--shadow-hover);
    border-color: transparent;
}

/* Remove bottom border-radius when autocomplete is visible */
.search-container:has(.autocomplete-dropdown.visible) .search-box {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-color: var(--border-color);
}

.search-icon {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.search-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 16px;
}

.search-input::placeholder {
    color: var(--text-secondary);
}

.mic-button {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    margin-left: 12px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mic-button:focus {
    outline: 2px solid var(--active-text);
    outline-offset: 2px;
    border-radius: 4px;
}

.mic-icon {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
}

/* Autocomplete Dropdown */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 0 0 24px 24px;
    margin-top: -1px;
    max-height: 400px;
    overflow-y: auto;
    display: none;
    z-index: 100;
    box-shadow: var(--shadow);
    overflow-y: hidden;
}

.autocomplete-dropdown.visible {
    display: block;
    border-top: none;
}

.autocomplete-item {
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    color: var(--text-primary);
    transition: background-color 0.1s;
    position: relative;
}

.autocomplete-item:hover,
.autocomplete-item.active {
    background-color: var(--hover-bg);
}

.autocomplete-item-icon {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.autocomplete-item span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-delete-btn {
    display: flex;
    width: 24px;
    height: 24px;
    padding: 0;
    margin-left: 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: 4px;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    visibility: hidden;
    opacity: 0;
    transition: background-color 0.1s, color 0.1s, opacity 0.1s, visibility 0.1s;
}

.history-delete-btn svg {
    width: 16px;
    height: 16px;
}

.history-delete-btn:hover {
    background-color: var(--hover-bg);
    color: var(--text-primary);
}

.history-item:hover .history-delete-btn {
    visibility: visible;
    opacity: 1;
}

/* Shortcuts */
.shortcuts-container {
    width: 100%;
    max-width: 900px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.shortcut-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    position: relative;
    text-decoration: none;
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: 10px;
}

.shortcut-icon-wrapper {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background-color: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    position: relative;
    transition: transform 0.2s;
}

.shortcut-item:hover {
    /* transform: scale(1.05); */
    background-color: var(--bg-secondary);
}

.shortcut-icon {
    width: auto;
    height: 32px;
    object-fit: cover;
}

.shortcut-icon-fallback {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 32px;
}

.shortcut-label {
    font-size: 13px;
    text-align: center;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.shortcut-menu {
    position: absolute;
    top: 7px;
    right: -4px;
    width: 24px;
    height: 24px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
}

.shortcut-item:hover .shortcut-menu {
    display: block;
}

.shortcut-menu.hidden {
    display: none !important;
}

.shortcut-menu-icon {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
}

.shortcut-context-menu {
    position: absolute;
    background-color: var(--bg-surface);
    border-radius: 8px;
    box-shadow: var(--shadow-hover);
    min-width: 127px;
    z-index: 20;
    display: none;
    box-shadow: var(--shadow);
}

.shortcut-context-menu.visible {
    display: block;
}

.shortcut-context-menu-item {
    padding: 14px 16px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 14px;
    text-align: center;
    transition: background-color 0.1s;
}

.shortcut-context-menu-item:first-child {
    border-radius: 8px 8px 0 0;
}

.shortcut-context-menu-item:hover {
    background-color: var(--hover-bg);
}

.shortcut-context-menu-item:last-child {
    border-radius: 0 0 8px 8px;
}

.shortcut-context-menu-item:last-child:hover {
    background-color: var(--hover-bg);
}

.shortcut-context-menu-divider {
    height: 1px;
    background-color: var(--border-color);
}

.add-shortcut {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
    color: var(--text-secondary);
    font-size: 24px;
    line-height: 25px;
    margin: 10px;
}

.add-shortcut:hover {
    background-color: var(--hover-bg);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-overlay.visible {
    display: flex;
}

.modal {
    background-color: var(--bg-surface);
    border-radius: 8px;
    padding: 24px;
    width: 90%;
    max-width: 400px;
    box-shadow: var(--shadow-hover);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-title {
    font-size: 18px;
    font-weight: 500;
}

.modal-close {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:focus {
    outline: 2px solid var(--active-text);
    outline-offset: 2px;
    border-radius: 4px;
}

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-primary);
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
}

.form-input:focus {
    outline: 2px solid var(--active-text);
    outline-offset: 0;
    border-color: transparent;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.btn {
    padding: 10px 24px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.btn-primary {
    background-color: #8ab4f8;
    color: #202124;
    font-weight: 500;
}

.btn-primary:hover:not(:disabled) {
    background-color: #aecbfa;
}

.btn-primary:disabled {
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-secondary {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--active-text);
}

.btn-secondary:hover {
    background-color: var(--hover-bg);
}

.btn-danger {
    background-color: #ea4335;
    color: white;
}

.btn-danger:hover {
    background-color: #d33b2c;
}

/* Voice Overlay */
.voice-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.voice-overlay.visible {
    display: flex;
}

.voice-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 80px;
    color: #ffffff;
}

.voice-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: #ffffff;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.voice-close:hover {
    opacity: 0.8;
}

.voice-close:focus {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
    border-radius: 4px;
}

.voice-mic-icon {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.voice-mic-icon svg {
    width: 60px;
    height: 60px;
    color: #ffffff;
}

.voice-text {
    font-size: 24px;
    color: #ffffff;
    font-weight: 400;
}

.voice-text a {
    color: #8ab4f8;
    text-decoration: underline;
    cursor: pointer;
}

.voice-text a:hover {
    opacity: 0.8;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--bg-surface);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: 4px;
    box-shadow: var(--shadow-hover);
    display: none;
    z-index: 4000;
}

.toast.visible {
    display: block;
}

/* Responsive */
@media (max-width: 768px) {
    .hero-image {
        max-width: 200px;
    }

    .search-container {
        max-width: 100%;
    }

    .shortcuts-container {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 15px;
    }

    .shortcut-icon-wrapper {
        width: 56px;
        height: 56px;
    }

    .apps-panel {
        right: 10px;
        width: calc(100% - 20px);
        max-width: 320px;
    }

    header {
        padding: 10px 15px;
    }
}
