/* ============================================
   GRASP - Base Styles (Layout & Components)
   Цвета — в тематических файлах
   ============================================ */

/* ===== Reset ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.5;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    border-radius: 4px;
}

/* ===== Header ===== */
.header {
    border-bottom-width: 1px;
    border-bottom-style: solid;
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.header__container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.header__title {
    font-size: 1.3rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.header__logo {
    flex-shrink: 0;
}

.header__status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.status-indicator--loading { animation: pulse 1.5s infinite; }
.status-indicator--started  { }
.status-indicator--frozen   { }
.status-indicator--stopped  { }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.header__actions {
    margin-left: auto;
    display: flex;
    gap: 4px;
    align-items: center;
}

/* ===== Navigation ===== */
.nav {
    border-bottom-width: 1px;
    border-bottom-style: solid;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.nav__container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    gap: 0;
}

.nav__tab {
    padding: 12px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.nav__tab:hover {
    border-bottom-style: solid;
}

.nav__tab.active {
    border-bottom-style: solid;
}

.nav__badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.nav__badge:empty {
    display: none;
}

/* ===== Main ===== */
.main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ===== Toolbar ===== */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}

.toolbar__left,
.toolbar__right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar__title {
    font-size: 1.1rem;
    font-weight: 600;
}

.toolbar__stats {
    font-size: 0.85rem;
}

/* ===== Buttons ===== */
.btn {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-family: inherit;
}

.btn:hover {
    opacity: 0.85;
}

.btn--primary {
    color: #fff;
}

.btn--danger {
    /* color задаётся темой */;
}

.btn--icon {
    padding: 6px;
    background: transparent;
    border: 1px solid transparent;
}

.btn--sm {
    padding: 4px 10px;
    font-size: 0.8rem;
}

/* ===== Filter Bar ===== */
.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filter-bar__select {
    padding: 6px 12px;
    background: transparent;
    border: 1px solid;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: border-color 0.2s ease;
    font-family: inherit;
}

.filter-bar__select:focus {
    outline: none;
}

.filter-bar__search {
    padding: 6px 12px;
    background: transparent;
    border: 1px solid;
    border-radius: 6px;
    font-size: 0.85rem;
    flex: 1;
    min-width: 200px;
    transition: border-color 0.2s ease;
    font-family: inherit;
}

.filter-bar__search:focus {
    outline: none;
}

/* ===== Loading ===== */
.loading {
    text-align: center;
    padding: 48px;
    font-style: italic;
}

/* ===== Repo Tree ===== */
.repo-tree {
    border: 1px solid;
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.3s ease;
}

.repo-group {
    border-bottom-width: 1px;
    border-bottom-style: solid;
    transition: border-color 0.3s ease;
}

.repo-group:last-child {
    border-bottom: none;
}

.repo-group__header {
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s ease;
    user-select: none;
}

.repo-group__header:hover {
    /* фон задаётся темой */;
}

.repo-group__header .arrow {
    transition: transform 0.2s ease;
    font-size: 0.7rem;
    flex-shrink: 0;
}

.repo-group__header.collapsed .arrow {
    transform: rotate(-90deg);
}

.repo-group__count {
    font-size: 0.8rem;
    font-weight: 400;
}

.repo-group__body {
    /* visible by default */;
}

.repo-group__header.collapsed + .repo-group__body {
    display: none;
}

.repo-item {
    padding: 10px 16px 10px 40px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-top-width: 1px;
    border-top-style: solid;
    cursor: pointer;
    transition: background-color 0.2s ease;
    flex-wrap: wrap;
}

.repo-item__status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.repo-item__info {
    flex: 1;
    min-width: 0;
}

.repo-item__name {
    font-weight: 600;
    font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.repo-item__path {
    font-size: 0.8rem;
    font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.repo-item__description {
    font-size: 0.8rem;
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.repo-item__tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.repo-tag {
    padding: 2px 8px;
    border: 1px solid;
    border-radius: 12px;
    font-size: 0.75rem;
}

.repo-item__interval {
    font-size: 0.8rem;
    font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}

.repo-item__actions {
    display: flex;
    gap: 4px;
}

/* ===== Queue List ===== */
.queue-list {
    border: 1px solid;
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.3s ease;
}

.queue-item {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    transition: background-color 0.2s ease;
}

.queue-item__priority {
    font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.75rem;
    min-width: 24px;
}

.queue-item__type {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.queue-item__name {
    flex: 1;
    font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
    font-weight: 600;
}

.queue-item__scheduled {
    font-size: 0.8rem;
}

/* ===== Events List ===== */
.events-list {
    border: 1px solid;
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.3s ease;
}

.event-item {
    padding: 10px 16px;
    display: flex;
    gap: 12px;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    align-items: flex-start;
    transition: background-color 0.2s ease;
}

.event-item__time {
    font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.8rem;
    white-space: nowrap;
    min-width: 140px;
}

.event-item__type {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.event-item__message {
    flex: 1;
    font-size: 0.85rem;
}

.event-item__description {
    font-size: 0.8rem;
    margin-top: 2px;
}

/* ===== Modal ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
}

.modal.active {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 80px;
}

.modal__overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.modal__content {
    position: relative;
    border: 1px solid;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    z-index: 1;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.modal__content--wide {
    max-width: 700px;
}

.modal__header {
    padding: 16px 20px;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 2;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.modal__title {
    font-size: 1.05rem;
    font-weight: 600;
}

.modal__close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s ease;
}

.modal__body {
    padding: 20px;
}

/* ===== Form ===== */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s ease, background-color 0.3s ease, color 0.3s ease;
}

.form-input:focus {
    outline: none;
}

.form-textarea {
    resize: vertical;
    min-height: 60px;
}

.interval-input {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.interval-presets {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.preset-btn {
    padding: 4px 8px;
    border: 1px solid;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.preset-btn.active {
    /* задаётся темой */;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
    padding-top: 16px;
    border-top-width: 1px;
    border-top-style: solid;
    transition: border-color 0.3s ease;
}

/* ===== Detail View ===== */
.detail-grid {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 8px 16px;
}

.detail-label {
    font-weight: 600;
    font-size: 0.85rem;
}

.detail-value {
    word-break: break-all;
    font-size: 0.9rem;
}

.detail-value--mono {
    font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.85rem;
}

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    font-size: 0.9rem;
    animation: slideIn 0.3s ease;
    max-width: 400px;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ===== Theme Toggle Button ===== */
#btnToggleTheme {
    position: relative;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .header__container { padding: 0 12px; }
    .nav__container { padding: 0 12px; }
    .main { padding: 12px; }
    .nav__tab { padding: 10px 12px; font-size: 0.8rem; }
    .repo-item { padding: 10px 12px 10px 24px; }
    .repo-item__description { display: none; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .detail-grid { grid-template-columns: 1fr; }
}

/* ===== Groups Table ===== */
.groups-table-wrapper {
    border: 1px solid;
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.3s ease;
}

.groups-table {
    width: 100%;
    border-collapse: collapse;
}

.groups-table__th {
    padding: 10px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.85rem;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    transition: border-color 0.3s ease, background-color 0.3s ease;
}

.groups-table__th--alias {
    width: 180px;
}

.groups-table__th--title {
    /* flex */
}

.groups-table__th--period {
    width: 160px;
}

.groups-table__th--count {
    width: 120px;
    text-align: center;
}

.groups-table__th--actions {
    width: 140px;
    text-align: right;
}

.groups-table td {
    padding: 10px 16px;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    font-size: 0.9rem;
    transition: border-color 0.3s ease;
}

.groups-table tbody tr:last-child td {
    border-bottom: none;
}

.groups-table tbody tr:hover {
    transition: background-color 0.2s ease;
}

.groups-table__alias {
    font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.85rem;
}

.groups-table__count {
    text-align: center;
    font-weight: 600;
}

.groups-table__actions {
    text-align: right;
    display: flex;
    gap: 4px;
    justify-content: flex-end;
}

.groups-table .loading {
    text-align: center;
    padding: 32px;
    font-style: italic;
}

.groups-table__row--default {
    /* чуть выделяем фоном */
}

.groups-table__period {
    font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.85rem;
}

.groups-table__hint {
    font-size: 0.8rem;
    font-style: italic;
}

.form-hint {
    font-size: 0.75rem;
    margin-top: 4px;
}

/* Кнопка добавления репозитория в навбаре */
.nav__add-btn {
    margin-left: auto;
    padding: 6px 14px;
    font-size: 0.85rem;
    border-radius: 6px;
    align-self: center;
}

@media (max-width: 768px) {
    .nav__add-btn {
        display: none;
    }
}

/* ===== About Modal ===== */
.modal__content--about {
    max-width: 440px;
}

.about-content {
    text-align: center;
}

.about-logo {
    color: var(--color-primary);
    margin-bottom: 16px;
}

.about-name {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.about-tagline {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    margin-bottom: 20px;
}

.about-description {
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 24px;
    text-align: left;
}

.about-links {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 24px;
}

.about-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.about-link:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.about-meta {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
}

.about-meta__sep {
    margin: 0 8px;
    opacity: 0.5;
}
/* ===== END: About Modal  ===== */