/* =========================================================
   Tutorial Studio
   Text Color Panel
========================================================= */

.text-color-panel {
    position: fixed;
    z-index: 10050;

    width: min(320px, calc(100vw - 24px));
    max-height: min(600px, calc(100vh - 24px));

    display: flex;
    flex-direction: column;

    overflow: hidden;

    color: #202938;
    background: #FFFFFF;

    border: 1px solid #DCE3EC;
    border-radius: 12px;

    box-shadow:
        0 12px 32px rgba(22, 34, 51, 0.14),
        0 3px 8px rgba(22, 34, 51, 0.05);

    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        "PingFang SC",
        "Microsoft YaHei",
        sans-serif;

    font-size: 12px;
    line-height: 1.4;

    opacity: 1;
    visibility: visible;

    transform: translateY(0);

    transition:
        opacity 140ms ease,
        transform 140ms ease,
        box-shadow 140ms ease;
}

.text-color-panel[hidden] {
    display: none !important;
}

.text-color-panel *,
.text-color-panel *::before,
.text-color-panel *::after {
    box-sizing: border-box;
}


/* =========================================================
   Header
========================================================= */

.tcp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;

    flex: 0 0 auto;

    min-height: 36px;
    padding: 4px 8px;

    border-bottom: 1px solid #E9EDF3;
    background: #FFFFFF;
}

.tcp-heading {
    display: flex;
    align-items: center;
    gap: 8px;

    flex: 1 1 auto;
    min-width: 0;
}

.tcp-heading-icon {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 28px;
    height: 28px;

    flex: 0 0 auto;

    color: #2563EB;
    background: #EFF6FF;

    border: 1px solid #DBEAFE;
    border-radius: 8px;

    font-size: 18px;
    line-height: 1;
}

.tcp-heading-text {
    display: flex;
    flex-direction: column;
    gap: 2px;

    min-width: 0;
}

.tcp-title {
    color: #172033;

    font-size: 13px;
    font-weight: 700;
    line-height: 1.4;
}

.tcp-subtitle {
    color: #64748B;

    font-size: 10px;
    line-height: 1.3;
}

.tcp-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 28px;
    height: 28px;

    flex: 0 0 auto;

    padding: 0;

    color: #64748B;
    background: transparent;

    border: 1px solid transparent;
    border-radius: 7px;

    font-size: 21px;
    line-height: 1;

    cursor: pointer;

    transition:
        color 140ms ease,
        background 140ms ease,
        border-color 140ms ease;
}

.tcp-icon-button:hover {
    color: #1F2937;
    background: #F1F5F9;
    border-color: #E2E8F0;
}


/* =========================================================
   Body
========================================================= */

.tcp-body {
    min-height: 0;

    overflow-x: hidden;
    overflow-y: auto;

    padding: 10px 12px;

    overscroll-behavior: contain;

    scrollbar-width: thin;
    scrollbar-color: #CBD5E1 transparent;
}

.tcp-body::-webkit-scrollbar {
    width: 5px;
}

.tcp-body::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 99px;
}

.tcp-section {
    min-width: 0;
    margin-top: 12px;
}

.tcp-section:first-child {
    margin-top: 0;
}

.tcp-section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;

    margin-bottom: 6px;

    color: #344054;

    font-size: 11px;
    font-weight: 650;
}

.tcp-current-value {
    color: #64748B;

    font-family:
        "SFMono-Regular",
        Consolas,
        monospace;

    font-size: 11px;
    font-weight: 500;
}


/* =========================================================
   Current Color Preview
========================================================= */

.tcp-current-preview {
    display: flex;
    align-items: center;
    gap: 8px;

    width: 100%;
    min-width: 0;
    min-height: 36px;

    padding: 5px 8px;

    background: #F8FAFC;

    border: 1px solid #E5EAF1;
    border-radius: 8px;
}

.tcp-preview-swatch {
    display: block;

    width: 24px;
    height: 24px;

    flex: 0 0 24px;

    background-color: #000000;

    border: 1px solid rgba(15, 23, 42, 0.16);
    border-radius: 6px;

    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.tcp-preview-info {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;

    flex: 1 1 auto;
    min-width: 0;
}

.tcp-preview-info strong {
    color: #263244;

    font-size: 11px;
    font-weight: 650;
}

.tcp-preview-info span {
    color: #64748B;

    font-size: 10px;
}


/* =========================================================
   Compact Current Color Row
========================================================= */

.tcp-current-inline {
    display: flex;
    align-items: center;
    gap: 7px;

    width: 100%;
    min-width: 0;
    min-height: 34px;

    padding: 4px 7px;

    background: #F8FAFC;

    border: 1px solid #E5EAF1;
    border-radius: 8px;
}

.tcp-current-label,
.tcp-preview-label {
    flex: 0 0 auto;

    color: #64748B;

    font-size: 10px;
    white-space: nowrap;
}

.tcp-current-inline [data-tcp-current-value] {
    flex: 0 0 auto;

    color: #263244;

    font-family:
        "SFMono-Regular",
        Consolas,
        monospace;

    font-size: 11px;
    font-weight: 600;

    white-space: nowrap;
}

.tcp-current-inline .tcp-preview-swatch {
    width: 22px;
    height: 22px;

    flex: 0 0 22px;

    margin-left: auto;
}


/* =========================================================
   Color Grid
========================================================= */

.tcp-color-grid {
    display: grid;

    width: 100%;
    min-width: 0;

    grid-template-columns: repeat(10, minmax(0, 1fr));

    gap: 5px;
}

.tcp-theme-grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));

    gap: 5px;
}

.tcp-color-swatch {
    position: relative;

    display: block;

    width: 100%;
    min-width: 0;

    aspect-ratio: 1 / 1;

    padding: 0;

    background-color: var(--tcp-swatch-color, #FFFFFF);

    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 5px;

    cursor: pointer;

    transition:
        transform 120ms ease,
        border-color 120ms ease,
        box-shadow 120ms ease;
}

.tcp-theme-grid .tcp-color-swatch {
    border-radius: 5px;
}

.tcp-color-swatch:hover {
    z-index: 1;

    transform: scale(1.08);

    border-color: #64748B;

    box-shadow:
        0 2px 6px rgba(15, 23, 42, 0.12);
}

.tcp-color-swatch:focus-visible {
    outline: 2px solid #2563EB;
    outline-offset: 2px;
}

.tcp-color-swatch.is-selected {
    border-color: #2563EB;

    box-shadow:
        0 0 0 1px #FFFFFF,
        0 0 0 2px #2563EB;
}

.tcp-color-swatch.is-selected::after {
    content: "";

    position: absolute;

    left: 50%;
    top: 50%;

    width: 5px;
    height: 8px;

    border-right: 2px solid #FFFFFF;
    border-bottom: 2px solid #FFFFFF;

    transform: translate(-50%, -60%) rotate(45deg);

    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.4));
}


/* =========================================================
   Custom Color
========================================================= */

.tcp-custom-row {
    display: grid;

    width: 100%;
    min-width: 0;

    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);

    gap: 8px;
}

.tcp-native-color-label {
    position: relative;

    display: flex;
    align-items: center;
    gap: 7px;

    min-width: 0;
    min-height: 34px;

    padding: 4px 7px;

    color: #344054;
    background: #FFFFFF;

    border: 1px solid #DCE3EC;
    border-radius: 8px;

    font-size: 11px;
    font-weight: 550;

    cursor: pointer;

    transition:
        background 140ms ease,
        border-color 140ms ease;
}

.tcp-native-color-label:hover {
    background: #F8FAFC;
    border-color: #A8B7CA;
}

.tcp-native-color-preview {
    display: block;

    width: 22px;
    height: 22px;

    flex: 0 0 22px;

    background-color: #000000;

    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 6px;
}

.tcp-native-color-input {
    position: absolute;
    inset: 0;

    width: 100%;
    height: 100%;

    opacity: 0;

    cursor: pointer;
}

.tcp-hex-field {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;

    min-width: 0;
}

.tcp-hex-field > span {
    color: #64748B;

    font-size: 10px;
    line-height: 1.2;
}

.tcp-hex-field input {
    width: 100%;
    min-width: 0;
    height: 25px;

    padding: 3px 7px;

    color: #263244;
    background: #FFFFFF;

    border: 1px solid #DCE3EC;
    border-radius: 6px;

    outline: none;

    font-family:
        "SFMono-Regular",
        Consolas,
        monospace;

    font-size: 11px;

    transition:
        border-color 140ms ease,
        box-shadow 140ms ease;
}

.tcp-hex-field input:focus {
    border-color: #3B82F6;

    box-shadow:
        0 0 0 2px rgba(59, 130, 246, 0.12);
}

.tcp-validation-message {
    display: none;

    margin: 5px 0 0;

    color: #DC2626;

    font-size: 10px;
    line-height: 1.4;
}

.tcp-validation-message.is-visible {
    display: block;
}


/* =========================================================
   Recent Colors
========================================================= */

.tcp-recent-section {
    min-width: 0;
    padding-bottom: 0;
}

.tcp-empty-recent {
    margin: 0;
    padding: 7px 0;

    color: #94A3B8;

    font-size: 10px;
    text-align: center;
}

.tcp-empty-recent[hidden] {
    display: none;
}


/* =========================================================
   Footer
========================================================= */

.tcp-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;

    flex: 0 0 auto;

    min-height: 48px;
    padding: 7px 12px;

    background: #FFFFFF;

    border-top: 1px solid #E9EDF3;
}

.tcp-footer-actions {
    display: flex;
    align-items: center;
    gap: 6px;

    min-width: 0;
}

.tcp-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;

    min-height: 30px;

    padding: 0 10px;

    border: 1px solid transparent;
    border-radius: 7px;

    font-family: inherit;
    font-size: 11px;
    font-weight: 650;

    white-space: nowrap;

    cursor: pointer;

    transition:
        color 140ms ease,
        background 140ms ease,
        border-color 140ms ease,
        box-shadow 140ms ease,
        transform 140ms ease;
}

.tcp-button:active {
    transform: translateY(1px);
}

.tcp-button:focus-visible {
    outline: 2px solid #2563EB;
    outline-offset: 2px;
}

.tcp-button-ghost {
    padding: 0 6px;

    color: #64748B;
    background: transparent;
}

.tcp-button-ghost:hover {
    color: #1D4ED8;
    background: #EFF6FF;
}

.tcp-button-secondary {
    color: #344054;
    background: #FFFFFF;

    border-color: #DCE3EC;
}

.tcp-button-secondary:hover {
    background: #F8FAFC;
    border-color: #B8C5D5;
}

.tcp-button-primary {
    color: #FFFFFF;

    background: linear-gradient(
        135deg,
        #2563EB,
        #4F46E5
    );

    box-shadow:
        0 2px 4px rgba(37, 99, 235, 0.18);
}

.tcp-button-primary:hover {
    background: linear-gradient(
        135deg,
        #1D4ED8,
        #4338CA
    );

    box-shadow:
        0 3px 7px rgba(37, 99, 235, 0.22);
}


/* =========================================================
   Mobile
========================================================= */

@media (max-width: 480px) {

    .text-color-panel {
        width: calc(100vw - 20px);
        max-height: calc(100dvh - 20px);

        border-radius: 12px;
    }

    .tcp-header {
        min-height: 34px;
        padding: 3px 7px;
    }

    .tcp-body {
        padding: 9px 10px;
    }

    .tcp-section {
        margin-top: 11px;
    }

    .tcp-section-heading {
        margin-bottom: 5px;
    }

    .tcp-theme-grid {
        gap: 4px;
    }

    .tcp-color-grid {
        gap: 4px;
    }

    .tcp-footer {
        min-height: 44px;
        padding: 6px 9px;
    }

    .tcp-button {
        min-height: 29px;
        padding: 0 8px;

        font-size: 11px;
    }

    .tcp-button-ghost {
        padding: 0 4px;
    }

    .tcp-footer-actions {
        gap: 5px;
    }
}


/* =========================================================
   Reduced Motion
========================================================= */

@media (prefers-reduced-motion: reduce) {

    .text-color-panel,
    .text-color-panel *,
    .text-color-panel *::before,
    .text-color-panel *::after {
        transition: none !important;
        animation: none !important;
    }
}