/* Cards */
.card {
    background: var(--card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--glass-border), transparent);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    color: var(--text);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    gap: 0.5rem;
    font-family: inherit;
    text-decoration: none;
}

.btn-icon {
    font-size: 1.1rem;
}

.btn-text {
    font-weight: 500;
}

@media (max-width: 600px) {
    .dashboard-btn .btn-text {
        display: none;
    }
    
    .dashboard-btn {
        padding: 0.6rem;
    }
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: #4752c4;
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--glass);
    color: var(--text);
    border-color: var(--glass-border);
}

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

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

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

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    border-radius: 6px;
}

.btn-lg {
    padding: 0.8rem 1.6rem;
    font-size: 1.1rem;
    border-radius: 10px;
}

.btn-danger {
    background: rgba(231, 76, 60, 0.15);
    color: #e74c3c;
    border-color: rgba(231, 76, 60, 0.2);
}

.btn-danger:hover {
    background: #e74c3c;
    color: white;
}

/* Role Tags */
.role-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid;
    margin: 0 6px 6px 0;
    transition: all 0.2s ease;
}

.role-tag-remove {
    cursor: pointer;
    opacity: 0.6;
    font-size: 0.75rem;
    margin-left: 2px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
}

.role-tag-remove:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.4);
    transform: scale(1.1);
}

/* Inputs */
.search-box {
    position: relative;
    flex: 1;
    max-width: 400px;
}

.search-input {
    width: 100%;
    padding: 0.6rem 1rem;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
    transition: all 0.2s;
}

.search-input:focus {
    border-color: var(--accent);
    background: rgba(0, 0, 0, 0.6);
    box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.2);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid transparent;
}

.badge-accent {
    background: rgba(var(--accent-rgb), 0.1);
    color: var(--accent);
    border-color: rgba(var(--accent-rgb), 0.2);
}

/* Toggle Switch */
.toggle-switch-small {
    position: relative;
    width: 44px;
    height: 24px;
    display: inline-block;
    flex-shrink: 0;
}

.toggle-switch-small input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-indicator {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.08);
    transition: all 0.3s ease;
    border-radius: 24px;
    border: 1px solid var(--glass-border);
}

.toggle-indicator:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    top: 3px;
    background-color: white;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch-small input:checked + .toggle-indicator {
    background-color: var(--accent);
    border-color: var(--accent);
}

.toggle-switch-small input:checked + .toggle-indicator:before {
    left: 23px;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(12px) saturate(180%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 2rem;
    animation: fade-in 0.2s ease-out;
}

.modal-content {
    background: radial-gradient(circle at top left, rgba(20, 28, 45, 0.98), rgba(11, 18, 32, 0.98));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    max-width: 600px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 
        0 24px 64px rgba(0, 0, 0, 0.6),
        inset 0 1px 1px rgba(255, 255, 255, 0.1);
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    animation: modal-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-content::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent);
    z-index: 1;
}

.modal-content::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.15), transparent 40%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    z-index: 2;
}

.modal-header {
    margin-bottom: 1.5rem;
}

.modal-channel-header {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    margin: 0;
    letter-spacing: -0.02em;
}

.modal-channel-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
    margin-right: -10px;
    padding-right: 10px;
}

.modal-channel-item, .modal-channel-button {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1.25rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text);
    width: 100%;
    text-align: left;
}

.modal-channel-item:hover, .modal-channel-button:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.modal-channel-item.selected, .modal-channel-button.selected {
    background: rgba(var(--accent-rgb), 0.15);
    border-color: var(--accent);
    color: white;
}

.modal-channel-name {
    font-weight: 600;
}

.modal-channel-id {
    display: block;
    font-size: 0.8rem;
    color: var(--muted);
    font-family: monospace;
}

.modal-footer {
    display: flex;
    gap: 12px;
    margin-top: 1.5rem;
    justify-content: center;
    align-items: center;
}

.modal-search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.95rem;
    outline: none;
    margin-bottom: 1.25rem;
    transition: all 0.2s;
}

.modal-search-input:focus {
    border-color: var(--accent);
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.2);
}

/* Alert Modals */
.alert-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(12px) saturate(180%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    padding: 2rem;
    animation: fade-in 0.2s ease-out;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.alert-modal {
    background: radial-gradient(circle at top left, rgba(20, 28, 45, 0.98), rgba(11, 18, 32, 0.98));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    max-width: 400px;
    width: 100%;
    padding: 1.75rem;
    box-shadow: 
        0 32px 64px -12px rgba(0, 0, 0, 0.7),
        inset 0 1px 1px rgba(255, 255, 255, 0.1);
    text-align: center;
    position: relative;
    overflow: hidden;
    animation: modal-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.alert-modal::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent);
    z-index: 1;
}

.alert-modal::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.15), transparent 40%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    z-index: 2;
}

.alert-modal.error::before { background: #ef4444; }
.alert-modal.warn::before { background: #f59e0b; }
.alert-modal.success::before { background: #10b981; }
.alert-modal.info::before { background: var(--accent); }

@keyframes modal-pop {
    0% { transform: scale(0.9) translateY(20px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

.alert-modal-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    display: inline-block;
    filter: drop-shadow(0 0 16px rgba(0, 0, 0, 0.4));
}

.alert-modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    margin-bottom: 0.5rem;
    letter-spacing: -0.01em;
}

.alert-modal-message {
    color: var(--muted);
    line-height: 1.5;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.alert-modal-input-container {
    margin-bottom: 1.5rem;
}

.alert-modal-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s;
}

.alert-modal-input:focus {
    border-color: var(--accent);
    background: rgba(0, 0, 0, 0.4);
}

.alert-modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.alert-modal-btn {
    min-width: 120px;
}

.dashboard-alert-toast {
    position: fixed;
    z-index: 10001;
    min-width: 320px;
    max-width: 460px;
    padding: 0.9rem 1rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: radial-gradient(circle at top left, rgba(20, 28, 45, 0.98), rgba(11, 18, 32, 0.98));
    box-shadow: 0 20px 40px -16px rgba(0, 0, 0, 0.68);
    pointer-events: auto;
}

.dashboard-alert-toast::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 3px;
    border-radius: 12px 12px 0 0;
    background: var(--accent);
}

.dashboard-alert-toast.is-top-right {
    top: 18px;
    right: 18px;
}

.dashboard-alert-toast.is-top {
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
}

.dashboard-alert-toast.info::before { background: var(--accent); }
.dashboard-alert-toast.warn::before { background: #f59e0b; }
.dashboard-alert-toast.success::before { background: #10b981; }
.dashboard-alert-toast.error::before { background: #ef4444; }

.dashboard-alert-toast-title {
    font-weight: 700;
    color: #fff;
    margin-bottom: 0.35rem;
}

.dashboard-alert-toast-message {
    color: var(--muted);
    font-size: 0.93rem;
    line-height: 1.45;
    word-break: break-word;
}

.dashboard-alert-toast-actions {
    margin-top: 0.7rem;
    display: flex;
    justify-content: flex-end;
}

.glass-morphism {
    background: rgba(11, 18, 32, 0.8) !important;
    backdrop-filter: blur(20px) saturate(160%) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

/* Lists */
.list-none {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Back to Top */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 44px;
    height: 44px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(20px);
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    background: #4752c4;
    transform: translateY(-5px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

@media (max-width: 768px) {
    .back-to-top {
        bottom: 1.5rem;
        right: 1.5rem;
        width: 40px;
        height: 40px;
    }
}
