/* Custom styles for Trading Card Exchange */

/* Centralized design tokens for consistent sizing and spacing */
:root {
    --base-font-size: 16px; /* default body font size */
    --base-line-height: 1.45;
    --container-padding-left: 20px; /* matches main left padding */
    --container-padding-right: 30px; /* matches main right padding */
    --sidebar-width: 240px;
    --card-grid-min: 220px; /* minimum column width in card grids */
    --card-narrow-width: 220px; /* narrow card width used across search/results */
    --card-gap: 1rem;
}

html, body {
    font-size: var(--base-font-size);
    line-height: var(--base-line-height);
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

/* Buttons and form fields consistent sizing */
.btn, .form-control, .form-select { font-size: 0.95rem; }

/* Global table styling - prevent header text wrapping */
table thead th {
    white-space: nowrap;
}


.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    width: 220px; /* Explicit width to prevent content overlap */
    padding: 48px 0 0;
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);
}

.sidebar-sticky {
    position: relative;
    top: 0;
    height: calc(100vh - 48px);
    padding-top: .5rem;
    overflow-x: hidden;
    overflow-y: auto;
}

.sidebar .nav-link {
    font-weight: 500;
    color: #007bff;
    padding: 0.5rem 1rem;
    margin-bottom: 0.25rem;
    border-radius: 0.25rem;
}

.sidebar .nav-link:hover {
    color: #0056b3;
    background-color: rgba(0, 123, 255, 0.15);
}

.sidebar .nav-link.active {
    color: #0056b3;
    background-color: rgba(0, 123, 255, 0.2);
}

.user-info {
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: 0.25rem;
    margin: 1rem;
}

.user-info p {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.user-info-section {
    background-color: #2c3e50 !important;
    border: 1px solid #3a4b5c;
}

.user-avatar img {
    border: 2px solid #3498db;
    transition: transform 0.2s ease;
}

.user-avatar img:hover {
    transform: scale(1.05);
}

.points-display {
    font-size: 0.85rem;
}

.points-display .text-muted {
    font-size: 0.7rem;
}

.auth-links {
    padding: 1rem;
    text-align: center;
}

.auth-links .btn {
    width: 100%;
}

main {
    margin-left: var(--sidebar-width); /* keep consistent with sidebar width */
    padding: var(--container-padding-left) var(--container-padding-right) var(--container-padding-left) var(--container-padding-left);
    min-height: 100vh; /* Ensure main content area takes full height */
}

/* Ensure all containers within main have proper spacing */
/* Make container padding match the outer `main` padding so pages that
   use `.container` or `.container-fluid` align flush with templates
   that do not use an extra wrapper (e.g. advanced_search_full.html).
   This prevents double-padding (main + container) which caused
   inconsistent edge spacing next to the sidebar. */
main .container,
main .container-fluid {
    max-width: 100%;
    margin-right: auto;
    margin-left: auto;
    /* Keep internal container padding minimal so the outer `main` padding
       is the single source of truth for page edge spacing. */
    padding-left: 0;
    padding-right: 0;
}

/* Make any container-fluid inside main behave like a centered fixed-width container
   (this gives pages using container-fluid the same visual edge spacing as pages
   that rely only on the outer `main` padding, e.g. advanced_search_full.html).
   We emulate common bootstrap container max-widths to keep responsiveness. */
main .container-fluid {
    width: 100%;
    box-sizing: border-box;
    padding-left: 0; /* rely on main's padding */
    padding-right: 0;
    margin-left: auto;
    margin-right: auto;
}

@media (min-width: 576px) {
    main .container-fluid { max-width: 540px; }
}
@media (min-width: 768px) {
    main .container-fluid { max-width: 720px; }
}
@media (min-width: 992px) {
    main .container-fluid { max-width: 960px; }
}
@media (min-width: 1200px) {
    main .container-fluid { max-width: 1140px; }
}
@media (min-width: 1400px) {
    main .container-fluid { max-width: 1320px; }
}

/* Prevent any content from overlapping with the sidebar */
body:not(.mobile-mode) .row,
body:not(.mobile-mode) .alert,
body:not(.mobile-mode) .card {
    margin-left: 0;
}

@media (max-width: 767.98px) {
    .sidebar {
        position: relative;
        height: auto;
    }
    
    main {
        margin-left: 0;
    }
}

/* Card styles */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--card-grid-min), 1fr));
    gap: var(--card-gap);
    margin-top: 1rem;
}

/* Narrow card layout for search results - consistent with card-grid min width */
.card-narrow {
    max-width: var(--card-narrow-width);
    width: 100%;
    margin: 0 auto;
}

/* Remove white backgrounds from image containers */
.card-image-container,
.card img {
    background: transparent !important;
}

/* Make sure the image itself maintains quality */
.card-image-transparent {
    background: transparent !important;
    border: none !important;
}

.card-item {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 0.75rem;
    background-color: #fff;
    transition: box-shadow 0.15s ease-in-out;
}

.card-item:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.card-name {
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.35rem;
    font-size: 0.95rem;
}

.card-details {
    font-size: 0.9rem;
    color: #6c757d;
}

.card-title, .card-text {
    font-size: 0.95rem;
}

.price-info {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.875rem;
}

.inventory-controls {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.inventory-controls input {
    width: 60px;
    padding: 0.25rem;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    text-align: center;
}

/* Trade partner styles */
.partner-card {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 1rem;
    margin-bottom: 1rem;
    background-color: #fff;
}

.partner-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.partner-stats {
    font-size: 0.875rem;
    color: #6c757d;
}

.match-score {
    font-weight: bold;
    color: #28a745;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .card-grid {
        grid-template-columns: 1fr;
    }
    
    .inventory-controls {
        flex-direction: column;
    }
    
    .inventory-controls input {
        width: 100%;
    }
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: #007bff;
    animation: spin 1s ease-in-out infinite;
}

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

/* Alert styles */
.alert-custom {
    border-radius: 0.375rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}

/* Button styles */
.btn-custom {
    border-radius: 0.375rem;
    padding: 0.5rem 1rem;
    font-weight: 500;
    transition: all 0.15s ease-in-out;
}

.btn-custom:hover {
    transform: translateY(-1px);
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
}

/* Form styles */
.form-control-custom {
    border-radius: 0.375rem;
    border: 1px solid #ced4da;
    padding: 0.5rem 0.75rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control-custom:focus {
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Table styles */
.table-custom {
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 0.375rem;
    overflow: hidden;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.table-custom th {
    background-color: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
}

.table-custom td {
    border-bottom: 1px solid #dee2e6;
}

/* Pagination styles */
.pagination-custom {
    justify-content: center;
    margin-top: 2rem;
}

.pagination-custom .page-link {
    border-radius: 0.375rem;
    margin: 0 0.125rem;
    border: 1px solid #dee2e6;
    color: #495057;
}

.pagination-custom .page-link:hover {
    background-color: #e9ecef;
    border-color: #adb5bd;
}

.pagination-custom .page-item.active .page-link {
    background-color: #007bff;
    border-color: #007bff;
}

/* Daily Bonus Card Styles */
#daily-bonus-card {
    border: 2px solid #ffc107;
    background: linear-gradient(135deg, #fff3cd 0%, #ffffff 100%);
    box-shadow: 0 0.25rem 0.75rem rgba(255, 193, 7, 0.2);
    transition: all 0.3s ease;
}

#daily-bonus-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(255, 193, 7, 0.3);
}

#daily-bonus-card .card-title {
    color: #856404;
    font-weight: bold;
    text-align: center;
    margin-bottom: 1rem;
}

#claim-bonus-btn {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    border: none;
    padding: 0.75rem 1.5rem;
    font-weight: bold;
    border-radius: 0.5rem;
    transition: all 0.3s ease;
    box-shadow: 0 0.25rem 0.5rem rgba(40, 167, 69, 0.3);
}

#claim-bonus-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 0.5rem 1rem rgba(40, 167, 69, 0.4);
    background: linear-gradient(135deg, #218838 0%, #1e7e34 100%);
}

#claim-bonus-btn:disabled {
    transform: none;
    box-shadow: none;
    opacity: 0.7;
}

.daily-bonus-success {
    color: #155724;
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 0.375rem;
    padding: 0.75rem;
    margin: 0.5rem 0;
}

.daily-bonus-info {
    background-color: #f8f9fa;
    border-radius: 0.375rem;
    padding: 0.5rem;
    margin: 0.25rem 0;
    border-left: 4px solid #ffc107;
}

/* Enhanced User Stats Styling */
.user-stats .d-flex {
    transition: all 0.2s ease;
    padding: 2px 4px;
    border-radius: 4px;
}

.user-stats .d-flex:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateX(2px);
}

.points-display .d-flex {
    transition: all 0.2s ease;
    padding: 2px 4px;
    border-radius: 4px;
}

.points-display .d-flex:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateX(2px);
}

/* Stat label alignment */
.user-stats .d-flex > span:first-child,
.points-display .d-flex > span:first-child {
    min-width: 70px;
    text-align: left;
}

/* Colorful icon animations */
.user-stats i, .points-display i {
    transition: all 0.3s ease;
    width: 14px;
    text-align: center;
}

.user-stats .d-flex:hover i, .points-display .d-flex:hover i {
    transform: scale(1.1);
    filter: brightness(1.2);
}

/* Premium badge glow effect */
.badge {
    transition: all 0.3s ease;
}

.badge:hover {
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

/* Username styling */
.username {
    transition: color 0.3s ease;
}

.user-details:hover .username {
    color: #58a6ff !important;
}

/* Premium Profile Customization */
.profile-section {
    transition: all 0.3s ease;
}

/* Premium Backgrounds */
.bg-gradient-blue {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
}

.bg-gradient-purple {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%) !important;
}

.bg-gradient-gold {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%) !important;
}

.bg-pattern-stars {
    background: #1a1a2e url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'><circle cx='10' cy='10' r='1' fill='%23fff' opacity='0.3'/></svg>") repeat !important;
}

.bg-pattern-cards {
    background: #2c3e50 url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'><rect x='15' y='10' width='10' height='15' fill='%23fff' opacity='0.1'/></svg>") repeat !important;
}

.bg-animated-aurora {
    background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
    background-size: 400% 400%;
    animation: aurora 15s ease infinite;
}

@keyframes aurora {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Global Avatar Border Styles for all avatar images */
.avatar-border-gold {
    border: 3px solid #ffd700 !important;
    border-radius: 50% !important;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5) !important;
}

.avatar-border-rainbow {
    border: 4px solid transparent !important;
    border-radius: 50% !important;
    background: linear-gradient(white, white) padding-box,
                conic-gradient(from 0deg, #ff0000, #ff8000, #ffff00, #80ff00, #00ff00, #00ff80, #00ffff, #0080ff, #0000ff, #8000ff, #ff00ff, #ff0080, #ff0000) border-box !important;
    position: relative;
}

.avatar-border-glow {
    border: 2px solid #00d4ff !important;
    border-radius: 50% !important;
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.8) !important;
}

.avatar-border-diamond {
    border: 4px solid transparent !important;
    border-radius: 50% !important;
    background: linear-gradient(white, white) padding-box,
                conic-gradient(from 0deg, #ffd700, #ffffff, #ffd700, #ffffff, #ffd700) border-box !important;
    animation: diamondPulse 3s ease-in-out infinite;
}

@keyframes diamondPulse {
    0%, 100% { 
        transform: scale(1);
        filter: brightness(1) drop-shadow(0 0 10px rgba(255, 215, 0, 0.5));
    }
    50% { 
        transform: scale(1.05);
        filter: brightness(1.3) drop-shadow(0 0 20px rgba(255, 215, 0, 0.8));
    }
}

/* Ensure all avatar images are circular */
img.rounded-circle, .avatar-img {
    border-radius: 50% !important;
    object-fit: cover;
}

/* Remove legacy avatar border classes that conflict */
.avatar-gold img, .avatar-rainbow img, .avatar-pulse img, .avatar-diamond img, .avatar-fire img, .avatar-ice img {
    border: none !important;
    background: none !important;
    box-shadow: none !important;
    animation: none !important;
    clip-path: none !important;
    transform: none !important;
}
