:root {
    /* Colors - Light Mode */
    --bg-color: #f9fafb;
    --surface-color: #ffffff;
    --surface-secondary: #f3f4f6;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --accent-color: #7c3aed;
    --accent-soft: #ede9fe;
    --border-color: #e5e7eb;
    --danger-color: #ef4444;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    --header-height: 60px;
    --nav-height: 60px;
}

.history-section {
    margin-top: 10px;
    background: var(--surface-color);
    border-radius: 16px;
    padding: 16px;
    border: 1px solid var(--border-color);
}

.history-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-item {
    padding-bottom: 12px;
    border-bottom: 0.5px solid var(--border-color);
}

.history-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 4px;
}

.history-type {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 4px;
}

.type-mute { background: var(--accent-soft); color: var(--accent-color); }
.type-unmute { background: #dcfce7; color: #166534; }
.type-ban { background: #fee2e2; color: #991b1b; }
.type-unban { background: #fef9c3; color: #854d0e; }
.type-warning { background: #ffedd5; color: #9a3412; }
.type-badword { background: #ffe4e6; color: #9f1239; }

.history-delete-btn {
    background: none;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, opacity 0.2s;
    opacity: 0.6;
}

.history-delete-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.history-eye-btn {
    background: var(--surface-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--accent-color);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.history-eye-btn:hover {
    background: var(--accent-soft);
    border-color: var(--accent-color);
}

.history-eye-btn i {
    font-size: 14px;
}

.history-date {
    font-size: 12px;
    color: var(--text-tertiary);
}

.history-comment {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.4;
    word-break: break-word;
}

.comment-input-wrapper {
    margin-top: 12px;
    width: 100%;
}

.comment-textarea {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--surface-secondary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    resize: none;
    transition: border-color 0.2s;
}

.comment-textarea:focus {
    outline: none;
    border-color: var(--accent-color);
}

/* Auto Theme (System) */
@media (prefers-color-scheme: dark) {
    body.auto-theme {
        --bg-color: #000000;
        --surface-color: #1c1c1e;
        --surface-secondary: #2c2c2e;
        --text-primary: #ffffff;
        --text-secondary: #a1a1aa;
        --text-tertiary: #71717a;
        --accent-color: #8b5cf6;
        --accent-soft: #2e1065;
        --border-color: #38383a;
        --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
        --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
        --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6);
    }
}

/* Manual Dark Theme */
body.dark-theme {
    --bg-color: #000000;
    --surface-color: #1c1c1e;
    --surface-secondary: #2c2c2e;
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --text-tertiary: #71717a;
    --accent-color: #8b5cf6;
    --accent-soft: #2e1065;
    --border-color: #38383a;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow-x: hidden;
    line-height: 1.5;
    transition: background-color var(--transition-normal);
    min-height: 100vh;
}

/* Layout */
.app-wrapper {
    max-width: 500px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-color);
    position: relative;
    padding-bottom: calc(var(--nav-height) + var(--safe-area-bottom) + 20px);
}

/* Header */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--surface-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: calc(12px + var(--safe-area-top)) 16px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 0.5px solid var(--border-color);
}

.header-left, .header-right {
    min-width: 44px;
    display: flex;
    align-items: center;
}

.header-title {
    font-size: 17px;
    font-weight: 600;
    flex: 1;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.back-btn, .icon-btn {
    background: none;
    border: none;
    color: var(--accent-color);
    font-size: 18px;
    cursor: pointer;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
    text-decoration: none;
}

.back-btn:active, .icon-btn:active {
    background-color: var(--surface-secondary);
}

.icon-btn.active {
    background-color: var(--accent-color) !important;
    color: white !important;
}

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 500px;
    background-color: var(--surface-color);
    border-top: 0.5px solid var(--border-color);
    display: flex;
    padding-bottom: var(--safe-area-bottom);
    height: calc(var(--nav-height) + var(--safe-area-bottom));
    z-index: 100;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    text-decoration: none;
    font-size: 10px;
    font-weight: 500;
    gap: 4px;
}

.nav-item.active {
    color: var(--accent-color);
}

.nav-item i {
    font-size: 20px;
}

/* Lists & Cards */
.container {
    padding: 16px;
}

.card-link {
    display: flex;
    align-items: center;
    gap: 16px;
    background-color: var(--surface-color);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    border: 0.5px solid var(--border-color);
    text-decoration: none;
    color: inherit;
    transition: transform 0.1s;
}

.card-link:active {
    transform: scale(0.98);
    background-color: var(--surface-secondary);
}

.card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background-color: var(--accent-soft);
    color: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.card-content {
    flex: 1;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.card-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}

.filter-group label {
    user-select: none;
}

.icon-btn:active {
    opacity: 0.7;
    transform: scale(0.95);
}

/* User List */
/* Filter Chips */
.filter-container {
    padding: 12px 16px;
    background-color: var(--bg-color);
    position: sticky;
    top: 60px;
    z-index: 10;
    border-bottom: 0.5px solid var(--border-color);
}

.filter-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.filter-scroll::-webkit-scrollbar {
    display: none;
}

.filter-chip {
    padding: 6px 14px;
    background-color: var(--surface-secondary);
    border: 0.5px solid var(--border-color);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-chip.active {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* User Badges */
.user-name {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.name-text {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-badges {
    display: flex;
    align-items: center;
    gap: 4px;
}

.mini-badge {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}

.mini-badge.mute {
    background-color: var(--accent-soft);
    color: var(--accent-color);
}

.mini-badge.ban {
    background-color: var(--danger-color);
    color: white;
}

.mini-badge.left {
    background-color: var(--surface-secondary);
    color: var(--text-tertiary);
    border: 0.5px solid var(--border-color);
}

.user-row {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: var(--surface-color);
    border-bottom: 0.5px solid var(--border-color);
    text-decoration: none;
    color: inherit;
}

.user-row:active {
    background-color: var(--surface-secondary);
}

.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--accent-soft);
    color: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-info {
    flex: 1;
}

.user-name {
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.role-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    background-color: var(--surface-secondary);
    color: var(--text-secondary);
    font-weight: 700;
    text-transform: uppercase;
}

.role-badge.admin { background-color: #fef3c7; color: #92400e; }
.role-badge.danger { background-color: #fee2e2; color: #991b1b; }
.role-badge.success { background-color: #dcfce7; color: #166534; }
.role-badge.warning { background-color: #ffedd5; color: #9a3412; }
.role-badge.secondary { background-color: #f3f4f6; color: #4b5563; }

.active-warn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background-color: #f59e0b;
    color: white;
    border-radius: 4px;
    font-size: 10px;
    margin-left: 6px;
    vertical-align: middle;
}

.user-username {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Search */
.search-container {
    padding: 12px 16px;
    background-color: var(--bg-color);
    position: sticky;
    top: var(--header-height);
    z-index: 90;
}

.search-bar {
    background-color: var(--surface-secondary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    padding: 8px 12px;
    gap: 8px;
}

.search-bar input {
    background: none;
    border: none;
    color: var(--text-primary);
    flex: 1;
    font-size: 15px;
    outline: none;
}

/* Details */
.details-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px 16px 24px;
    background-color: var(--surface-color);
    margin-bottom: 12px;
}

.avatar-large {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: var(--accent-soft);
    color: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 16px;
    box-shadow: var(--shadow-md);
}

.details-name { 
    font-size: 20px; 
    font-weight: 700; 
    word-break: break-word; 
    overflow-wrap: break-word;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}
.details-username { 
    font-size: 15px; 
    color: var(--text-secondary); 
    margin-bottom: 8px; 
    word-break: break-all;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

.copy-mini-btn {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.copy-mini-btn:hover {
    color: var(--accent-color);
}

.copy-mini-btn:active {
    transform: scale(0.9);
}

.tg-link-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background-color: #0088cc;
    color: white;
    padding: 12px 20px;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 600;
    margin: 10px 16px;
    transition: opacity 0.2s;
}

.tg-link-btn:hover {
    opacity: 0.9;
}

.tg-link-btn:active {
    transform: scale(0.98);
}

.info-section {
    background-color: var(--surface-color);
    margin: 0 16px;
    border-radius: 12px;
    padding: 16px;
    border: 0.5px solid var(--border-color);
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 0.5px solid var(--border-color);
}

.info-row:last-child { border-bottom: none; }
.info-label { color: var(--text-secondary); font-size: 14px; }
.info-value { font-weight: 500; font-size: 14px; }

.action-grid {
    display: flex;
    gap: 8px;
    padding: 16px;
    align-items: stretch;
}

.action-btn {
    flex: 1;
    background-color: var(--surface-color);
    border: 0.5px solid var(--border-color);
    padding: 12px 4px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: transform 0.1s;
    text-decoration: none;
    min-width: 0;
}

.action-btn span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    text-align: center;
}

.action-btn.warning {
    flex: 1.8;
}

.action-btn i { font-size: 18px; color: var(--accent-color); }
.action-btn.danger { color: var(--danger-color); }
.action-btn.danger i { color: var(--danger-color); }
.action-btn.warning { color: #f59e0b; }
.action-btn.warning i { color: #f59e0b; }

.btn {
    padding: 12px;
    border-radius: 10px;
    border: none;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}

.btn-primary { 
    background-color: var(--accent-color); 
    color: white; 
    transition: all 0.2s;
}

.btn-primary:active {
    opacity: 0.9;
    transform: scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}
.btn-secondary { background-color: var(--surface-secondary); color: var(--text-primary); }

/* Badges etc */
.badge-row {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--border-color);
}

.status-dot.active {
    background-color: var(--success-color);
    box-shadow: 0 0 4px var(--success-color);
}

/* Modal simple */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: none;
    backdrop-filter: blur(2px);
}
.modal-overlay.active { display: block; }

.mute-sheet {
    position: fixed; 
    bottom: 0; 
    left: 50%; 
    transform: translateX(-50%); 
    width: 100%; 
    max-width: 500px; 
    background: var(--surface-color); 
    border-radius: 20px 20px 0 0; 
    padding: 24px; 
    z-index: 1001;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
}

.mute-presets {
    display: grid; 
    grid-template-columns: 1fr 1fr 1fr; 
    gap: 10px; 
    margin-bottom: 20px;
}

.custom-duration-wrapper {
    display: flex; 
    gap: 8px; 
    margin-bottom: 20px;
}

.input-custom-time {
    flex: 2; 
    padding: 14px; 
    border-radius: 12px; 
    border: 1px solid var(--border-color); 
    background: var(--bg-color); 
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 500;
    outline: none;
    transition: border-color 0.2s;
}

.input-custom-time:focus {
    border-color: var(--accent-color);
}

.select-custom-unit {
    flex: 1;
    padding: 5px 36px 5px 14px;
    border-radius: 12px;
    border: 1px solid var(--border-color); 
    background: var(--bg-color); 
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 18px;
}

.highlight-time {
    color: var(--accent-color);
    font-weight: 700;
    background: var(--accent-soft);
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
    margin: 2px 0;
}

/* Custom Modal */
.custom-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.custom-modal-overlay.active {
    display: flex;
}

.custom-modal {
    background: var(--surface-color);
    width: 100%;
    max-width: 400px;
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    animation: modalSlideUp 0.3s ease-out;
}

@keyframes modalSlideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.custom-modal-header h3 {
    margin: 0 0 16px 0;
    text-align: center;
    font-size: 18px;
    color: var(--text-primary);
}

.custom-modal-body {
    margin-bottom: 24px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.5;
}

.custom-modal-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.custom-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-color);
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.custom-checkbox:checked {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

.custom-checkbox:checked::after {
    content: "\f00c";
    font: var(--fa-font-solid);
    font-weight: 900;
    color: white;
    font-size: 12px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Action Loader */
.action-loader-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.8);
    z-index: 3000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
}

.action-loader-overlay.active {
    display: flex;
}

.loader-content {
    text-align: center;
    color: white;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-left-color: var(--accent-color);
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 1s linear infinite;
}

/* Animations */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.fa-spin-once {
    animation: spin 0.6s linear infinite;
}

#loader-message {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}
