/* Utility Components */

/* Grid System */
.grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 16px;
    margin-top: 16px;
}

.col-12 { grid-column: span 12; }
.col-6 { grid-column: span 6; }
.col-4 { grid-column: span 4; }

@media (max-width: 860px) {
    .col-6, .col-4 { grid-column: span 12; }
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 14px;
    border: 0;
    cursor: pointer;
    transition: all 140ms ease;
}

.btn-primary {
    background: var(--primary-bg);
    color: var(--primary-text);
}

.btn-primary:hover {
    filter: brightness(0.94);
}

.btn-ghost {
    background: transparent;
    color: var(--text);
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.08);
}

body[data-theme="light"] .btn-ghost:hover {
    background: rgba(0, 0, 0, 0.06);
}

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

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: var(--input-bg);
    color: var(--text);
    font-size: 14px;
    transition: border-color 140ms ease, box-shadow 140ms ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.18);
}

body[data-theme="light"] .form-control {
    border-color: rgba(0, 0, 0, 0.14);
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, 0.14);
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-success {
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.28);
    color: #10b981;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.28);
    color: #ef4444;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.28);
    color: #f59e0b;
}

.alert-danger { border-color: rgba(255, 255, 255, 0.18); }
.alert-warning { border-color: rgba(255, 255, 255, 0.18); }

body[data-theme="light"] .alert {
    border-color: rgba(0, 0, 0, 0.14);
    background: rgba(0, 0, 0, 0.04);
}

body[data-theme="light"] .alert-success,
body[data-theme="light"] .alert-danger,
body[data-theme="light"] .alert-warning {
    border-color: rgba(0, 0, 0, 0.18);
}

/* Back to Top */
.back-to-top {
    position: fixed;
    right: 22px;
    bottom: 92px;
    z-index: 9990;
    width: 52px;
    min-height: 52px;
    padding: 8px 6px 6px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-radius: 14px;
    background: var(--accent);
    color: #ffffff;
    cursor: pointer;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(16px);
    transition: opacity 220ms ease, transform 220ms ease, visibility 220ms ease, filter 140ms ease;
}

.back-to-top.is-visible {
    display: inline-flex;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.back-to-top.is-scrolling {
    pointer-events: none;
    filter: brightness(1.08);
}

.back-to-top.is-scrolling .back-to-top__icon {
    animation: back-to-top-bounce 0.55s ease-in-out infinite alternate;
}

@keyframes back-to-top-bounce {
    from {
        transform: translateY(3px);
    }

    to {
        transform: translateY(-5px);
    }
}

.back-to-top:hover {
    filter: brightness(1.06);
}

.back-to-top:focus-visible {
    outline: 2px solid var(--text);
    outline-offset: 3px;
}

.back-to-top__icon {
    width: 20px;
    height: 20px;
    display: block;
}

.back-to-top__label {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.8px;
    line-height: 1;
}

body[data-theme="light"] .back-to-top {
    border-color: rgba(0, 0, 0, 0.12);
}

@media (max-width: 860px) {
    .back-to-top {
        right: 14px;
        bottom: 76px;
        width: 48px;
        min-height: 48px;
        border-radius: 12px;
    }

    .back-to-top__icon {
        width: 18px;
        height: 18px;
    }

    .back-to-top__label {
        font-size: 8px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .back-to-top {
        transition: opacity 120ms ease, visibility 120ms ease;
        transform: none;
    }

    .back-to-top.is-visible {
        transform: none;
    }

    .back-to-top.is-scrolling .back-to-top__icon {
        animation: none;
    }
}
