/* 這個檔案負責 tool clipboard 的版面與互動樣式 */

:root {
    --app-max-width: 1680px;
    --app-radius: 0.9rem;
    --app-touch-size: 44px;
    --app-editor-min-height: 340px;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    background: var(--bs-tertiary-bg);
}

.app-container {
    max-width: var(--app-max-width);
    margin-inline: auto;
}

.app-navbar {
    backdrop-filter: blur(12px);
    background-color: color-mix(in srgb, var(--bs-body-bg) 92%, transparent) !important;
}

.brand-icon {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    color: var(--bs-primary);
    background: color-mix(in srgb, var(--bs-primary) 12%, transparent);
}

.navbar-brand small {
    font-size: 0.72rem;
    line-height: 1.1;
}

.btn-icon {
    width: var(--app-touch-size);
    height: var(--app-touch-size);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.language-button {
    min-height: var(--app-touch-size);
}

.language-menu {
    min-width: 230px;
}

.language-menu .dropdown-item {
    min-height: var(--app-touch-size);
    display: flex;
    align-items: center;
}

.context-tip {
    border-radius: var(--app-radius);
}

.quick-action-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.6rem;
}

.quick-action-grid .btn {
    min-height: var(--app-touch-size);
}

.card {
    border-radius: var(--app-radius);
    overflow: hidden;
}

.editor-card .card-body {
    min-height: 430px;
}

.editor-textarea {
    min-height: var(--app-editor-min-height);
    resize: vertical;
    line-height: 1.6;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.96rem;
    border-radius: 0.75rem;
}

.editor-textarea:focus {
    box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--bs-primary) 20%, transparent);
}

.result-card .editor-textarea:focus {
    box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--bs-success) 20%, transparent);
}

.editor-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.2rem;
}

.transform-tabs {
    gap: 0.4rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 0.2rem;
    scrollbar-width: thin;
}

.transform-tabs .nav-link {
    white-space: nowrap;
    min-height: var(--app-touch-size);
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
}

.tool-button {
    appearance: none;
    border: 1px solid var(--bs-border-color);
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    border-radius: 0.8rem;
    padding: 0.85rem;
    min-height: 92px;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    text-align: left;
    transition: transform 120ms ease, border-color 120ms ease, background-color 120ms ease, box-shadow 120ms ease;
}

.tool-button:hover,
.tool-button:focus-visible {
    border-color: var(--bs-primary);
    background: color-mix(in srgb, var(--bs-primary) 6%, var(--bs-body-bg));
    box-shadow: 0 0.35rem 1rem rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
    outline: none;
}

.tool-button strong,
.tool-button small {
    display: block;
}

.tool-button strong {
    line-height: 1.3;
    margin-bottom: 0.25rem;
}

.tool-button small {
    color: var(--bs-secondary-color);
    line-height: 1.35;
}

.tool-icon,
.tool-fa {
    flex: 0 0 52px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.7rem;
    background: var(--bs-tertiary-bg);
    color: var(--bs-primary);
    font-weight: 700;
    font-style: normal;
}

.tool-fa {
    font-size: 1.2rem;
}

.shortcut-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem 1.5rem;
}

.shortcut-grid > div {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.shortcut-grid > div > span:last-child {
    margin-left: 0.35rem;
}

.tech-card {
    border-style: dashed;
}

.custom-context-menu {
    position: fixed;
    z-index: 1090;
    width: min(360px, calc(100vw - 24px));
    max-height: min(680px, calc(100vh - 24px));
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.85rem;
    display: none;
    overflow: hidden;
}

.custom-context-menu.is-open {
    display: block;
}

.context-menu-header {
    min-height: 44px;
    padding: 0.65rem 0.8rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--bs-border-color);
    background: var(--bs-tertiary-bg);
}

.context-menu-scroll {
    overflow-y: auto;
    max-height: calc(min(680px, calc(100vh - 24px)) - 45px);
    padding: 0.45rem;
}

.context-action {
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--bs-body-color);
    min-height: 42px;
    border-radius: 0.55rem;
    display: grid;
    grid-template-columns: 34px 1fr;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.55rem;
    text-align: left;
}

.context-action:hover,
.context-action:focus-visible {
    background: var(--bs-tertiary-bg);
    outline: none;
}

.context-action > i,
.context-action > .mini-code {
    width: 30px;
    text-align: center;
    color: var(--bs-primary);
}

.mini-code {
    font-size: 0.78rem;
    font-weight: 700;
}

.context-divider {
    height: 1px;
    background: var(--bs-border-color);
    margin: 0.4rem 0;
}

.context-section-title {
    padding: 0.35rem 0.55rem 0.2rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--bs-secondary-color);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.context-native-hint {
    padding: 0.4rem 0.55rem 0.2rem;
}

.toast-container {
    z-index: 1100;
}

@media (max-width: 1199.98px) {
    .tool-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 991.98px) {
    :root {
        --app-editor-min-height: 300px;
    }

    .quick-action-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .tool-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .shortcut-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 575.98px) {
    :root {
        --app-editor-min-height: 260px;
    }

    .app-container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .navbar-brand small {
        display: none !important;
    }

    .language-button {
        max-width: 170px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .quick-action-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .quick-action-grid .btn:first-child {
        grid-column: span 2;
    }

    .editor-card .card-body {
        min-height: 340px;
        padding: 0.75rem;
    }

    .editor-card .card-header {
        align-items: flex-start !important;
    }

    .tool-grid {
        grid-template-columns: 1fr;
    }

    .tool-button {
        min-height: 78px;
    }

    .context-tip {
        font-size: 0.9rem;
    }

    footer .btn {
        min-height: var(--app-touch-size);
    }
}

@media (hover: none) and (pointer: coarse) {
    .custom-context-menu {
        display: none !important;
    }
}
