/*!
 * Details Page Styles
 * Optimized for performance and maintainability
 */

/* ==========================================================================
   1. CSS Variables (Custom Properties)
   ========================================================================== */

:root {
    --details-max-width: 1200px;
    --sidebar-width: 330px;
    --border-color: #ddd;
    --background-light: #f5f5f5;
    --background-white: #fff;
    --text-muted: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --map-bg: rgb(56, 63, 71);
    --table-hover: #f8f9fa;
    --table-stripe: #fdfdfd;
    --border-radius: 4px;
    --spacing-xs: 2px;
    --spacing-sm: 5px;
    --spacing-md: 10px;
    --spacing-lg: 15px;
    --spacing-xl: 20px;
}

/* ==========================================================================
   2. Utility Classes
   ========================================================================== */

.u-full-width { 
    width: 100%; 
    max-width: 100%; 
}

.u-box-border { 
    box-sizing: border-box; 
}

.u-no-wrap { 
    white-space: nowrap; 
}

.u-text-center { 
    text-align: center; 
}

.u-overflow-hidden { 
    overflow: hidden; 
}

.u-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   3. Base Layout & Container
   ========================================================================== */

.details-page {
    word-wrap: break-word;
    max-width: var(--details-max-width);
    margin: 0 auto;
    position: relative;
}

.details-page.container-fluid {
    padding: 0 var(--spacing-lg);
    box-sizing: border-box;
    max-width: var(--details-max-width);
    margin: 0 auto;
}

.details-content-wrapper {
    display: flex;
    flex-wrap: nowrap;
    margin: 0 -15px;
    width: calc(100% + 30px);
    min-height: 200px;
    align-items: flex-start;
}

.main {
    flex: 1;
    min-width: 0;
    max-width: calc(100% - 360px);
    overflow-x: auto;
    padding: 0 var(--spacing-lg);
    box-sizing: border-box;
}

.main > * {
    max-width: 100%;
    box-sizing: border-box;
}

.sidepanel {
    flex: 0 0 var(--sidebar-width);
    width: var(--sidebar-width);
    min-height: 200px;
    box-sizing: border-box;
}

.details-footer {
    margin-top: var(--spacing-xl);
    padding: var(--spacing-md);
    text-align: center;
}

/* ==========================================================================
   4. Typography & Title Styles
   ========================================================================== */

.title-container {
    padding: 0;
}

.title-container h1#details-title {
    font-size: 30px; /* Same as h2 to maintain similar visual size */
    margin: 0 0 var(--spacing-md) 0;
}

.title-category-icon {
    font-size: 3em;
    float: left;
    padding-top: 0;
    padding-right: 30px;
}

.title-banned-icon {
    color: var(--danger-color);
}

/* ==========================================================================
   5. Table Styles
   ========================================================================== */

/* Base table styles */
.details-page table:not(#collections .table),
.details-page .table:not(#collections .table),
.details-info-table,
.file-list-table,
.dltable-clean {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    table-layout: fixed;
}

.details-page .table { 
    margin-bottom: 0; 
}

.details-page .table-responsive,
.table-scroll-container {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
}

/* Info table */
.details-info-table {
    font-size: small;
    width: 100%;
    max-width: 100%;
    border: 1px solid var(--border-color);
    table-layout: fixed;
    box-sizing: border-box;
}

.details-info-table th {
    text-align: center;
    padding: 8px;
    background-color: var(--background-light);
    border: 1px solid var(--border-color);
}

.details-info-table td {
    padding: 8px;
    border: 1px solid var(--border-color);
    vertical-align: top;
}

.details-info-table td:first-child {
    width: 140px;
    white-space: nowrap;
    text-align: right;
    font-weight: bold;
    padding: 8px 12px 8px 8px;
}

/* File list table */
.file-list-header {
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.file-list-header .title {
    font-weight: bold;
}

.file-list-header .toggle-link {
    font-size: 90%;
}

.file-list-table {
    font-size: 10pt;
    width: 100%;
    max-width: 100%;
    table-layout: fixed;
    box-sizing: border-box;
}

.file-list-table td.filename {
    word-break: break-word;
}

/* File list column structure - filename gets more space than size */
.file-list-table th:first-child,
.file-list-table td:first-child {
    width: 60%; /* Filename column gets 60% width on desktop */
}

.file-list-table th:last-child,
.file-list-table td:last-child {
    width: 40%; /* Size column gets 40% width on desktop */
    text-align: right;
}

.file-list-table th {
    text-align: center;
    padding: 6px;
    background-color: var(--background-light);
    border: 1px solid var(--border-color);
}

.file-list-table td {
    padding: 6px;
    border: 1px solid var(--border-color);
    vertical-align: top;
}

/* ==========================================================================
   6. DL Table (Peer/Torrent Tables) - Compact Design
   ========================================================================== */

.dltable-clean {
    width: 100%;
    max-width: 100%;
    font-size: 10px;
    border-collapse: collapse;
    background-color: var(--background-white);
    table-layout: fixed;
    box-sizing: border-box;
}

.dltable-clean thead {
    background-color: #343a40;
    color: white;
}

.dltable-clean th {
    padding: 3px var(--spacing-xs);
    text-align: center;
    border: 1px solid #dee2e6;
    font-weight: 600;
    white-space: nowrap;
    font-size: 9px;
}

.dltable-clean th:first-child,
.dltable-clean th:nth-child(2) {
    text-align: left;
}

.dltable-clean td {
    padding: var(--spacing-xs) 3px;
    border: 1px solid #dee2e6;
    vertical-align: middle;
    font-size: 9px;
    line-height: 1.1;
    overflow: hidden;
}

.dltable-clean td:first-child {
    padding: 1px var(--spacing-xs);
    text-align: center;
}

.dltable-clean tbody tr:hover {
    background-color: var(--table-hover);
}

.dltable-clean tbody tr:nth-child(even) {
    background-color: var(--table-stripe);
}

/* DL Table specific cells and utilities */
.dltable-clean .user-cell {
    width: 130px;
    line-height: 1.0;
}

.dltable-clean .location-text {
    font-size: 8px;
    color: var(--text-muted);
    display: block;
    margin-top: 1px;
    line-height: 1.0;
}

.dltable-clean .text-center { text-align: center; }
.dltable-clean .text-nowrap { white-space: nowrap; }
.dltable-clean .ratio-good { color: var(--success-color); }
.dltable-clean .ratio-bad { color: var(--danger-color); }
.dltable-clean .connectable-no { color: var(--danger-color); font-weight: bold; }
.dltable-clean .connectable-yes { color: var(--success-color); }

.dltable-clean .gravatar { 
    border-radius: var(--spacing-xs); 
    margin-right: var(--spacing-xs); 
    vertical-align: middle;
    max-width: 24px;
    max-height: 24px;
}

.dltable-clean .username-link { 
    font-weight: bold; 
    text-decoration: none; 
}

.dltable-clean .ip-link { 
    color: var(--text-muted); 
    font-size: 8px; 
}

.dltable-clean .progress-cell {
    position: relative;
    width: 50px;
    font-size: 8px;
}

.dltable-clean .compact-user {
    line-height: 1.0;
}

.dltable-clean .compact-user .username-line {
    font-size: 9px;
    font-weight: bold;
}

.dltable-clean .compact-user .ip-line {
    font-size: 8px;
    color: var(--text-muted);
}

.dltable-clean .client-cell {
    width: 70px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 8px;
    padding: var(--spacing-xs) 3px;
}

/* DL Table column widths */
.dltable-clean .avatar-col { width: 26px; padding: 1px var(--spacing-xs); }
.dltable-clean .conn-col { width: 30px; }
.dltable-clean .size-col { width: 50px; }
.dltable-clean .rate-col { width: 55px; }
.dltable-clean .ratio-col { width: 40px; }
.dltable-clean .time-col { width: 50px; }

/* ==========================================================================
   7. Components & UI Elements
   ========================================================================== */

/* Alerts and notifications */
.alert-close-btn {
    float: right;
}

.stats-alert {
    padding-bottom: 0;
    font-size: small;
}

.stats-table {
    background: var(--background-white);
}

.no-seeds-alert,
.noseeds-alert {
    text-align: center;
    margin-top: 10pt;
}

.no-seeds-icon,
.dmca-icon,
.noseeds-icon {
    font-size: 5.2em;
}

.dmca-alert {
    margin-bottom: 0;
}

/* Star rating */
.star-icon {
    font-size: 1.2em;
}

.star-icon.gold {
    color: gold;
}

.star-badge {
    float: right;
    margin-left: var(--spacing-xs);
}

/* Panels */
.details-panel-border {
    border-style: solid;
    padding-bottom: 0;
}

.details-panel-nowrap {
    white-space: nowrap;
}

.download-button {
    padding: var(--spacing-md);
    width: 100%;
}

/* Buttons and controls */
#acceptterms {
    display: none;
    white-space: nowrap;
}

#worldmap_zoom_in, 
#worldmap_zoom_out {
    background-color: #EEEEEE;
    color: black;
    border: 1px solid #CCCCCC;
    height: 15px;
    width: 15px;
}

/* ==========================================================================
   8. Home Tab Components
   ========================================================================== */

.home-file-panel {
    overflow-y: scroll;
    overflow-x: hidden;
}

.home-file-panel.multi-file {
    height: 280px;
}

.home-file-table {
    font-size: 10pt;
    margin: 0;
}

.home-filename-cell {
    word-break: break-word;
}

.home-description {
    padding: var(--spacing-sm);
}

.home-tags-container {
    margin-left: 8px;
}

.home-tag {
    display: inline-block;
    background-color: #e7f3ff;
    border: 1px solid #b3d9ff;
    padding: 3px 8px;
    margin: var(--spacing-xs);
    border-radius: 12px;
    font-size: 11px;
}

.home-tag-link {
    text-decoration: none;
    color: #0066cc;
}

.home-bibtex-container {
    padding: 3px;
}

.home-bibtex {
    font-size: x-small;
    white-space: pre-wrap;
    margin: 0;
}

/* ==========================================================================
   9. Comments
   ========================================================================== */

.comment-meta {
    font-size: small;
    margin: 0;
    color: grey;
}

.comment-avatar-cell {
    width: 30px;
    padding: 1px;
}

.comment-edit-info {
    font-size: small;
}

/* ==========================================================================
   10. Collections
   ========================================================================== */

#collections .table {
    font-size: small;
    width: 100%;
}

/* ==========================================================================
   11. Map Components
   ========================================================================== */

#world-map-markers {
    width: 100%;
    max-width: 100%;
    height: 300px;
    box-sizing: border-box;
    background-color: var(--map-bg);
    min-width: 200px;
    position: relative;
}

.jvectormap-container {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
    background-color: var(--map-bg);
    position: relative !important;
    overflow: hidden !important;
}

.jvectormap-loading {
    background-color: var(--map-bg) !important;
}

.map-tooltip {
    min-width: 200px;
}

.map-tooltip-avatar {
    float: left;
    padding: var(--spacing-sm);
}

/* ==========================================================================
   12. Responsive Design - Mobile First
   ========================================================================== */

@media (max-width: 768px) {
    .details-page {
        max-width: 100%;
        margin: 0 auto;
        padding: 0;
    }
    
    .details-page.container-fluid {
        max-width: 100%;
    }
    
    .details-content-wrapper {
        flex-direction: column;
        margin-right: 0;
        margin-left: 0;
        width: 100%;
    }
    
    .main {
        flex: 1 1 auto !important;
        width: 100% !important;
        max-width: 100% !important;
        padding-right: 0;
        padding-left: 0;
        margin-bottom: var(--spacing-lg);
        order: 1;
    }
    
    .sidepanel {
        flex: 1 1 auto !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: auto !important;
        padding-right: 0;
        padding-left: 0;
        flex-basis: auto !important;
        order: 2;
    }
    
    /* Mobile navigation improvements */
    .details-tabs .nav-tabs {
        font-size: 13px;
    }
    
    .details-tabs .nav-tabs > li {
        margin-bottom: 1px;
    }
    
    .details-tabs .nav-tabs > li > a {
        padding: 6px 8px;
    }
    
    .details-tabs .nav-tabs > li.pull-right {
        float: none;
        margin-top: 3px;
    }
    
    /* Mobile table optimizations */
    .dltable-clean {
        font-size: 8px;
        width: 100%;
        margin: 0;
    }
    
    .details-info-table {
        width: 100%;
        margin: 0;
    }
    
    .details-info-table td:first-child {
        width: 120px;
    }
    
    .table-scroll-container {
        margin: 0;
        padding: 0;
    }
    
    /* File list mobile optimizations */
    .file-list-table {
        font-size: 8px; /* Smaller text for mobile */
    }
    
    .file-list-table th,
    .file-list-table td {
        padding: 3px; /* Tighter padding for mobile */
    }
    
    /* Filename column gets 70% width, size column gets 30% */
    .file-list-table th:first-child,
    .file-list-table td:first-child {
        width: 70%;
    }
    
    .file-list-table th:last-child,
    .file-list-table td:last-child {
        width: 30%;
        text-align: right; /* Right-align file sizes */
    }
    
    /* Make filename text even smaller on very small screens */
    @media (max-width: 480px) {
        .file-list-table {
            font-size: 7px;
        }
        
        .file-list-table th,
        .file-list-table td {
            padding: 2px;
        }
    }
    
    /* Collections mobile adjustments */
    #collections .table {
        font-size: 11px;
    }
    
    #collections .colhead,
    #collections .table td {
        padding: var(--spacing-xs);
    }
}

/* Ad container constraints */
#someunit.ad-container {
    overflow: hidden !important;
    box-sizing: border-box;
    max-width: 330px;
    width: 330px;
    max-height:220px;
}
/* ==========================================================================
   14. Performance Optimizations
   ========================================================================== */

/* GPU acceleration for smooth animations */
.details-content-wrapper,
.main,
.sidepanel {
    will-change: transform;
}

/* Reduce layout thrashing */
* {
    box-sizing: border-box;
}

/* Optimize font rendering */
.details-page {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeSpeed;
}

/* Print styles */
@media print {
    .details-page {
        max-width: none;
        margin: 0;
        padding: 0;
    }
    
    .details-content-wrapper {
        flex-direction: column;
        margin: 0;
        width: 100%;
    }
    
    .main,
    .sidepanel {
        width: 100%;
        max-width: 100%;
        padding: 0;
    }
    
    .details-footer,
    .download-button {
        display: none;
    }
}
