@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

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

:root {
    --ton-blue: #0098EA;
    --ton-blue-hover: #0088d4;
    --bg-primary: #F7F9FB;
    --bg-white: #FFFFFF;
    --bg-secondary: #EFEFF4;
    --text-primary: #000000;
    --text-secondary: #708499;
    --border-color: #E8E8E8;
    --hover-bg: #F0F4F8;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-pill: 20px;
}

[data-theme="dark"] {
    --ton-blue: #0098EA;
    --ton-blue-hover: #1AA3F0;
    --bg-primary: #17212b;
    --bg-white: #1e2c3a;
    --bg-secondary: #232e3c;
    --text-primary: #f5f5f5;
    --text-secondary: #708499;
    --border-color: #2b3d4f;
    --hover-bg: #253545;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--ton-blue);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--bg-white);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-img {
    height: 40px;
    width: auto;
    filter: drop-shadow(1px 0 0 #000) drop-shadow(-1px 0 0 #000) drop-shadow(0 1px 0 #000) drop-shadow(0 -1px 0 #000);
}

[data-theme="dark"] .logo-img {
    filter: none;
}

.logo:visited {
    color: var(--text-primary);
}

.header-right a {
    padding: 10px 20px;
    background: rgba(0, 136, 204, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    font-weight: 500;
    font-size: 14px;
    box-shadow: 0 4px 16px rgba(0, 136, 204, 0.3);
    transition: all 0.2s ease;
}

.header-right a:hover {
    background: rgba(0, 136, 204, 0.95);
    box-shadow: 0 6px 24px rgba(0, 136, 204, 0.4);
    transform: translateY(-1px);
    text-decoration: none;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background: var(--hover-bg);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    fill: var(--text-secondary);
    transition: fill 0.2s;
}

.theme-toggle:hover svg {
    fill: var(--text-primary);
}

.lang-selector {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 6px 8px;
    font-size: 12px;
    color: var(--text-primary);
    cursor: pointer;
}

.lang-selector:focus {
    outline: none;
    border-color: var(--ton-blue);
}

[dir="rtl"] {
    direction: rtl;
}

[dir="rtl"] .header-right {
    flex-direction: row-reverse;
}

[dir="rtl"] .bag-id {
    flex-direction: row-reverse;
}

main {
    flex: 1;
    padding: 20px 12px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.hero {
    text-align: center;
    margin-bottom: 32px;
}

.hero-img {
    height: 120px;
    width: auto;
    filter: drop-shadow(1px 0 0 #000) drop-shadow(-1px 0 0 #000) drop-shadow(0 1px 0 #000) drop-shadow(0 -1px 0 #000);
}

[data-theme="dark"] .hero-img {
    filter: none;
}

.hero-title {
    margin-top: 16px;
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}


.search-box {
    margin-bottom: 16px;
    display: flex;
    gap: 10px;
    justify-content: center;
}

.search-box input {
    padding: 12px 20px;
    font-size: 14px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--text-primary);
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.search-box input::placeholder {
    color: var(--text-secondary);
}

.search-box input:focus {
    outline: none;
    border-color: var(--ton-blue);
    box-shadow: 0 4px 20px rgba(0, 136, 204, 0.25);
}

.search-box button {
    padding: 12px 28px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    background: rgba(0, 136, 204, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    box-shadow: 0 4px 16px rgba(0, 136, 204, 0.3);
    transition: all 0.2s ease;
}

.search-box button:hover {
    background: rgba(0, 136, 204, 0.95);
    box-shadow: 0 6px 24px rgba(0, 136, 204, 0.4);
    transform: translateY(-1px);
}

.categories {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    overflow-x: auto;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    justify-content: center;
}

.categories::-webkit-scrollbar {
    display: none;
}

.categories label {
    flex-shrink: 0;
    padding: 10px 18px;
    background: var(--bg-white);
    border-radius: var(--radius-pill);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    gap: 6px;
}

.cat-icon {
    width: 16px;
    height: 16px;
}

.categories label:hover {
    background: var(--border-color);
}

.categories input[type="radio"] {
    display: none;
}

.categories input[type="radio"]:checked + span {
    background: var(--ton-blue);
    color: #fff;
}

.categories label:has(input:checked) {
    background: var(--ton-blue);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 152, 234, 0.3);
}

.table-wrapper {
    background: var(--bg-white);
    border-radius: var(--radius-md);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    text-align: left;
    padding: 12px 8px;
}

th {
    background: var(--bg-white);
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

td {
    border-bottom: 1px solid var(--border-color);
}

tr:last-child td {
    border-bottom: none;
}

tr.clickable-row {
    cursor: pointer;
}

tr.clickable-row:hover td {
    background: var(--hover-bg);
}

.type-icon {
    font-size: 18px;
}

.type-svg {
    width: 20px;
    height: 20px;
    stroke: var(--text-secondary);
}

.bag-name {
    font-weight: 500;
    color: var(--text-primary);
}

.bag-id {
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.bag-id:hover {
    color: var(--ton-blue);
}

.copy-icon {
    width: 14px;
    height: 14px;
    fill: var(--text-secondary);
    flex-shrink: 0;
    transition: fill 0.2s;
}

.bag-id:hover .copy-icon {
    fill: var(--ton-blue);
}

footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    color: var(--text-secondary);
    font-size: 13px;
    border-top: 1px solid var(--border-color);
}

footer a {
    color: var(--text-secondary);
}

footer a:hover {
    color: var(--ton-blue);
}

main h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

#connect-msg {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

#upload-form {
    justify-content: center;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    background: var(--bg-white);
    padding: 20px;
    border-radius: var(--radius-md);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

#upload-form input,
#upload-form select {
    padding: 12px 20px;
    font-size: 14px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--text-primary);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

#upload-form input::placeholder {
    color: var(--text-secondary);
}

#upload-form input:focus,
#upload-form select:focus {
    outline: none;
    border-color: var(--ton-blue);
    box-shadow: 0 4px 20px rgba(0, 136, 204, 0.25);
}

#upload-form input[type="text"] {
    width: 250px;
}

#upload-form input#bag-id {
    width: 100%;
    max-width: 550px;
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
}

#upload-form select {
    width: 160px;
}

#upload-form button {
    padding: 14px 32px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    background: rgba(0, 136, 204, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    box-shadow: 0 4px 16px rgba(0, 136, 204, 0.3);
    transition: all 0.2s ease;
}

#upload-form button:hover {
    background: rgba(0, 136, 204, 0.95);
    box-shadow: 0 6px 24px rgba(0, 136, 204, 0.4);
    transform: translateY(-1px);
}

#upload-status {
    width: 100%;
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.bag-detail {
    margin: 0 auto;
    max-width: 800px;
}

.bag-header {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.bag-category {
    display: inline-block;
    padding: 6px 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-pill);
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: capitalize;
}

.bag-header h1 {
    font-size: 20px;
    font-weight: 600;
    word-break: break-word;
}

.stats-grid {
    margin-bottom: 12px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.stat-card {
    background: var(--bg-white);
    border-radius: var(--radius-sm);
    padding: 14px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.stat-value {
    display: block;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.uploader-section {
    background: var(--bg-white);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
}

.uploader-value {
    flex: 1;
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 11px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.uploader-value a {
    color: var(--ton-blue);
}

.info-label {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 13px;
    white-space: nowrap;
}

.bag-id-section {
    background: var(--bg-white);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.bag-id-section .info-label {
    display: block;
    margin-bottom: 8px;
}

.bag-id-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bag-id-row code {
    flex: 1;
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 11px;
    color: var(--text-primary);
    background: var(--bg-secondary);
    padding: 10px;
    border-radius: var(--radius-sm);
    word-break: break-all;
}

.copy-btn {
    background: var(--bg-secondary);
    border: none;
    padding: 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s;
}

.copy-btn:hover {
    background: var(--border-color);
}

.copy-btn svg {
    fill: var(--text-secondary);
    display: block;
}

.copy-btn.copied svg {
    fill: var(--ton-blue);
}

.files-section {
    background: var(--bg-white);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.files-section h2 {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.files-list {
    max-height: 400px;
    overflow-y: auto;
}

.file-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
    font-size: 13px;
}

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

.file-name {
    word-break: break-all;
    flex: 1;
}

.file-size {
    color: var(--text-secondary);
    white-space: nowrap;
}

.loading, .no-files {
    color: var(--text-secondary);
    text-align: center;
    padding: 20px;
}

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

.faq-title {
    font-size: 28px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 32px;
}

.faq-item {
    background: var(--bg-white);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.faq-item h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.faq-item p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.bag-not-found {
    text-align: center;
    padding: 60px 20px;
}

.bag-not-found p {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 16px;
}

@media (max-width: 768px) {
    header {
        padding: 12px 16px;
    }

    .logo {
        font-size: 18px;
    }

    .header-right a {
        padding: 8px 12px;
        font-size: 13px;
    }

    main {
        padding: 16px;
    }

    .search-box {
        flex-direction: column;
    }

    .search-box input {
        max-width: 100%;
    }

    .search-box button {
        width: 100%;
    }

    .categories {
        margin: 0 -16px 16px -16px;
        padding: 0 16px 8px 16px;
    }

    th, td {
        padding: 12px;
        font-size: 13px;
    }

    th:nth-child(4), td:nth-child(4),
    th:nth-child(5), td:nth-child(5),
    th:nth-child(6), td:nth-child(6) {
        display: none;
    }

    .bag-name {
        display: block;
        max-width: 180px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .bag-id code {
        display: inline-block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 100px;
        vertical-align: middle;
    }

    #upload-form {
    justify-content: center;
        flex-direction: column;
    }

    #upload-form input[type="text"],
    #upload-form input#bag-id,
    #upload-form select,
    #upload-form button {
        width: 100%;
        max-width: 100%;
    }
}

/* Deactivate section */
.deactivate-section {
    margin-top: 16px;
    padding: 16px;
    background: rgba(255, 59, 48, 0.1);
    border-radius: var(--radius-sm);
    text-align: center;
}

.deactivate-btn {
    padding: 12px 28px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    background: rgba(255, 59, 48, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    box-shadow: 0 4px 16px rgba(255, 59, 48, 0.3);
    transition: all 0.2s ease;
}

.deactivate-btn:hover {
    background: rgba(255, 59, 48, 0.95);
    box-shadow: 0 6px 24px rgba(255, 59, 48, 0.4);
    transform: translateY(-1px);
}

.deactivate-status {
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Bag Preview in Add page */
.bag-preview {
    width: 100%;
    flex-basis: 100%;
    margin-top: 20px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
}

.bag-preview h3 {
    margin: 0 0 16px 0;
    font-size: 16px;
    color: var(--text-primary);
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.preview-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.preview-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.preview-value {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
    word-break: break-word;
}

.preview-files-list {
    margin-top: 16px;
    max-height: 200px;
    overflow-y: auto;
    font-size: 13px;
}

.preview-files-list .file-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.preview-files-list .file-name {
    color: var(--text-primary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.preview-files-list .file-size {
    color: var(--text-secondary);
    margin-left: 12px;
    flex-shrink: 0;
}

@media (max-width: 480px) {
    .preview-grid {
        grid-template-columns: 1fr;
    }
}

/* Skeleton Loading */
@keyframes skeleton-shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-secondary) 25%,
        var(--hover-bg) 50%,
        var(--bg-secondary) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

.skeleton-text {
    height: 14px;
    border-radius: 4px;
}

.skeleton-text.skeleton-sm {
    width: 40px;
}

.skeleton-text.skeleton-md {
    width: 80px;
}

.skeleton-text.skeleton-lg {
    width: 140px;
}

.skeleton-text.skeleton-xl {
    width: 200px;
}

.skeleton-row td {
    padding: 12px 8px;
}

.skeleton-icon {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.skeleton-stat-value {
    width: 60px;
    height: 24px;
    margin: 0 auto 4px;
    border-radius: 4px;
}

.skeleton-stat-label {
    width: 50px;
    height: 12px;
    margin: 0 auto;
    border-radius: 4px;
}

.skeleton-file-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.skeleton-file-row:last-child {
    border-bottom: none;
}

.skeleton-file-name {
    height: 14px;
    width: 60%;
    border-radius: 4px;
}

.skeleton-file-size {
    height: 14px;
    width: 50px;
    border-radius: 4px;
}

.skeleton-badge {
    width: 70px;
    height: 28px;
    border-radius: var(--radius-pill);
}

.skeleton-title {
    width: 200px;
    height: 24px;
    border-radius: 4px;
}

.skeleton-code {
    width: 100%;
    height: 36px;
    border-radius: var(--radius-sm);
}

.skeleton-uploader {
    width: 70%;
    height: 14px;
    border-radius: 4px;
}

/* Fade transition for content */
.content-loading {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.content-loaded {
    opacity: 1;
}
