/**
 * TACSTAT Frontend Styles
 * Uses CSS variables for customizable theming
 */

/* Wrapper */
.tacstat-wrapper {
    background: var(--tacstat-bg, transparent);
    color: var(--tacstat-text, #ffffff);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    padding: 20px;
    border-radius: 8px;
    max-width: 100%;
    overflow-x: auto;
}

/* Squadron Selector */
.tacstat-squadron-selector {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.tacstat-squadron-selector label {
    font-weight: 600;
    color: var(--tacstat-text);
}

.tacstat-squadron-dropdown {
    padding: 10px 15px;
    border-radius: 6px;
    border: 1px solid var(--tacstat-border);
    background: var(--tacstat-row-bg);
    color: var(--tacstat-text);
    font-size: 14px;
    min-width: 200px;
    cursor: pointer;
}

.tacstat-squadron-dropdown:focus {
    outline: none;
    border-color: var(--tacstat-accent);
}

/* Squadron Header */
.tacstat-squadron-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px;
    background: var(--tacstat-header-bg);
    border-radius: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.tacstat-squadron-logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    border-radius: 8px;
}

.tacstat-squadron-info {
    flex: 1;
    min-width: 200px;
}

.tacstat-squadron-name {
    margin: 0 0 5px 0;
    font-size: 24px;
    font-weight: 700;
    color: var(--tacstat-gold);
}

.tacstat-squadron-desc {
    margin: 0 0 5px 0;
    opacity: 0.8;
    font-size: 14px;
}

.tacstat-pilot-count {
    margin: 0;
    font-size: 13px;
    color: var(--tacstat-accent);
}

/* Summary Cards */
.tacstat-summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.tacstat-summary-card {
    background: var(--tacstat-row-bg);
    border: 1px solid var(--tacstat-border);
    border-radius: 8px;
    padding: 15px;
    text-align: center;
}

.tacstat-summary-value {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: var(--tacstat-accent);
    line-height: 1.2;
}

.tacstat-summary-value.tacstat-kills {
    color: var(--tacstat-kills);
}

.tacstat-summary-label {
    display: block;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.7;
    margin-top: 5px;
}

/* Table */
.tacstat-table-wrapper {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--tacstat-border);
}

.tacstat-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    min-width: 700px;
}

.tacstat-table thead {
    background: var(--tacstat-header-bg);
}

.tacstat-table th {
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--tacstat-text);
    border-bottom: 2px solid var(--tacstat-border);
    white-space: nowrap;
}

.tacstat-table th.tacstat-col-rank,
.tacstat-table th.tacstat-col-time,
.tacstat-table th.tacstat-col-missions,
.tacstat-table th.tacstat-col-kills,
.tacstat-table th.tacstat-col-deaths,
.tacstat-table th.tacstat-col-kd,
.tacstat-table th.tacstat-col-a2a,
.tacstat-table th.tacstat-col-a2g,
.tacstat-table th.tacstat-col-accuracy {
    text-align: center;
}

.tacstat-table tbody tr {
    background: var(--tacstat-row-bg);
    border-bottom: 1px solid var(--tacstat-border);
    transition: background-color 0.2s ease;
    cursor: pointer;
}

.tacstat-table tbody tr:hover {
    background: var(--tacstat-row-hover);
}

.tacstat-table td {
    padding: 12px 15px;
    color: var(--tacstat-text);
}

.tacstat-table td.tacstat-col-rank,
.tacstat-table td.tacstat-col-time,
.tacstat-table td.tacstat-col-missions,
.tacstat-table td.tacstat-col-kills,
.tacstat-table td.tacstat-col-deaths,
.tacstat-table td.tacstat-col-kd,
.tacstat-table td.tacstat-col-a2a,
.tacstat-table td.tacstat-col-a2g,
.tacstat-table td.tacstat-col-accuracy {
    text-align: center;
}

/* Rank badges */
.tacstat-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 12px;
}

.tacstat-rank-1 {
    background: linear-gradient(135deg, #ffd700, #ffaa00);
    color: #000;
}

.tacstat-rank-2 {
    background: linear-gradient(135deg, #c0c0c0, #a0a0a0);
    color: #000;
}

.tacstat-rank-3 {
    background: linear-gradient(135deg, #cd7f32, #a0522d);
    color: #fff;
}

/* Pilot name */
.tacstat-pilot-name {
    display: block;
    font-weight: 600;
    color: var(--tacstat-gold);
}

.tacstat-pilot-aircraft {
    display: block;
    font-size: 11px;
    opacity: 0.6;
    margin-top: 2px;
}

/* Colored stats */
.tacstat-kills {
    color: var(--tacstat-kills) !important;
    font-weight: 600;
}

.tacstat-deaths {
    color: var(--tacstat-deaths) !important;
}

.tacstat-accuracy {
    color: var(--tacstat-accent) !important;
    font-weight: 600;
}

/* No data message */
.tacstat-no-data {
    text-align: center;
    padding: 40px 20px;
    opacity: 0.7;
    font-style: italic;
}

/* Modal */
.tacstat-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.tacstat-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
}

.tacstat-modal-content {
    position: relative;
    background: var(--tacstat-header-bg, rgba(22, 27, 34, 0.95));
    border: 1px solid var(--tacstat-border);
    border-radius: 12px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    color: var(--tacstat-text);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

.tacstat-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 28px;
    color: var(--tacstat-text);
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
}

.tacstat-modal-close:hover {
    opacity: 1;
}

.tacstat-modal-body {
    padding: 30px;
}

/* Modal Content */
.tacstat-pilot-detail-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--tacstat-border);
}

.tacstat-pilot-photo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--tacstat-gold);
}

.tacstat-pilot-photo-placeholder {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--tacstat-row-bg);
    border: 3px solid var(--tacstat-gold);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 700;
    color: var(--tacstat-gold);
}

.tacstat-pilot-detail-info h3 {
    margin: 0 0 5px 0;
    font-size: 24px;
    color: var(--tacstat-gold);
}

.tacstat-pilot-detail-info p {
    margin: 0;
    font-size: 13px;
    opacity: 0.7;
}

/* Stats grid in modal */
.tacstat-detail-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 25px;
}

.tacstat-detail-stat {
    background: var(--tacstat-row-bg);
    border-radius: 8px;
    padding: 15px;
    text-align: center;
}

.tacstat-detail-stat-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: var(--tacstat-accent);
}

.tacstat-detail-stat-label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.6;
    margin-top: 5px;
}

/* Sections in modal */
.tacstat-detail-section {
    margin-bottom: 20px;
}

.tacstat-detail-section h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--tacstat-accent);
    border-bottom: 1px solid var(--tacstat-border);
    padding-bottom: 8px;
}

.tacstat-detail-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--tacstat-border);
    font-size: 14px;
}

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

.tacstat-detail-row-label {
    opacity: 0.7;
}

.tacstat-detail-row-value {
    font-weight: 600;
}

/* Loading state */
.tacstat-loading {
    text-align: center;
    padding: 40px;
}

.tacstat-loading::after {
    content: '';
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid var(--tacstat-border);
    border-top-color: var(--tacstat-accent);
    border-radius: 50%;
    animation: tacstat-spin 1s linear infinite;
}

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

/* Responsive */
@media (max-width: 1024px) {
    .tacstat-table {
        font-size: 13px;
        min-width: 800px;
    }
    
    .tacstat-table th,
    .tacstat-table td {
        padding: 10px 8px;
    }
}

@media (max-width: 768px) {
    .tacstat-squadron-header {
        flex-direction: column;
        text-align: center;
    }
    
    .tacstat-summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .tacstat-detail-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .tacstat-modal-body {
        padding: 20px;
    }
    
    .tacstat-table {
        font-size: 12px;
        min-width: 700px;
    }
    
    .tacstat-table th,
    .tacstat-table td {
        padding: 8px 6px;
    }
    
    /* Hide less important columns on medium screens */
    .tacstat-col-missions {
        display: none;
    }
}

@media (max-width: 600px) {
    /* Hide more columns on small screens */
    .tacstat-col-a2a,
    .tacstat-col-a2g {
        display: none;
    }
    
    .tacstat-table {
        min-width: 500px;
    }
}

@media (max-width: 480px) {
    .tacstat-wrapper {
        padding: 10px;
    }
    
    .tacstat-summary-cards {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    
    .tacstat-summary-card {
        padding: 10px;
    }
    
    .tacstat-summary-value {
        font-size: 22px;
    }
    
    /* Hide even more on very small screens */
    .tacstat-col-kd,
    .tacstat-col-accuracy {
        display: none;
    }
    
    .tacstat-table {
        min-width: 350px;
        font-size: 11px;
    }
    
    .tacstat-table th,
    .tacstat-table td {
        padding: 6px 4px;
    }
}
