/* Shirley Chinese Teacher - Pet Game System
   NetDynamic.Net - v1.0.0-alpha
   Design matching circles UI theme - mobile first */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1a1a2e;
    color: #fff;
    padding: 0;
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    font-size: 14px;
}

/* ============ HEADER ============ */
.app-header {
    background: #16213e;
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #0f3460;
}

.app-header h1 {
    font-size: 16px;
    font-weight: bold;
    color: #FFD700;
}

.app-header .version {
    color: #666;
    font-size: 10px;
    display: block;
    margin-top: 2px;
}

/* ============ TABS ============ */
.tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.tab-btn {
    flex: 1;
    padding: 8px;
    background: #0f3460;
    border: none;
    color: #888;
    cursor: pointer;
    border-radius: 5px;
    font-size: 13px;
    font-weight: bold;
    transition: opacity 0.2s;
    min-width: 0;
    white-space: nowrap;
}

.tab-btn.active {
    background: #e94560;
    color: #fff;
}

.tab-btn:hover:not(.active) {
    opacity: 0.8;
    color: #aaa;
}

/* ============ TAB CONTENT ============ */
.tab-content {
    display: none;
}

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

/* ============ MAIN PANEL ============ */
.panel {
    background: #16213e;
    padding: 15px;
    border-radius: 10px;
    width: 100%;
    max-width: 100%;
}

/* ============ SECTIONS ============ */
.control-section {
    margin-bottom: 15px;
}

.section-label {
    font-size: 12px;
    color: #aaa;
    text-transform: uppercase;
    font-weight: bold;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.section-divider {
    border: none;
    border-top: 1px solid #0f3460;
    margin: 15px 0;
}

/* ============ BUTTONS ============ */
.btn {
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
    transition: opacity 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.btn:hover {
    opacity: 0.9;
}

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

.btn-secondary {
    background: #0f3460;
    color: #fff;
}

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

.btn-success {
    background: #27ae60;
    color: #fff;
}

.btn-gold {
    background: #FFD700;
    color: #000;
}

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

.btn-block {
    display: flex;
    width: 100%;
    justify-content: center;
}

.action-buttons {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

/* ============ FORM INPUTS ============ */
input[type="text"],
input[type="number"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: 10px;
    border: 1px solid #0f3460;
    border-radius: 5px;
    background: #1a1a2e;
    color: #fff;
    font-size: 14px;
    font-family: inherit;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #e94560;
}

select {
    cursor: pointer;
}

.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    font-size: 12px;
    color: #aaa;
    margin-bottom: 5px;
    font-weight: bold;
}

.form-row {
    display: flex;
    gap: 10px;
}

.form-row .form-group {
    flex: 1;
    min-width: 0;
}

.form-hint {
    font-size: 11px;
    color: #666;
    margin-top: 3px;
}

/* ============ PET GRID ============ */
.pet-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.pet-card {
    background: #1a1a2e;
    border: 1px solid #0f3460;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.pet-card:hover {
    border-color: #e94560;
}

.pet-image-wrap {
    width: 100%;
    height: 150px;
    background: #111;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.pet-image-wrap img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.pet-image-placeholder {
    color: #444;
    font-size: 3rem;
}

.pet-card-body {
    padding: 10px;
}

.pet-card-body h3 {
    font-size: 14px;
    color: #FFD700;
    margin-bottom: 5px;
}

.pet-status {
    font-size: 11px;
    color: #888;
    margin-bottom: 3px;
}

.pet-card-actions {
    padding: 8px 10px;
    border-top: 1px solid #0f3460;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* ============ FAN CARDS ============ */
.fan-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.fan-card {
    background: #1a1a2e;
    border: 1px solid #0f3460;
    border-radius: 8px;
    padding: 12px;
}

.fan-card:hover {
    border-color: #e94560;
}

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

.fan-name {
    font-size: 14px;
    font-weight: bold;
    color: #fff;
}

.fan-pet-display {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.fan-pet-img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid #FFD700;
    object-fit: cover;
    background: #333;
    flex-shrink: 0;
}

.fan-pet-info h4 {
    font-size: 13px;
    color: #FFD700;
    margin-bottom: 2px;
}

.fan-pet-info .level-text {
    color: #aaa;
    font-size: 12px;
}

/* ============ PROGRESS BAR ============ */
.progress-wrap {
    margin: 8px 0;
}

.progress-bar-bg {
    width: 100%;
    height: 8px;
    background: #0f3460;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #e94560, #FFD700);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.progress-text {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: #666;
    margin-top: 3px;
}

/* ============ COLLAPSIBLE SECTION ============ */
.collapsible-section {
    border: 1px solid #0f3460;
    border-radius: 5px;
    padding: 10px 12px;
    background: rgba(15, 52, 96, 0.2);
}

.section-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.section-header-row:hover {
    opacity: 0.85;
}

.collapse-arrow {
    font-size: 12px;
    color: #888;
    transition: transform 0.2s;
}

.collapse-arrow.expanded {
    transform: rotate(180deg);
}

.collapsible-body {
    margin-top: 10px;
}

.lock-btn {
    font-size: 11px !important;
    padding: 4px 10px !important;
}

.lock-btn.unlocked {
    background: #27ae60;
}

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

/* ============ BADGES ============ */
.taken-badge {
    background: #c0392b;
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
}

.available-badge {
    background: #27ae60;
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
}

/* ============ TABLES ============ */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    text-align: left;
    padding: 8px 10px;
    color: #aaa;
    font-size: 11px;
    text-transform: uppercase;
    border-bottom: 1px solid #0f3460;
    font-weight: bold;
}

.data-table td {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(15, 52, 96, 0.5);
    vertical-align: middle;
}

.data-table tr:hover td {
    background: rgba(15, 52, 96, 0.3);
}

/* ============ SELECTED USERS LIST (same as circles) ============ */
.selected-users-list {
    min-height: 60px;
    background: #1a1a2e;
    border: 1px dashed #0f3460;
    border-radius: 5px;
    padding: 10px;
}

.selected-user-item {
    display: flex;
    align-items: center;
    padding: 8px;
    background: #0f3460;
    border-radius: 5px;
    margin-bottom: 8px;
    gap: 10px;
}

.selected-user-item:last-child {
    margin-bottom: 0;
}

.user-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #FFD700;
    flex-shrink: 0;
}

.user-avatar-placeholder {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    border: 2px solid #FFD700;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: 14px;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-sub {
    font-size: 10px;
    color: #888;
}

/* ============ SEARCH (same as circles) ============ */
.search-container {
    position: relative;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #1a1a2e;
    border: 1px solid #e94560;
    border-top: none;
    border-radius: 0 0 5px 5px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 9999;
    display: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.search-results.show {
    display: block;
}

.search-result-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    cursor: pointer;
    gap: 10px;
}

.search-result-item:hover {
    background: #0f3460;
}

.search-result-item img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
}

.search-result-item .no-image {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

/* ============ LEVEL IMAGES ============ */
.level-images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.level-image-slot {
    text-align: center;
}

.level-image-slot label {
    display: block;
    font-size: 10px;
    color: #888;
    margin-bottom: 4px;
}

.level-image-preview {
    width: 100%;
    height: 80px;
    background: #1a1a2e;
    border: 2px dashed #0f3460;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.2s;
}

.level-image-preview:hover {
    border-color: #e94560;
}

.level-image-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.upload-icon {
    color: #444;
    font-size: 14px;
    font-weight: bold;
}

/* ============ MODAL (same as circles) ============ */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 500;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: #16213e;
    border-radius: 10px;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    padding: 15px;
    border-bottom: 1px solid #0f3460;
}

.modal-header h2 {
    font-size: 16px;
    color: #FFD700;
}

.modal-body {
    padding: 15px;
}

.modal-footer {
    padding: 10px 15px;
    border-top: 1px solid #0f3460;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ============ ACTIVITIES LIST ============ */
.activity-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(15, 52, 96, 0.3);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-item input {
    flex: 1;
}

.activity-item .points-input {
    width: 70px;
    flex: none;
}

/* ============ TOAST ============ */
.toast-container {
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 2000;
}

.toast {
    background: #16213e;
    border: 1px solid #27ae60;
    border-radius: 5px;
    padding: 10px 15px;
    margin-bottom: 8px;
    color: #fff;
    font-size: 13px;
    font-weight: bold;
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.5s forwards;
    min-width: 200px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.toast.error {
    border-color: #c0392b;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* ============ EMPTY STATE ============ */
.empty-state {
    text-align: center;
    padding: 20px;
    color: #666;
    font-style: italic;
}

.empty-state .icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
    font-style: normal;
}

/* ============ HISTORY ============ */
.history-list {
    max-height: 200px;
    overflow-y: auto;
    font-size: 12px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px solid rgba(15, 52, 96, 0.3);
    color: #aaa;
}

.history-item .points-change {
    font-weight: bold;
}

.history-item .points-change.positive {
    color: #27ae60;
}

.history-item .points-change.negative {
    color: #c0392b;
}

/* ============ LEVEL CONFIG ROW ============ */
.level-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
    padding: 6px 8px;
    background: #0f3460;
    border-radius: 5px;
}

.level-row .level-num {
    font-size: 12px;
    font-weight: bold;
    color: #FFD700;
    min-width: 35px;
}

.level-row input {
    flex: 1;
    min-width: 0;
    padding: 6px 8px;
    font-size: 13px;
}

/* ============ STATS MODAL ============ */
.stats-display {
    text-align: center;
}

.stats-pet-img {
    max-width: 150px;
    max-height: 150px;
    border-radius: 10px;
    border: 3px solid #FFD700;
}

.stats-name {
    font-size: 18px;
    color: #FFD700;
    font-weight: bold;
    margin: 10px 0 5px;
}

.stats-owner {
    font-size: 13px;
    color: #aaa;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin-bottom: 15px;
}

.stats-grid {
    display: flex;
    justify-content: space-around;
    padding: 12px;
    background: #0f3460;
    border-radius: 5px;
    margin-bottom: 12px;
}

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

.stat-value {
    font-size: 20px;
    font-weight: bold;
    color: #FFD700;
}

.stat-label {
    font-size: 10px;
    color: #888;
    text-transform: uppercase;
}

.stat-value.cyan { color: #00f2ea; }
.stat-value.pink { color: #e94560; }

/* ============ EVOLUTION GALLERY ============ */
.evo-gallery {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 8px 0;
    -webkit-overflow-scrolling: touch;
}

.evo-item {
    text-align: center;
    min-width: 65px;
    flex-shrink: 0;
}

.evo-item img {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    object-fit: cover;
}

.evo-item .evo-placeholder {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    background: #1a1a2e;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    font-size: 1.5rem;
}

.evo-item .evo-label {
    font-size: 9px;
    color: #666;
    margin-top: 3px;
}

.evo-active {
    border: 2px solid #FFD700;
}

.evo-locked {
    opacity: 0.3;
    border: 2px solid #0f3460;
}

.evo-past {
    border: 2px solid #0f3460;
}

/* ============ LEADERBOARD RANK COLORS ============ */
.rank-gold { color: #FFD700; font-weight: bold; }
.rank-silver { color: #C0C0C0; font-weight: bold; }
.rank-bronze { color: #CD7F32; font-weight: bold; }

/* ============ FAN ACTIONS ============ */
.fan-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #0f3460;
}

/* ============ RESPONSIVE ============ */

/* Tablet and up */
@media (min-width: 600px) {
    .pet-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .fan-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .modal {
        max-width: 500px;
    }
}

/* Desktop */
@media (min-width: 900px) {
    .pet-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .fan-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .tab-content-wrap {
        max-width: 900px;
        margin: 0 auto;
    }
}

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #1a1a2e;
}

::-webkit-scrollbar-thumb {
    background: #0f3460;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #e94560;
}
