
/*
Theme Name: CDN Widgets
Description: Минимальная тема WordPress с защищённой панелью управления CDN-виджетами.
Version: 1.2.0
Requires PHP: 7.4
Text Domain: cdn-widgets
*/


/* Основные стили */

:root {
    color-scheme: light;

    --background: #f5f5f7;
    --surface: #ffffff;
    --text: #1d1d1f;
    --text-secondary: #6e6e73;
    --border: #e5e5e7;

    --blue: #0071e3;
    --blue-hover: #0077ed;

    --green: #34c759;
    --red: #ff3b30;

    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

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

body {
    min-height: 100vh;
    margin: 0;

    background: var(--background);
    color: var(--text);
}

button,
input {
    font: inherit;
}

button {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: var(--blue);
}

::selection {
    background: #cce4ff;
    color: var(--text);
}


/* Типографика */

h1,
h2,
h3 {
    color: var(--text);
    font-weight: 700;
}

h1 {
    margin: 12px 0 10px;

    font-size: clamp(32px, 5vw, 44px);
    line-height: 1.12;
    letter-spacing: -0.04em;
}

h2 {
    margin: 0 0 20px;

    font-size: 22px;
    line-height: 1.25;
    letter-spacing: -0.025em;
}

h3 {
    margin: 0;

    font-size: 18px;
    line-height: 1.35;
    letter-spacing: -0.02em;
    overflow-wrap: anywhere;
}

.brand {
    color: var(--blue);

    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.muted {
    margin: 0;

    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

.hint {
    margin-top: 12px;
    font-size: 13px;
}


/* Поля ввода */

input[type="text"],
input[type="password"] {
    display: block;

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

    padding: 0 16px;

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

    background: var(--surface);
    color: var(--text);

    font-size: 16px;
    outline: none;

    transition: border-color 0.2s ease;
}

input[type="text"]:hover,
input[type="password"]:hover {
    border-color: #a1a1a6;
}

input[type="text"]:focus,
input[type="password"]:focus {
    border-color: var(--blue);
}

input::placeholder {
    color: #86868b;
}


/* Кнопки */

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

    min-height: 44px;
    padding: 0 22px;

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

    background: transparent;
    color: var(--text);

    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;

    cursor: pointer;
    user-select: none;

    transition:
        background-color 0.2s ease,
        border-color 0.2s ease,
        color 0.2s ease;
}

.button:focus-visible {
    outline: 3px solid rgba(0, 113, 227, 0.35);
    outline-offset: 3px;
}

.button-primary {
    background: var(--blue);
    color: #ffffff;
}

.button-primary:hover {
    background: var(--blue-hover);
}

.button-outline {
    border-color: #d2d2d7;
    background: var(--surface);
    color: var(--text);
}

.button-outline:hover {
    background: var(--background);
    border-color: #a1a1a6;
}

.button-danger {
    border-color: #ffd5d2;
    background: transparent;
    color: #d92d20;
}

.button-danger:hover {
    border-color: #ffb8b3;
    background: #fff1f0;
}


/* Основной контейнер */

.cdn-panel {
    width: 100%;
    max-width: 1040px;

    margin: 0 auto;
    padding: 64px 32px 100px;
}


/* Авторизация */

.login-card {
    width: 100%;
    max-width: 420px;

    margin: min(16vh, 130px) auto 0;
    padding: 44px 40px;

    border: 1px solid var(--border);
    border-radius: 20px;

    background: var(--surface);
}

.login-card h1 {
    margin-bottom: 14px;
}

.login-card form {
    display: grid;
    gap: 14px;

    margin-top: 32px;
}

.login-card label {
    color: var(--text);

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

.login-card .button {
    width: 100%;
    margin-top: 8px;
}


/* Заголовок панели */

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;

    margin-bottom: 40px;
}

.panel-header .button {
    flex-shrink: 0;
}


/* Секции */

.panel-section {
    padding: 32px;

    border: 1px solid var(--border);
    border-radius: 20px;

    background: var(--surface);
}

.panel-section h2 {
    margin-bottom: 20px;
}


/* Добавление сайта */

.add-form {
    display: flex;
    align-items: center;
    gap: 12px;
}

.add-form input {
    flex: 1;
}

.add-form .button {
    flex-shrink: 0;
}


/* Список сайтов */

.sites-section {
    margin-top: 48px;
}

.count {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-width: 24px;
    height: 24px;
    padding: 0 7px;

    margin-left: 4px;

    border-radius: 100px;

    background: #e8e8ed;
    color: var(--text-secondary);

    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    vertical-align: middle;
}


/* Пустой список */

.empty-state {
    padding: 44px 24px;

    border: 1px dashed #d2d2d7;
    border-radius: 16px;

    background: rgba(255, 255, 255, 0.5);
    color: var(--text-secondary);

    font-size: 14px;
    line-height: 1.6;
    text-align: center;
}


/* Карточка сайта */

.site-card {
    margin-top: 16px;
    padding: 28px 32px;

    border: 1px solid var(--border);
    border-radius: 20px;

    background: var(--surface);
}

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

    margin-bottom: 24px;
}


/* Список виджетов */

.widgets-list {
    display: grid;
    grid-template-columns: repeat(
        auto-fill,
        minmax(220px, 1fr)
    );
    gap: 12px;

    margin-bottom: 24px;
}


/* Переключатели виджетов */

.widget-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;

    min-height: 64px;
    padding: 14px 16px;

    border: 1px solid var(--border);
    border-radius: 14px;

    background: #fafafa;

    cursor: pointer;
    user-select: none;

    transition:
        background-color 0.2s ease,
        border-color 0.2s ease;
}

.widget-toggle:hover {
    background: #f5f5f7;
    border-color: #d2d2d7;
}

.widget-toggle > span:first-child {
    flex: 1;
    min-width: 0;

    color: var(--text);

    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.widget-toggle input {
    position: absolute;

    width: 1px;
    height: 1px;

    opacity: 0;
}


/* Визуальная часть переключателя */

.toggle-track {
    position: relative;

    flex: 0 0 44px;

    width: 44px;
    height: 26px;

    border-radius: 100px;

    background: #d2d2d7;

    transition: background-color 0.2s ease;
}

.toggle-track::before {
    content: "";

    position: absolute;
    top: 3px;
    left: 3px;

    width: 20px;
    height: 20px;

    border-radius: 50%;

    background: #ffffff;

    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);

    transition: transform 0.2s ease;
}


/* Активный переключатель */

.widget-toggle input:checked + .toggle-track {
    background: var(--green);
}

.widget-toggle input:checked + .toggle-track::before {
    transform: translateX(18px);
}

.widget-toggle input:focus-visible + .toggle-track {
    outline: 3px solid rgba(0, 113, 227, 0.4);
    outline-offset: 3px;
}


/* Сохранение настроек */

.save-button {
    min-width: 140px;
}


/* Уведомления */

.alert {
    margin: 24px 0;
    padding: 16px 20px;

    border: 1px solid var(--border);
    border-radius: 12px;

    background: var(--surface);
    color: var(--text);

    font-size: 14px;
    line-height: 1.6;
}

.alert-success {
    border-color: #ccebd5;
    background: #f0faf3;
    color: #237a3b;
}

.alert-error {
    border-color: #ffd5d2;
    background: #fff1f0;
    color: #c62828;
}


/* Скрытый текст для доступности */

.visually-hidden {
    position: absolute;

    width: 1px;
    height: 1px;

    padding: 0;
    margin: -1px;

    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);

    white-space: nowrap;
    border: 0;
}


/* Планшеты */

@media (max-width: 768px) {

    .cdn-panel {
        padding: 48px 24px 80px;
    }

    .panel-section {
        padding: 28px;
    }

    .site-card {
        padding: 24px;
    }

    .widgets-list {
        grid-template-columns: repeat(
            auto-fill,
            minmax(190px, 1fr)
        );
    }

}


/* Смартфоны */

@media (max-width: 600px) {

    .cdn-panel {
        padding: 36px 16px 64px;
    }

    h1 {
        font-size: 32px;
    }

    h2 {
        font-size: 20px;
    }

    h3 {
        font-size: 17px;
    }

    .login-card {
        margin-top: 64px;
        padding: 32px 24px;
    }

    .panel-header {
        flex-wrap: wrap;
        gap: 20px;

        margin-bottom: 32px;
    }

    .panel-header .button {
        min-height: 40px;
        padding: 0 18px;
    }

    .panel-section {
        padding: 24px 20px;
        border-radius: 18px;
    }

    .add-form {
        flex-direction: column;
        align-items: stretch;
    }

    .add-form input {
        flex: none;
    }

    .add-form .button {
        width: 100%;
    }

    .sites-section {
        margin-top: 40px;
    }

    .site-card {
        padding: 22px 20px;
        border-radius: 18px;
    }

    .site-header {
        align-items: flex-start;
        flex-wrap: wrap;
        gap: 12px;

        margin-bottom: 20px;
    }

    .widgets-list {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .widget-toggle {
        min-height: 60px;
    }

    .save-button {
        width: 100%;
    }

}


/* Уменьшение анимаций */

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

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }

}
