/* S3 Explorer - Minimal Dark Theme */

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: rgba(26, 26, 38, 0.8);
    --accent: #6366f1;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: rgba(255, 255, 255, 0.08);
    --radius: 12px;
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at 20% 0%, rgba(99, 102, 241, 0.12) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

.header-content {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-icon {
    width: 24px;
    height: 24px;
    color: var(--accent);
}

.logo-text {
    font-size: 1.125rem;
    font-weight: 600;
}

/* Main */
.main {
    flex: 1;
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    width: 100%;
}

/* Search */
.search-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 4px;
    transition: border-color 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--accent);
}

.s3-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    color: var(--text-primary);
    font-family: inherit;
    min-width: 0;
}

.s3-input::placeholder {
    color: var(--text-muted);
}

.region-select {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    outline: none;
}

.browse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.75rem;
    cursor: pointer;
    transition: opacity 0.2s;
}

.browse-btn:hover {
    opacity: 0.9;
}

.browse-btn svg {
    width: 18px;
    height: 18px;
}

/* Results */
.results-section {
    margin-top: 1.5rem;
    animation: fadeIn 0.3s;
}

.results-section.hidden {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.breadcrumb-content {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
    font-size: 0.875rem;
    flex: 1;
    line-height: 1.8;
}

.bucket-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.breadcrumb-item {
    color: var(--text-secondary);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.breadcrumb-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.breadcrumb-item.active {
    color: var(--text-primary);
    font-weight: 500;
}

.breadcrumb-separator {
    color: var(--text-muted);
}

/* Browser */
.browser-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.browser-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.browser-header.hidden {
    display: none;
}

.item-count {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* States */
.loading,
.error,
.empty {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-muted);
}

.loading.hidden,
.error.hidden,
.empty.hidden {
    display: none;
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.error {
    color: #ef4444;
}

/* Data Table */
.file-list-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 500;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 0.625rem 1rem;
    vertical-align: middle;
}

/* Remove border for folder rows */
.data-table tbody tr.folder td {
    border-bottom: none;
}

/* Add border only for file rows */
.data-table tbody tr.file td {
    border-bottom: 1px solid var(--border);
}

.data-table tbody tr.file:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.data-table tbody tr.folder:hover {
    background: rgba(99, 102, 241, 0.06);
}

.col-name {
    min-width: 280px;
}

.col-modified {
    width: 100px;
    white-space: nowrap;
}

.col-timestamp {
    width: 140px;
    white-space: nowrap;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.6875rem;
    color: var(--text-muted);
}

.col-size {
    width: 70px;
    text-align: right;
    white-space: nowrap;
}

.col-actions {
    width: 100px;
    text-align: right;
}

.folder-link,
.file-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.folder-link {
    cursor: pointer;
    color: var(--accent);
}

.folder-link:hover {
    text-decoration: underline;
}

.item-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.folder-icon {
    color: var(--accent);
}

.file-icon {
    color: var(--text-muted);
}

.actions-cell {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
}

.action-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.75rem;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.15s;
}

.action-link:hover {
    color: var(--accent);
    background: rgba(99, 102, 241, 0.1);
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    font-size: 0.75rem;
}

.page-info {
    color: var(--text-muted);
}

.page-controls {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.page-btn {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.375rem 0.625rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.page-btn:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-num {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    min-width: 24px;
    text-align: center;
}

.page-num:hover {
    background: rgba(255, 255, 255, 0.05);
}

.page-num.active {
    background: var(--accent);
    color: white;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 700px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 0.875rem;
    font-weight: 500;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.preview-content {
    flex: 1;
    overflow: auto;
    padding: 1rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8125rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text-secondary);
    background: var(--bg-primary);
    margin: 0;
}

.modal-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
    text-align: right;
}

.download-btn {
    display: inline-block;
    background: var(--accent);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
}

.download-btn:hover {
    opacity: 0.9;
}

/* Metadata View */
.metadata-view {
    font-family: 'Inter', sans-serif;
    background: var(--bg-secondary);
}

.meta-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.meta-section {
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 1rem;
}

.meta-title {
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.meta-item {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
}

.meta-item span {
    color: var(--text-muted);
    margin-right: 0.5rem;
}

.meta-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}

.meta-table th,
.meta-table td {
    text-align: left;
    padding: 0.375rem 0.5rem;
    border-bottom: 1px solid var(--border);
}

.meta-table th {
    color: var(--text-muted);
    font-weight: 500;
}

.meta-table td {
    color: var(--text-secondary);
}

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

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* Responsive */
@media (max-width: 640px) {
    .main {
        padding: 1rem;
    }

    .search-card {
        padding: 1rem;
    }

    .input-wrapper {
        flex-wrap: wrap;
    }

    .s3-input {
        width: 100%;
    }

    .region-select {
        flex: 1;
    }
}