/* =====================================================
   Global reset
   ===================================================== */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;

    margin: 0;
    padding: 0;

    overflow: hidden;

    background: #111;
    color: #e0e0e0;

    font-family:
        Arial,
        Helvetica,
        sans-serif;
}

button,
input {
    font: inherit;
}


/* =====================================================
   Main GIPHY browser
   ===================================================== */

.giphy-browser {
    display: flex;
    flex-direction: column;

    width: 100%;
    height: 100%;

    min-width: 0;
    min-height: 0;

    overflow: hidden;

    background: #313338;
    color: #dbdee1;
}


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

.giphy-header {
    display: flex;
    flex: 0 0 auto;

    align-items: center;
    justify-content: space-between;

    min-height: 58px;
    padding: 9px 12px;

    border-bottom:
        1px solid rgba(0, 0, 0, 0.35);

    background: #1e1f22;
}

.giphy-header-info {
    display: flex;
    align-items: center;

    min-width: 0;
    gap: 10px;
}

.giphy-header-icon {
    display: grid;
    place-items: center;

    width: 38px;
    height: 30px;

    border-radius: 6px;

    background: #5865f2;
    color: #fff;

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

.giphy-title {
    margin: 0;

    color: #f2f3f5;

    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
}

.giphy-subtitle {
    margin: 3px 0 0;

    color: #949ba4;

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

.giphy-close-button {
    display: grid;
    place-items: center;

    width: 30px;
    height: 28px;

    padding: 0;

    border: 1px solid #4e5058;
    border-radius: 5px;

    background: #2b2d31;
    color: #dbdee1;

    cursor: pointer;

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

.giphy-close-button:hover {
    background: #3f4147;
    color: #fff;
}


/* =====================================================
   Search section
   ===================================================== */

.giphy-search-section {
    flex: 0 0 auto;

    padding: 10px 12px 8px;

    border-bottom:
        1px solid rgba(0, 0, 0, 0.3);

    background: #2b2d31;
}

.search-row {
    display: grid;

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

    gap: 7px;
}

.giphy-search-input {
    width: 100%;
    min-width: 0;
    height: 38px;

    padding: 0 11px;

    border: 1px solid #4e5058;
    border-radius: 6px;

    outline: 0;

    background: #1e1f22;
    color: #f2f3f5;

    font-size: 13px;
}

.giphy-search-input::placeholder {
    color: #949ba4;
}

.giphy-search-input:focus {
    border-color: #5865f2;
}

.giphy-search-button {
    height: 38px;

    padding: 0 15px;

    border: 0;
    border-radius: 6px;

    background: #5865f2;
    color: #fff;

    cursor: pointer;

    font-size: 12px;
    font-weight: 700;
}

.giphy-search-button:hover:not(:disabled) {
    background: #4752c4;
}

.giphy-search-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.giphy-status {
    min-height: 18px;

    margin-top: 7px;

    color: #949ba4;

    font-size: 11px;
}


/* =====================================================
   Main two-column layout
   ===================================================== */

.giphy-layout {
    display: grid;

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

    flex: 1 1 0;

    width: 100%;
    height: 0;

    min-width: 0;
    min-height: 0;

    overflow: hidden;

    background: #313338;
}


/* =====================================================
   History panel
   ===================================================== */

.giphy-history-panel {
    display: flex;
    flex-direction: column;

    width: 100%;

    min-width: 0;
    min-height: 0;

    overflow: hidden;

    border-right:
        1px solid rgba(0, 0, 0, 0.35);

    background: #2b2d31;
}

.giphy-history-header {
    display: flex;
    flex: 0 0 auto;

    align-items: center;
    justify-content: space-between;

    min-height: 45px;
    padding: 0 10px 0 12px;

    border-bottom:
        1px solid rgba(0, 0, 0, 0.3);

    background: #232428;
}

.giphy-history-title {
    color: #f2f3f5;

    font-size: 13px;
    font-weight: 700;
}

.giphy-history-count {
    display: inline-grid;
    place-items: center;

    min-width: 21px;
    height: 21px;

    margin-left: 5px;
    padding: 0 6px;

    border-radius: 20px;

    background: #1e1f22;
    color: #b5bac1;

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

.giphy-history-clear {
    padding: 5px 8px;

    border: 0;
    border-radius: 4px;

    background: transparent;
    color: #b5bac1;

    cursor: pointer;

    font-size: 11px;
}

.giphy-history-clear:hover {
    background: #3f4147;
    color: #fff;
}

.giphy-history-list {
    flex: 1 1 auto;

    min-width: 0;
    min-height: 0;

    padding: 8px;

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

.giphy-history-empty {
    padding: 24px 10px;

    color: #949ba4;

    font-size: 11px;
    line-height: 1.5;
    text-align: center;
}

.giphy-history-item {
    display: grid;

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

    align-items: center;
    gap: 8px;

    margin-bottom: 7px;
    padding: 7px;

    overflow: hidden;

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

    background: #232428;
}

.giphy-history-item:hover {
    border-color:
        rgba(255, 255, 255, 0.07);

    background: #35373c;
}

.giphy-history-image {
    width: 52px;
    height: 52px;

    object-fit: cover;

    border-radius: 5px;

    background: #1e1f22;

    cursor: pointer;
}

.giphy-history-info {
    min-width: 0;
}

.giphy-history-item-title {
    overflow: hidden;

    color: #f2f3f5;

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

    text-overflow: ellipsis;
    white-space: nowrap;
}

.giphy-history-meta {
    margin-top: 3px;

    color: #949ba4;

    font-size: 9px;
}

.giphy-history-actions {
    display: flex;

    grid-column: 1 / -1;

    justify-content: flex-end;

    gap: 4px;
    margin-top: 2px;
}

.giphy-history-action {
    display: grid;
    place-items: center;

    min-width: 27px;
    height: 25px;

    padding: 0 7px;

    border: 0;
    border-radius: 4px;

    background: #1e1f22;
    color: #b5bac1;

    cursor: pointer;

    font-size: 11px;
}

.giphy-history-action:hover {
    background: #5865f2;
    color: #fff;
}


/* =====================================================
   Search results
   ===================================================== */

.giphy-results {
    display: grid;

    grid-template-columns:
        repeat(
            auto-fill,
            minmax(145px, 1fr)
        );

    grid-auto-rows: max-content;

    align-content: start;
    align-items: start;

    min-width: 0;
    min-height: 0;

    padding: 12px;

    gap: 12px;

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

    background: #313338;
}

.gif-item-wrap {
    display: flex;
    flex-direction: column;

    min-width: 0;

    padding: 7px;

    overflow: hidden;

    border: 1px solid #3f4147;
    border-radius: 8px;

    background: #18191c;
}

.gif-item-wrap:hover {
    border-color: #686b74;
    background: #1e1f22;
}

.giphy-image-button {
    display: block;

    width: 100%;
    padding: 0;

    overflow: hidden;

    border: 0;
    border-radius: 6px;

    background: #111;

    cursor: pointer;
}

.giphy-result {
    display: block;

    width: 100%;
    aspect-ratio: 1 / 1;

    object-fit: cover;

    background: #111;
}

.giphy-result-title {
    min-height: 30px;

    margin-top: 7px;

    overflow: hidden;

    color: #f2f3f5;

    font-size: 11px;
    line-height: 1.3;

    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.giphy-result-actions {
    display: grid;

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

    gap: 5px;
    margin-top: 7px;
}

.giphy-action-button {
    width: 100%;
    min-width: 0;

    padding: 6px 4px;

    border: 0;
    border-radius: 4px;

    cursor: pointer;

    overflow: hidden;

    font-size: 10px;
    font-weight: 700;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.send-gif-btn {
    background: #5865f2;
    color: #fff;
}

.send-gif-btn:hover {
    background: #4752c4;
}

.set-avatar-btn {
    background: #4e5058;
    color: #dbdee1;
}

.set-avatar-btn:hover {
    background: #686b74;
    color: #fff;
}


/* =====================================================
   Empty and error states
   ===================================================== */

.giphy-empty {
    grid-column: 1 / -1;

    width: 100%;
    margin: auto;
    padding: 40px 16px;

    color: #949ba4;

    text-align: center;
}

.giphy-empty-icon {
    display: inline-grid;
    place-items: center;

    width: 54px;
    height: 40px;

    margin-bottom: 10px;

    border-radius: 7px;

    background: #1e1f22;
    color: #b5bac1;

    font-size: 13px;
    font-weight: 800;
}

.giphy-empty-title {
    color: #f2f3f5;

    font-size: 14px;
    font-weight: 700;
}

.giphy-empty-text {
    margin-top: 5px;

    color: #949ba4;

    font-size: 11px;
}

.gif-load-error {
    opacity: 0.55;
}


/* =====================================================
   Scrollbars
   ===================================================== */

.giphy-history-list,
.giphy-results {
    scrollbar-color: #1e1f22 #2b2d31;
    scrollbar-width: thin;
}

.giphy-history-list::-webkit-scrollbar,
.giphy-results::-webkit-scrollbar {
    width: 10px;
}

.giphy-history-list::-webkit-scrollbar-track,
.giphy-results::-webkit-scrollbar-track {
    background: #2b2d31;
}

.giphy-history-list::-webkit-scrollbar-thumb,
.giphy-results::-webkit-scrollbar-thumb {
    border: 2px solid #2b2d31;
    border-radius: 10px;

    background: #1e1f22;
}


/* =====================================================
   Responsive layout
   ===================================================== */

@media (max-width: 720px) {
    .giphy-layout {
        grid-template-columns:
            165px
            minmax(0, 1fr);
    }

    .giphy-results {
        grid-template-columns:
            repeat(
                auto-fill,
                minmax(125px, 1fr)
            );
    }
}

@media (max-width: 540px) {
    .giphy-layout {
        display: flex;
        flex-direction: column;

        height: auto;
        overflow: auto;
    }

    .giphy-history-panel {
        flex: 0 0 180px;

        border-right: 0;
        border-bottom:
            1px solid rgba(0, 0, 0, 0.35);
    }

    .giphy-results {
        flex: 1 1 auto;

        grid-template-columns:
            repeat(
                auto-fill,
                minmax(120px, 1fr)
            );
    }
}
