/* Admin Contests Panel Styles */

/* Base reset */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background: #1e1f22;
    color: #dbdee1;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Layout */
.admin-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.admin-sidebar {
    width: 260px;
    background: #2b2d31;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #3f4147;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #3f4147;
}

.sidebar-header h1 {
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.sidebar-header i {
    color: #f0b232;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #b5bac1;
    text-decoration: none;
    border-radius: 6px;
    margin-bottom: 4px;
    cursor: pointer;
}

.nav-item:hover {
    background: #36373d;
    color: #fff;
}

.nav-item.active {
    background: #404249;
    color: #fff;
}

.nav-item i {
    width: 20px;
    text-align: center;
}

.nav-item .badge {
    margin-left: auto;
    background: #5865f2;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.nav-item .badge.badge-urgent {
    background: #da373c;
}

.sidebar-footer {
    padding: 12px 8px;
    border-top: 1px solid #3f4147;
}

/* Main Content */
.admin-main {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.tab-content {
    display: none;
    flex-direction: column;
    height: 100%;
}

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

.content-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #3f4147;
    background: #2b2d31;
    gap: 12px;
}

.content-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: #fff;
    margin: 0;
}

.header-subtitle {
    width: 100%;
    font-size: 13px;
    color: #b5bac1;
    margin: 4px 0 0 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.content-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

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

.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: #b5bac1;
}

.form-input,
.filter-select {
    width: 100%;
    background: #1e1f22;
    border: 1px solid #3f4147;
    border-radius: 4px;
    padding: 8px 12px;
    color: #dbdee1;
    font-size: 14px;
    font-family: inherit;
}

.form-input:focus,
.filter-select:focus {
    outline: none;
    border-color: #5865f2;
}

.filter-select {
    min-width: 150px;
    width: auto;
}

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

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: #dbdee1;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    border: none;
    font-family: inherit;
}

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

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-icon {
    padding: 6px 8px;
    background: transparent;
    color: #b5bac1;
}

.btn-icon:hover {
    background: #36373d;
    color: #fff;
}

.btn-primary {
    background: #5865f2;
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: #4752c4;
}

.btn-secondary {
    background: #4e5058;
    color: #fff;
}

.btn-secondary:hover:not(:disabled) {
    background: #5d5f68;
}

.btn-success {
    background: #3ba55d;
    color: #fff;
}

.btn-success:hover:not(:disabled) {
    background: #2d8049;
}

.btn-danger {
    background: #da373c;
    color: #fff;
}

.btn-danger:hover:not(:disabled) {
    background: #c62e32;
}

.btn-purple {
    background: #9b59b6;
    color: #fff;
}

.btn-purple:hover:not(:disabled) {
    background: #8e44ad;
}

.btn-outline {
    background: transparent;
    border: 1px solid #5865f2;
    color: #5865f2;
}

.btn-outline:hover:not(:disabled) {
    background: #5865f2;
    color: #fff;
}

/* States */
.loading-state,
.empty-state,
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #b5bac1;
    text-align: center;
}

.loading-state i,
.empty-state i,
.error-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.error-state {
    color: #f23f43;
}

/* Search Form */
.search-form {
    background: #2b2d31;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 24px;
}

.search-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

.search-row:last-child {
    margin-bottom: 0;
}

.search-actions {
    display: flex;
    gap: 8px;
    padding-top: 8px;
}

/* Escalated Contests */
.escalated-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.escalated-card {
    background: #2b2d31;
    border-radius: 8px;
    padding: 20px;
    border-left: 4px solid #f0b232;
}

.escalated-card.warning {
    border-left-color: #f0b232;
}

.escalated-card.urgent {
    border-left-color: #ed4245;
}

.escalated-card.critical {
    border-left-color: #9b1c1f;
    background: #332929;
}

.escalated-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.escalated-title {
    font-size: 18px;
    font-weight: 600;
    color: #fff;
}

.escalated-urgency {
    font-size: 13px;
    font-weight: 600;
    color: #ed4245;
    background: rgba(237, 66, 69, 0.15);
    padding: 4px 10px;
    border-radius: 4px;
}

.escalated-info {
    margin-bottom: 16px;
}

.info-row {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    margin-bottom: 8px;
    font-size: 14px;
    color: #b5bac1;
}

.info-row i {
    color: #6d6f78;
    margin-right: 6px;
}

.escalated-actions {
    display: flex;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid #3f4147;
}

/* Contests Table */
.contests-table {
    background: #2b2d31;
    border-radius: 8px;
    overflow: hidden;
}

.contests-header {
    display: grid;
    grid-template-columns: 2fr 1fr 120px 100px 80px 120px 100px;
    gap: 12px;
    padding: 12px 16px;
    background: #1e1f22;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: #b5bac1;
}

.contest-row {
    display: grid;
    grid-template-columns: 2fr 1fr 120px 100px 80px 120px 100px;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid #3f4147;
    align-items: center;
}

.contest-row:last-child {
    border-bottom: none;
}

.contest-row:hover {
    background: #36373d;
}

.contest-title {
    color: #fff;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.contest-host {
    color: #b5bac1;
}

.contest-status {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 4px 8px;
    border-radius: 4px;
    text-align: center;
}

.status-open {
    background: rgba(59, 165, 93, 0.2);
    color: #3ba55d;
}

.status-closed {
    background: rgba(240, 178, 50, 0.2);
    color: #f0b232;
}

.status-completed {
    background: rgba(88, 101, 242, 0.2);
    color: #5865f2;
}

.status-cancelled {
    background: rgba(109, 111, 120, 0.2);
    color: #b5bac1;
}

.status-judging {
    background: rgba(235, 137, 33, 0.2);
    color: #eb8921;
}

.status-escalated,
.status-awaiting_admin {
    background: rgba(218, 55, 60, 0.2);
    color: #da373c;
}

.contest-budget,
.contest-entries,
.contest-deadline {
    color: #b5bac1;
}

.contest-actions {
    display: flex;
    gap: 4px;
}

/* Context Menu */
.context-menu {
    background: #2b2d31;
    border: 1px solid #3f4147;
    border-radius: 6px;
    padding: 6px;
    z-index: 1000;
    min-width: 160px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.context-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 12px;
    background: none;
    border: none;
    color: #dbdee1;
    font-size: 14px;
    cursor: pointer;
    border-radius: 4px;
    text-align: left;
}

.context-item:hover {
    background: #36373d;
}

.context-item.danger {
    color: #da373c;
}

.context-item.danger:hover {
    background: rgba(218, 55, 60, 0.15);
}

/* Audit Logs Table */
.audit-table {
    background: #2b2d31;
    border-radius: 8px;
    overflow: hidden;
}

.audit-header {
    display: grid;
    grid-template-columns: 160px 180px 120px 120px 1fr 140px;
    gap: 12px;
    padding: 12px 16px;
    background: #1e1f22;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: #b5bac1;
}

.audit-row {
    display: grid;
    grid-template-columns: 160px 180px 120px 120px 1fr 140px;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #3f4147;
    font-size: 14px;
}

.audit-row:last-child {
    border-bottom: none;
}

.audit-row.admin-action {
    background: rgba(88, 101, 242, 0.05);
}

.audit-action {
    color: #fff;
    font-weight: 500;
}

.audit-action i {
    margin-right: 6px;
    color: #5865f2;
}

.audit-contest a {
    color: #5865f2;
    text-decoration: none;
}

.audit-contest a:hover {
    text-decoration: underline;
}

.audit-user,
.audit-admin {
    color: #dbdee1;
}

.audit-details {
    color: #6d6f78;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.audit-date {
    color: #b5bac1;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px;
}

.pagination-info {
    color: #b5bac1;
    font-size: 14px;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
}

.modal-content {
    position: relative;
    background: #2b2d31;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    margin: auto;
    z-index: 1;
    top: auto;
    left: auto;
    transform: none;
}

.modal-content.modal-large {
    max-width: 800px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #3f4147;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
}

.modal-close {
    background: none;
    border: none;
    color: #b5bac1;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
}

.modal-close:hover {
    color: #fff;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid #3f4147;
}

.modal-footer .refund-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: auto;
    cursor: pointer;
    color: #b5bac1;
    font-size: 14px;
}

.modal-footer .refund-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.modal-footer .modal-actions {
    display: flex;
    gap: 8px;
}

.warning-text {
    color: #f0b232;
    background: rgba(240, 178, 50, 0.1);
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 16px;
}

.warning-text i {
    margin-right: 8px;
}

.preset-reasons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.preset-reason-btn {
    background: #3f4147;
    border: 1px solid #4f545c;
    color: #b5bac1;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}

.preset-reason-btn:hover {
    background: #4f545c;
    color: #fff;
}

.info-text {
    color: #5865f2;
    background: rgba(88, 101, 242, 0.1);
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 16px;
}

.info-text i {
    margin-right: 8px;
}

/* Contest Detail Modal */
.detail-section {
    margin-bottom: 24px;
}

.detail-section h4 {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    color: #b5bac1;
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid #3f4147;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-item.full-width {
    grid-column: span 2;
}

.detail-item label {
    font-size: 12px;
    color: #6d6f78;
    text-transform: uppercase;
}

.detail-item span {
    color: #dbdee1;
}

.detail-description {
    background: #1e1f22;
    padding: 12px;
    border-radius: 6px;
    white-space: pre-wrap;
    color: #dbdee1;
}

.status-badge {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 4px 8px;
    border-radius: 4px;
}

/* Participants List */
.participants-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.participant-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 12px;
    background: #1e1f22;
    border-radius: 6px;
}

.participant-item.winner {
    border: 1px solid #f0b232;
    background: rgba(240, 178, 50, 0.1);
}

.participant-user {
    font-weight: 500;
    color: #fff;
}

.participant-date,
.participant-files {
    font-size: 13px;
    color: #b5bac1;
}

.winner-badge {
    margin-left: auto;
    color: #f0b232;
    font-weight: 600;
    font-size: 13px;
}

.empty-text {
    color: #6d6f78;
    font-style: italic;
}

/* Audit Timeline */
.audit-timeline {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.timeline-item {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 8px 12px;
    background: #1e1f22;
    border-radius: 4px;
    font-size: 13px;
}

.timeline-action {
    font-weight: 500;
    color: #dbdee1;
}

.timeline-date {
    color: #6d6f78;
}

.timeline-details {
    width: 100%;
    color: #b5bac1;
}

.detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid #3f4147;
}

/* Select Winner Modal */
.participants-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.participant-card {
    background: #1e1f22;
    border: 2px solid transparent;
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
}

.participant-card:hover {
    border-color: #3f4147;
}

.participant-card.selected {
    border-color: #5865f2;
    background: rgba(88, 101, 242, 0.1);
}

.participant-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.participant-name {
    font-weight: 600;
    color: #fff;
}

.participant-joined {
    font-size: 12px;
    color: #6d6f78;
}

.participant-files-preview {
    font-size: 13px;
    color: #b5bac1;
    margin-bottom: 12px;
}

.participant-card .btn {
    width: 100%;
}

/* Responsive */
@media (max-width: 1200px) {
    .contests-header,
    .contest-row {
        grid-template-columns: 1.5fr 1fr 100px 80px 60px 100px 80px;
    }

    .audit-header,
    .audit-row {
        grid-template-columns: 140px 160px 100px 100px 1fr 120px;
    }
}

@media (max-width: 900px) {
    .admin-container {
        flex-direction: column;
    }

    .admin-sidebar {
        position: static;
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid #3f4147;
    }

    .admin-main {
        margin-left: 0;
    }

    .sidebar-nav {
        display: flex;
        overflow-x: auto;
        padding: 8px;
    }

    .nav-item {
        white-space: nowrap;
        margin-bottom: 0;
        margin-right: 4px;
    }

    .sidebar-footer {
        display: none;
    }

    .search-row {
        grid-template-columns: 1fr;
    }

    .contests-header,
    .contest-row {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .contests-header {
        display: none;
    }

    .contest-row {
        flex-direction: column;
        align-items: flex-start;
        padding: 16px;
    }

    .audit-header,
    .audit-row {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .audit-header {
        display: none;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .detail-item.full-width {
        grid-column: span 1;
    }

    .info-row {
        flex-direction: column;
        gap: 8px;
    }
}

/* ========== Admin Panel Placement Styles ========== */

/* Winners list in detail modal */
.winners-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.winner-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
}

.winner-badge.placement-1 {
    background: rgba(255, 215, 0, 0.1);
    color: #ffd700;
}

.winner-badge.placement-2 {
    background: rgba(192, 192, 192, 0.1);
    color: #c0c0c0;
}

.winner-badge.placement-3 {
    background: rgba(205, 127, 50, 0.1);
    color: #cd7f32;
}

/* Placement progress header in select winner modal */
.placement-progress-header {
    padding: 16px;
    background: linear-gradient(90deg, rgba(74, 158, 255, 0.1) 0%, transparent 100%);
    border-radius: 10px;
    margin-bottom: 20px;
    border: 1px solid rgba(74, 158, 255, 0.2);
}

.placement-progress-header h5 {
    margin: 0 0 12px 0;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
}

.placement-slots {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.placement-slots .slot {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    background: #1f1f1f;
    border: 1px solid #333;
    color: #666;
}

.placement-slots .slot.filled {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.3);
    color: #22c55e;
}

.placement-slots .slot.current {
    background: rgba(74, 158, 255, 0.15);
    border-color: #4a9eff;
    color: #4a9eff;
}

/* Participant card in select winner modal */
.participant-card {
    background: #1f1f1f;
    border: 1px solid #333;
    border-radius: 10px;
    padding: 16px;
    cursor: pointer;
}

.participant-card:hover {
    border-color: #555;
}

.participant-card.selected {
    border-color: #4a9eff;
    background: rgba(74, 158, 255, 0.05);
}

.participant-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.participant-name {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
}

.participant-joined {
    font-size: 12px;
    color: #666;
}

.participant-files-preview {
    font-size: 13px;
    color: #888;
    margin-bottom: 12px;
}

.select-participant-btn {
    width: 100%;
    padding: 10px;
    background: transparent;
    border: 1px solid #4a9eff;
    border-radius: 6px;
    color: #4a9eff;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.select-participant-btn:hover {
    background: rgba(74, 158, 255, 0.1);
}

.participant-card.selected .select-participant-btn {
    background: #4a9eff;
    color: #fff;
}

/* ========== Finalize Modal Styles ========== */

.finalize-summary {
    background: #1a1a1a;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.finalize-summary h4 {
    margin: 0 0 16px 0;
    font-size: 16px;
    color: #fff;
}

.finalize-summary .winner-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.finalize-summary .winner-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #252525;
    border-radius: 8px;
}

.finalize-summary .winner-item .prize {
    margin-left: auto;
    color: #22c55e;
    font-weight: 600;
}

.finalize-summary .total-info {
    padding-top: 12px;
    border-top: 1px solid #333;
    text-align: right;
    color: #22c55e;
}

/* Finalize option in select winner modal */
.finalize-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(34, 197, 94, 0.1);
    border-radius: 8px;
    margin-top: 12px;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.finalize-option span {
    color: #22c55e;
    font-size: 13px;
    font-weight: 500;
}

.placement-progress-header .hint {
    margin: 8px 0 0 0;
    font-size: 13px;
    color: #888;
}
