/* Global Main Body Styling */
body {
    /* Guild Theme: Dark/Gold */
    --tg-theme-bg-color: #212121;
    --tg-theme-secondary-bg-color: #2c2c2c;
    --tg-theme-text-color: #e0e0e0;
    --tg-theme-hint-color: #888;
    --tg-theme-button-color: #D4AF37;
    --tg-theme-button-text-color: #000;

    background-color: var(--tg-theme-bg-color);
    color: var(--tg-theme-text-color);
    padding: 8px;
    font-size: 13px;
    color-scheme: dark;
}

@media (min-width: 801px) {
    .app-container {
        border-left: 1px solid #333;
        border-right: 1px solid #333;
        min-height: 100vh;
        background-color: var(--tg-theme-bg-color, #212121);
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
    }

    body {
        /* Lighter overlay for visibility on dark bg */
        background-image: linear-gradient(rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.9)), url('../img/clan_logo.png');
        background-size: cover;
        background-position: center;
        background-attachment: fixed;
        /* Removed blend-mode overlay to avoid double darkening */
    }
}

/* Стили для верхней навигации */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 0 5px;
}

.nav-link-custom {
    text-decoration: none;
    font-weight: bold;
    margin-right: 15px;
    color: var(--tg-theme-hint-color, #999);
    border-bottom: 2px solid transparent;
    padding-bottom: 2px;
}

.nav-link-custom.active {
    color: var(--tg-theme-button-color, #3390ec);
    border-bottom: 2px solid var(--tg-theme-button-color, #3390ec);
}

.last-update {
    font-size: 11px;
    color: #C5A065;
    text-align: right;
}

.brand-title,
.nav-tabs .nav-link.active span,
table.dataTable thead th span,
.gold-text-icon {
    font-weight: bold;
    /* font-size: 18px; Removed global size */

    /* Fallback */
    color: #D4AF37;

    background: linear-gradient(to bottom,
            #BF953F,
            #FCF6BA,
            #B38728,
            #FBF5B7,
            #AA771C);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: none;
    filter: drop-shadow(0px 1px 1px rgba(0, 0, 0, 0.5));
    font-family: 'Times New Roman', serif;
    letter-spacing: 0.5px;
}



.brand-title {
    font-size: 16px;
}

.nav-tabs .nav-link.active span {
    font-size: 14px;
}

table.dataTable thead th span {
    font-size: 12px;
}

.filter-card {
    background: var(--tg-theme-secondary-bg-color);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 10px;
    border: 1px solid #333;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.table-card {
    background: var(--tg-theme-secondary-bg-color);
    border-radius: 12px;
    padding: 5px;
    overflow: hidden;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border: 1px solid #333;
    border-top: none;
}

/* Table Loader Overlay */
#tableLoader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #212121;
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 12px;
}

.spinner-gold {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(212, 175, 55, 0.3);
    border-radius: 50%;
    border-top-color: #D4AF37;
    animation: spin 1s ease-in-out infinite;
}

.text-gold {
    color: #D4AF37;
    font-weight: bold;
}

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

.nav-tabs {
    border-bottom: 1px solid #333;
}

.nav-tabs .nav-link {
    color: #C5A065;
    cursor: pointer;
    border: 1px solid transparent;
    border-bottom: none;
}

.nav-tabs .nav-link:hover {
    border-color: #333 #333 #212121;
    /* Hover effect */
    color: var(--tg-theme-text-color);
}

.nav-tabs .nav-link.active {
    font-weight: bold;
    background-color: var(--tg-theme-secondary-bg-color);
    /* color handled by gradient rule above */
    border-color: #333 #333 var(--tg-theme-secondary-bg-color);
}

/* Цвета ячеек */
.stage-cell {
    text-align: center;
    font-weight: bold;
    color: #ddd;
}

.done {
    color: #198754;
    background-color: rgba(25, 135, 84, 0.1);
}

.dance {
    color: #d63384;
    background-color: rgba(214, 51, 132, 0.1);
}

.adept {
    color: #0d6efd;
    background-color: rgba(13, 110, 253, 0.1);
}

.btn-preset {
    font-size: 11px;
    padding: 4px 8px;
}

/* Цветовая кодировка событий истории */
.type-6 {
    color: green;
    font-weight: bold;
}

/* Вступил */
.type-8,
.type-10 {
    color: red;
    font-weight: bold;
}

/* Вышел / Изгнал */
.type-9 {
    color: #d35400;
}

/* Должность */

/* Table Styles */
table.dataTable {
    color: var(--tg-theme-text-color) !important;
}

/* DataTables Search Label */
.dataTables_wrapper .dataTables_filter {
    color: #C5A065;
}


/* --- Gaming Dashboard Table Styles --- */

/* 1. Remove Borders & Reset */
table.dataTable,
table.dataTable td,
table.dataTable th,
.dataTables_wrapper {
    border: none !important;
    border-bottom: none !important;
    background-color: #212121 !important;
}

/* 2. Header Panel Style */
table.dataTable thead th {
    background-color: #1a1a1a;
    color: #C5A065;
    font-size: 14px;
    font-weight: bold;
    text-transform: uppercase;
    text-align: center;
    /* Center headers */
    padding: 12px 2px;
    border-bottom: 1px solid #C5A065 !important;
    box-shadow: 0 4px 6px -4px rgba(0, 0, 0, 0.5);
}

/* ... */

/* Elegant font for table numbers (Stages) */
.stage-cell {
    font-family: 'Times New Roman', serif;
    font-size: 14px;
    letter-spacing: 0.5px;
    text-align: center;
    /* Center data */
}

/* 3. Zebra Striping & Body Styles */
table.dataTable tbody tr {
    background-color: #212121 !important;
    /* Odd rows (default) */
    transition: background-color 0.2s ease, transform 0.1s ease;
}

table.dataTable tbody tr:nth-child(even) {
    background-color: #2c2c2c !important;
    /* Even rows (lighter) */
}

/* 4. Hover Effects */
table.dataTable tbody tr:hover {
    background-color: #383838 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    /* Lift effect */
    transform: translateY(-1px);
    z-index: 1;
    position: relative;
}

/* 5. Cell Styling */
table.dataTable tbody td {
    padding: 8px 2px;
    background-color: transparent !important;
    color: #C5A065 !important;
    vertical-align: middle;
    border-top: 1px solid rgba(255, 255, 255, 0.03) !important;
    /* Extremely subtle divider */
}

/* Remove default DataTable stripe classes if they interfere */
table.dataTable.stripe tbody tr.odd,
table.dataTable.display tbody tr.odd {
    background-color: #212121 !important;
}

.class-icon {
    width: 20px;
    height: 20px;
    vertical-align: middle;
    margin-right: 4px;
    object-fit: contain;
}

.dropdown-menu-custom {
    max-height: 300px;
    overflow-y: auto;
    min-width: 250px;
    max-width: 320px;
    padding: 8px;
    background-color: #2c2c2c;
    /* Dark dropdown */
    border: 1px solid #444;
}

.dropdown-menu-custom .dropdown-item,
.dropdown-menu-custom li,
.dropdown-menu-custom .form-check-label {
    color: #C5A065;
}

.dropdown-menu-custom .dropdown-item:hover {
    background-color: #333;
    color: #E6C87C;
}

.form-control,
.form-select {
    background-color: #212121;
    border: 1px solid #444;
    color: #C5A065;
}

.form-control:focus,
.form-select:focus {
    background-color: #212121;
    color: #C5A065;
    border-color: var(--tg-theme-button-color);
    box-shadow: 0 0 0 0.25rem rgba(218, 165, 32, 0.25);
    /* Gold glow */
}

/* Checkbox styling fix for dark mode */
.form-check-input {
    background-color: #444;
    border-color: #666;
}

.form-check-input:checked {
    background-color: var(--tg-theme-button-color);
    border-color: var(--tg-theme-button-color);
}

/* Color the calendar icon gold using custom SVG */
input[type="date"]::-webkit-calendar-picker-indicator {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23C5A065' viewBox='0 0 24 24'%3E%3Cpath d='M20 3h-1V1h-2v2H7V1H5v2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 18H4V8h16v13z'/%3E%3C/svg%3E");
    cursor: pointer;
    /* Reset filter if it was applied */
    filter: none;
}

.form-check-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    width: 100%;
    padding: 6px 10px;
    margin: 0;
    color: var(--tg-theme-text-color);
}

.form-check.hover-bg:hover {
    background-color: rgba(255, 255, 255, 0.05);
    /* Hover effect for class items */
}

.class-checkbox {
    margin-right: 12px;
    margin-left: 0 !important;
    float: none !important;
}

/* Fix for Dropdown Checkboxes Overflow */
.dropdown-menu-custom .form-check {
    padding-left: 0;
    /* Reset default padding */
    display: flex;
    align-items: center;
}

.dropdown-menu-custom .form-check-input {
    margin-left: 0 !important;
    /* Reset default negative margin */
    margin-right: 10px;
    flex-shrink: 0;
}

/* Modals for Dark Theme */
.modal-content {
    background-color: #212121;
    color: var(--tg-theme-text-color) !important;
    border: 1px solid #444;
}

.modal-header,
.modal-footer {
    border-color: #333;
}

.btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
    /* Make close button white */
}

/* App Container for Desktop Limiting */
.app-container {
    max-width: 800px !important;
    margin: 0 auto !important;
    width: 100%;
}

@media (min-width: 801px) {
    .app-container {
        border-left: 1px solid #333;
        border-right: 1px solid #333;
        min-height: 100vh;
        background-color: var(--tg-theme-bg-color, #212121);
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
    }
}

/* Sticky Footer for Dropdown */
.sticky-footer {
    position: sticky;
    bottom: -8px;
    /* Sticks to the very bottom, covering padding */
    margin: 5px -8px -8px -8px;
    /* Pulls it out to the edges of padding */
    padding: 10px 8px;
    /* Inner padding for the button */
    background-color: #2c2c2c;
    z-index: 100;
    border-top: 1px solid #444;
}

/* Custom Gold Buttons */
.btn-gold-outline {
    background: linear-gradient(#2c2c2c, #2c2c2c) padding-box,
        linear-gradient(to bottom, #8A6E2F, #C5A065, #8A6E2F, #D4AF37, #6B5522) border-box;
    border: 1px solid transparent;
    color: #C5A065;
    /* Matching the highlight color */
    transition: all 0.3s ease;
}

/* Active state can remain filled or distinct */
.btn-gold-outline:active,
.btn-gold-outline.active {
    background: linear-gradient(#2c2c2c, #2c2c2c) padding-box,
        linear-gradient(to bottom, #8A6E2F, #C5A065, #8A6E2F, #D4AF37, #6B5522) border-box;
    color: #C5A065;
    box-shadow: inset 0 0 10px rgba(197, 160, 101, 0.2);
}

.btn-gold-outline:hover,
.btn-gold-outline:focus {
    /* Hover keeps dark background, but border glimmers */
    background: linear-gradient(#2c2c2c, #2c2c2c) padding-box,
        linear-gradient(to bottom, #C5A065, #E6C87C, #C5A065, #F0D88B, #8A6E2F) border-box;
    color: #E6C87C;
    border-color: transparent;
    box-shadow: 0 0 10px rgba(197, 160, 101, 0.4);
}

.btn-gold-filled {
    background: linear-gradient(to bottom, #FBF5B7, #D4AF37, #AA771C, #BF953F);
    color: #000;
    border: 1px solid #FBF5B7;
    font-weight: bold;
    transition: all 0.3s ease;
}

.btn-gold-filled:hover,
.btn-gold-filled:active,
.btn-gold-filled:focus {
    background: linear-gradient(to bottom, #BF953F, #FCF6BA, #B38728, #FBF5B7, #AA771C);
    color: #000;
    border-color: #B38728;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.6);
}

/* Override default bootstrap primary if needed, or just use custom class */
.btn-check:checked+.btn-gold-outline {
    background: linear-gradient(to bottom, #BF953F, #FCF6BA, #B38728, #FBF5B7, #AA771C) padding-box,
        linear-gradient(to bottom, #BF953F, #FCF6BA, #B38728, #FBF5B7, #AA771C) border-box;
    color: #000;
    color: #000;
}

/* Custom Scrollbar for Dropdown (and global) */
.dropdown-menu-custom,
body {
    scrollbar-width: thin;
    scrollbar-color: #8A6E2F #222;
}

.dropdown-menu-custom::-webkit-scrollbar {
    width: 8px;
}

.dropdown-menu-custom::-webkit-scrollbar-track {
    background: #222;
    border-radius: 4px;
}

.dropdown-menu-custom::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 4px;
    border: 1px solid #222;
}

.dropdown-menu-custom::-webkit-scrollbar-thumb:hover {
    background: #8A6E2F;
}

/* Global scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #1a1a1a;
}

::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 5px;
    border: 2px solid #1a1a1a;
}

::-webkit-scrollbar-thumb:hover {
    background: #8A6E2F;
}

/* Elegant font for table numbers (Stages) */
.stage-cell {
    font-family: 'Times New Roman', serif;
    font-size: 14px;
    letter-spacing: 0.5px;
    text-align: center;
}

/* Stage Column Color Gradients (High Specificity) */
table.dataTable tbody td.stage-col-1 {
    color: #888888 !important;
}

/* Gray - Starter */
table.dataTable tbody td.stage-col-2 {
    color: #A09580 !important;
}

/* Bronze-ish */
table.dataTable tbody td.stage-col-3 {
    color: #B8A570 !important;
}

/* Pale Gold */
table.dataTable tbody td.stage-col-4 {
    color: #D0B560 !important;
}

/* Soft Gold */
table.dataTable tbody td.stage-col-5 {
    color: #E8C550 !important;
}

/* Bright Gold */
table.dataTable tbody td.stage-col-6 {
    color: #C5A065 !important;
}

/* Standard Theme Gold */
table.dataTable tbody td.stage-col-7 {
    color: #DA9100 !important;
}

/* Deep Saturated Gold (Amber) */

/* Nickname Valor Tiers (High Specificity) */
table.dataTable tbody td.nick-tier-0 {
    color: #888888 !important;
}

/* 0 Valor - Gray */
table.dataTable tbody td.nick-tier-1 {
    color: #A09580 !important;
}

/* Bottom 20% - Bronze */
table.dataTable tbody td.nick-tier-2 {
    color: #B8A570 !important;
}

/* 20-40% - Pale Gold */
table.dataTable tbody td.nick-tier-3 {
    color: #D0B560 !important;
}

/* 40-60% - Soft Gold */
table.dataTable tbody td.nick-tier-4 {
    color: #E8C550 !important;
}

/* 60-80% - Bright Gold */
table.dataTable tbody td.nick-tier-5 {
    color: #DA9100 !important;
    font-weight: bold;
}

/* Top 20% - Amber/Bold */

/* Tier 7 - Amber/No Bold (Short Duration) */
table.dataTable tbody td.nick-tier-7 {
    color: #DA9100 !important;
    font-weight: normal !important;
}

/* Gold Tier Row Coloring (Contributions Tab) */
table.dataTable tbody tr.gold-tier-0 td:first-child {
    color: #888888 !important;
}

table.dataTable tbody tr.gold-tier-1 td:first-child {
    color: #A09580 !important;
}

table.dataTable tbody tr.gold-tier-2 td:first-child {
    color: #B8A570 !important;
}

table.dataTable tbody tr.gold-tier-3 td:first-child {
    color: #D0B560 !important;
}

table.dataTable tbody tr.gold-tier-4 td:first-child {
    color: #E8C550 !important;
}

table.dataTable tbody tr.gold-tier-5 td:first-child {
    color: #DA9100 !important;
    font-weight: bold;
}

table.dataTable tbody tr.gold-tier-7 td:first-child {
    color: #DA9100 !important;
    font-weight: normal !important;
}

/* Total Row Footer */
.table-total-row,
.table-total-row td {
    background-color: #1a1a1a !important;
    color: #C5A065 !important;
    font-weight: bold;
    border-top: 2px solid #C5A065 !important;
}

/* Metallic Shimmer Effect for Elites */
@keyframes metallicShine {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* Apply to Nickname Tier 6 (Top 10) */
table.dataTable tbody td.nick-tier-6,
table.dataTable tbody tr.gold-tier-6 td:first-child {
    background: linear-gradient(to right,
            #BF953F 20%,
            #FCF6BA 40%,
            #B38728 60%,
            #FBF5B7 80%,
            #AA771C 100%);
    background-size: 200% auto;
    color: #000 !important;
    /* Fallback */
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: metallicShine 8s linear infinite;
    text-shadow: 0 0 10px rgba(197, 160, 101, 0.4);
    font-weight: 800 !important;
}

/* Tier 5 (Top 20% - Top 10) - Static Amber */
table.dataTable tbody td.nick-tier-5,
table.dataTable tbody tr.gold-tier-5 td {
    color: #DA9100 !important;
    font-weight: bold;
    text-shadow: none;
    -webkit-text-fill-color: #DA9100;
}

/* Hide DataTables Sorting Arrows */
table.dataTable thead th.sorting:before,
table.dataTable thead th.sorting:after,
table.dataTable thead th.sorting_asc:before,
table.dataTable thead th.sorting_asc:after,
table.dataTable thead th.sorting_desc:before,
table.dataTable thead th.sorting_desc:after {
    display: none !important;
}

/* Remove DataTables padding for sorting arrows */
table.dataTable thead th.sorting,
table.dataTable thead th.sorting_asc,
/* Table Loader */
/* Remove DataTables padding for sorting arrows */
table.dataTable thead th.sorting,
table.dataTable thead th.sorting_asc,
table.dataTable thead th.sorting_desc {
    padding-right: 8px !important;
}
/* Responsive Table Padding */
@media (min-width: 768px) {
    table.dataTable thead th {
        padding: 12px 8px !important;
    }
    table.dataTable tbody td {
        padding: 10px 8px !important;
    }
}
