/* ==================== BASE STYLES ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #667eea;
    --primary-dark: #5a67d8;
    --secondary: #764ba2;
    --success: #48bb78;
    --danger: #f56565;
    --warning: #ed8936;
    --info: #4299e1;
    --dark: #2d3748;
    --light: #f7fafc;
    --gray: #718096;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
}

/* ==================== HEADER STYLES ==================== */
.header {
    background: white;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}

.header h1 {
    color: var(--dark);
    font-size: 2.5em;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
}

.header p {
    color: var(--gray);
    font-size: 1.1em;
    text-align: center;
}

.header-actions {
    text-align: center;
    margin-top: 20px;
}

.header-actions button {
    background: rgba(102, 126, 234, 0.1);
    color: var(--primary);
    border: 2px solid var(--primary);
    padding: 8px 16px;
    margin: 0 5px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
}

.header-actions button:hover {
    background: var(--primary);
    color: white;
}

/* ==================== NAVIGATION TABS ==================== */
.nav-tabs {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    background: white;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    overflow-x: auto;
    justify-content: center;
}

.nav-tab {
    padding: 18px 32px;
    background: transparent;
    border: 2px solid transparent;
    border-radius: 10px;
    color: var(--gray);
    font-weight: 600;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.nav-tab:hover {
    background: var(--light);
}

.nav-tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
}

/* ==================== STATS BAR ==================== */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

.stat-card .value {
    font-size: 2em;
    font-weight: bold;
    color: var(--primary);
}

.stat-card .label {
    color: var(--gray);
    margin-top: 5px;
}

/* ==================== TAB PANELS ==================== */
.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==================== ITEMS TAB STYLES ==================== */
.items-layout {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 30px;
}

@media (max-width: 1024px) {
    .items-layout {
        grid-template-columns: 1fr;
    }
}

.panel {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}

.panel-sticky {
    height: fit-content;
    position: sticky;
    top: 20px;
}

.section-title {
    font-size: 1.5em;
    color: var(--dark);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary);
}

/* ==================== FORM STYLES ==================== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--dark);
    font-weight: 600;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1em;
    transition: all 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* ==================== ENHANCIVE TARGETS ==================== */
.enhancive-targets {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

#targetsContainer {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ==================== BUTTON STYLES ==================== */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-add-target {
    background: var(--success);
    color: white;
}

.remove-target-btn {
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 5px;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==================== ITEM CARDS ==================== */
.search-bar {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 1em;
}

.items-grid {
    display: grid;
    gap: 15px;
}

.item-card {
    padding: 20px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    background: #f8f9fa;
    transition: all 0.3s;
}

.item-card:hover {
    border-color: var(--primary);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.2);
    transform: translateY(-2px);
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 15px;
}

.item-name {
    font-size: 1.2em;
    font-weight: bold;
    color: var(--dark);
}

.item-location {
    display: inline-block;
    padding: 5px 10px;
    background: var(--primary);
    color: white;
    border-radius: 5px;
    font-size: 0.85em;
    font-weight: 600;
}

.permanence-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 600;
}

.permanence-badge.persists {
    background: #c6f6d5;
    color: #22543d;
}

.permanence-badge.crumbly {
    background: #fed7d7;
    color: #742a2a;
}

.enhancive-item {
    display: inline-block;
    padding: 5px 10px;
    margin: 3px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 15px;
    font-size: 0.85em;
}

/* ==================== EQUIPMENT TAB STYLES ==================== */
.equipment-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    align-items: stretch;
    min-height: 800px;
}

@media (max-width: 1200px) {
    .equipment-layout {
        grid-template-columns: 1fr;
    }
}

.slots-container {
    display: grid;
    gap: 10px;
    height: auto; /* Let it use natural height */
}

.slot-row {
    display: grid;
    grid-template-columns: 100px 80px 1fr 100px 60px 30px;
    gap: 0;
    padding: 2px 4px;
    background: #f8f9fa;
    border-radius: 6px;
    align-items: center;
    transition: all 0.3s;
}

.slot-row > :nth-child(1) { margin-right: 0; }     /* Location */
.slot-row > :nth-child(2) { margin-right: 0; }     /* Slot number */  
.slot-row > :nth-child(3) { margin-right: 3px; }   /* Dropdown */
.slot-row > :nth-child(4) { margin-right: 4px; }   /* Checkboxes */
.slot-row > :nth-child(5) { margin-right: 0; }     /* Status */
.slot-row > :nth-child(6) { margin-right: 0; }     /* Unequip button */

.slot-row:hover {
    background: #e2e8f0;
    transform: translateX(5px);
}

.slot-location {
    font-weight: 600;
    color: var(--dark);
}

.slot-number {
    color: var(--gray);
}

.slot-number.premium {
    color: #9f7aea;
    font-weight: 600;
}

.slot-number.platinum {
    color: #ed8936;
    font-weight: 600;
}

.slot-item-select {
    padding: 4px 6px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
}

.slot-item-select.has-item {
    background: linear-gradient(135deg, #667eea20 0%, #764ba220 100%);
    border-color: var(--primary);
    font-weight: 600;
}

.slot-item-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.slot-status {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 600;
    text-align: center;
}

.slot-status.filled {
    background: var(--success);
    color: white;
}

.slot-status.empty {
    background: var(--gray);
    color: white;
}

.unequip-btn {
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s;
    width: 24px;
    height: 24px;
}

.slot-row:hover .unequip-btn.active {
    opacity: 1;
}

/* Equipment slot checkboxes and labels */
.slot-row label {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 0.8em;
    margin: 0;
    padding: 0;
    white-space: nowrap;
}

.slot-row input[type="checkbox"] {
    margin: 0;
    padding: 0;
    width: 12px;
    height: 12px;
}

/* Remove spinner buttons from number inputs and control width */
.amount-input {
    width: 60px !important;
    max-width: 60px !important;
    min-width: 60px !important;
    -webkit-appearance: none;
    -moz-appearance: textfield;
    box-sizing: border-box;
    padding: 4px 6px;
    margin: 0;
}

.amount-input::-webkit-outer-spin-button,
.amount-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
    display: none;
}

/* Ensure target rows don't overflow */
.target-row {
    display: grid;
    grid-template-columns: 1fr 65px 50px 30px;
    gap: 8px;
    margin-bottom: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    animation: slideIn 0.3s ease;
    width: 100%;
    box-sizing: border-box;
}

.target-row .amount-input {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding: 4px !important;
    font-size: 0.9em !important;
    border: 1px solid #e2e8f0 !important;
}

/* ==================== TOTALS TAB STYLES ==================== */
.totals-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

@media (max-width: 1200px) {
    .totals-layout {
        grid-template-columns: 1fr;
    }
}

.stat-group {
    margin-bottom: 30px;
}

.stat-group-title {
    font-size: 1.2em;
    font-weight: bold;
    color: var(--dark);
    margin-bottom: 15px;
    padding: 10px;
    background: linear-gradient(135deg, #667eea20 0%, #764ba220 100%);
    border-radius: 8px;
}

.stat-row {
    display: grid;
    grid-template-columns: 200px 100px 1fr 80px;
    gap: 15px;
    align-items: center;
    padding: 10px;
    margin-bottom: 8px;
    background: #f8f9fa;
    border-radius: 8px;
    transition: all 0.3s;
}

.stat-row:hover {
    background: #e2e8f0;
    transform: translateX(5px);
}

.stat-name {
    font-weight: 600;
    color: var(--dark);
}

.stat-value {
    font-size: 1.1em;
    font-weight: bold;
    text-align: center;
}

.stat-value.normal {
    color: var(--dark);
}

.stat-value.warning {
    color: var(--warning);
}

.stat-value.capped {
    color: var(--success);
}

.stat-value.overcap {
    color: var(--danger);
}

.progress-bar {
    height: 24px;
    background: #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4299e1 0%, #667eea 100%);
    transition: width 0.5s ease;
    display: flex;
    align-items: center;
    padding: 0 10px;
    color: white;
    font-size: 0.85em;
    font-weight: 600;
}

.progress-fill.capped {
    background: linear-gradient(90deg, #48bb78 0%, #38a169 100%);
}

.progress-fill.overcap {
    background: linear-gradient(90deg, #f56565 0%, #e53e3e 100%);
}

.stat-cap {
    font-size: 0.9em;
    color: var(--gray);
    text-align: center;
}

.equipped-summary {
    background: white;
    padding: 5px;
    border-radius: 10px;
    height: calc(98% - 70px); /* Account for section title and margins, reduced 2% */
    overflow-y: auto;
    overflow-x: hidden;
    word-wrap: break-word;
    box-sizing: border-box;
    max-width: 100%;
    width: 100%;
}

.summary-title {
    font-size: 1.3em;
    font-weight: bold;
    color: var(--dark);
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.summary-grid {
    display: grid;
    gap: 10px;
    width: 100%;
    max-width: 100%;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 6px;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.summary-target {
    font-weight: 600;
    color: var(--dark);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.summary-value {
    color: var(--primary);
    font-weight: bold;
    flex-shrink: 0;
    margin-left: 8px;
}

/* ==================== NOTIFICATION ==================== */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    background: var(--success);
    color: white;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    transform: translateX(400px);
    transition: transform 0.3s;
    z-index: 1000;
}

.notification.show {
    transform: translateX(0);
}

/* ==================== EMPTY STATE ==================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray);
}

.empty-state h3 {
    font-size: 1.5em;
    margin-bottom: 10px;
}

/* ==================== LOGIN STYLES ==================== */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    background: rgba(255, 255, 255, 0.95);
    padding: 2rem;
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    backdrop-filter: blur(10px);
}

.login-box h1 {
    text-align: center;
    margin-bottom: 2rem;
    color: #333;
    font-size: 2rem;
}

.login-box h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: #555;
}

.login-box input {
    width: 100%;
    padding: 12px;
    margin-bottom: 1rem;
    border: 2px solid #e1e1e1;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.login-box input:focus {
    outline: none;
    border-color: #667eea;
}

.login-box button {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

.login-box button:hover {
    transform: translateY(-2px);
}

.login-box p {
    text-align: center;
    margin-top: 1rem;
    color: #666;
}

.login-box a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
}

/* ==================== UTILITY CLASSES ==================== */
.hidden {
    display: none !important;
}

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

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* ==================== RESPONSIVE DESIGN ==================== */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .header {
        padding: 20px;
    }
    
    .header h1 {
        font-size: 2em;
    }
    
    
    /* Disable sticky behavior on mobile */
    .panel-sticky {
        position: static;
    }
    
    .nav-tabs {
        overflow-x: auto;
        padding: 5px;
    }
    
    .nav-tab {
        padding: 14px 20px;
        font-size: 1em;
        white-space: nowrap;
    }
    
    .stats-bar {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .items-layout,
    .equipment-layout,
    .totals-layout {
        grid-template-columns: 1fr;
    }
    
    .panel {
        padding: 15px;
    }
}

/* ==================== MARKETPLACE TAB STYLES ==================== */
.marketplace-tabs {
    width: 100%;
}

.tab-navigation {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e2e8f0;
}

.tab-btn {
    padding: 12px 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    color: var(--gray);
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
}

.tab-btn:hover {
    color: var(--primary);
    background: rgba(66, 153, 225, 0.1);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: rgba(66, 153, 225, 0.1);
}

.marketplace-tab-panel {
    display: none;
}

.marketplace-tab-panel.active {
    display: block;
}