/* ================================
   Storage Inspector - #3989ff Theme (Mobile First Responsive)
================================ */

:root {
    --#3989ff-primary: #4e91dd;
    --#3989ff-light: #7dbaff;
    --#3989ff-dark: #18559a;
    --#3989ff-bg-glow: rgba(157, 78, 221, 0.15);
    --border-color: rgba(255, 255, 255, 0.1);
    --border-hover: rgba(199, 125, 255, 0.3);
    --card-bg: linear-gradient(145deg, rgba(20, 16, 28, 0.95), rgba(12, 10, 18, 0.98));
}

html {
    box-sizing: border-box;
}

*, *:before, *:after {
    box-sizing: inherit;
}

body {
    margin: 0;
    padding: 0;
    background: #070a0d;
    color: #e0e0e0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow-x: hidden;
}

.background-glow {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at 50% 15%, var(--#3989ff-bg-glow) 0%, transparent 65%);
    pointer-events: none;
    z-index: 0;
}

.page-viewport {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1;
}

/* Header & Nav */
.page-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 12px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: #fff;
}

.brand-symbol {
    color: var(--#3989ff-light);
    font-size: 18px;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.brand-main {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 1px;
}

.brand-sub {
    font-size: 9px;
    color: var(--#3989ff-light);
    letter-spacing: 2px;
}

.top-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--#3989ff-light);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
}

.top-back-btn:hover {
    background: rgba(157, 78, 221, 0.15);
    border-color: var(--#3989ff-light);
    color: #fff;
}

/* Page Content */
.page-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
}

.tool-head {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.badge-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--#3989ff-light);
    letter-spacing: 1.5px;
}

.tool-head h1 {
    font-size: 22px;
    font-weight: 800;
    margin: 0;
    color: #ffffff;
}

.dashboard-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
    width: 100%;
}

/* Controls */
.control-row {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

@media (min-width: 640px) {
    .control-row {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}

.storage-type-toggle {
    display: flex;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 4px;
    gap: 4px;
    width: 100%;
}

@media (min-width: 640px) {
    .storage-type-toggle {
        width: auto;
    }
}

.toggle-pill {
    flex: 1;
    background: transparent;
    border: none;
    color: #a0a0a0;
    font-size: 12px;
    font-weight: 700;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.toggle-pill.active {
    background: var(--#3989ff-primary);
    color: #ffffff;
    box-shadow: 0 2px 10px rgba(157, 78, 221, 0.4);
}

.action-buttons-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    width: 100%;
}

@media (min-width: 640px) {
    .action-buttons-group {
        width: auto;
    }
}

.secondary-action-btn, .danger-action-btn {
    flex: 1;
    min-width: calc(50% - 4px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

@media (min-width: 480px) {
    .secondary-action-btn, .danger-action-btn {
        flex: initial;
        min-width: auto;
    }
}

.secondary-action-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: #ffffff;
}

.secondary-action-btn:hover {
    background: rgba(157, 78, 221, 0.2);
    border-color: var(--#3989ff-light);
}

.secondary-action-btn.primary-accent {
    background: rgba(157, 78, 221, 0.25);
    border-color: var(--#3989ff-primary);
    color: var(--#3989ff-light);
}

.secondary-action-btn.primary-accent:hover {
    background: var(--#3989ff-primary);
    color: #ffffff;
}

.danger-action-btn {
    background: rgba(255, 77, 77, 0.1);
    border: 1px solid rgba(255, 77, 77, 0.3);
    color: #ff6b6b;
}

.danger-action-btn:hover {
    background: rgba(255, 77, 77, 0.25);
    border-color: #ff4d4d;
    color: #fff;
}

/* Search and Stats Bar */
.search-stats-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

@media (min-width: 640px) {
    .search-stats-row {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

.custom-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 14px;
    color: #ffffff;
    font-size: 13px;
    outline: none;
    transition: all 0.2s ease;
}

.custom-input:focus {
    border-color: var(--#3989ff-light);
    background: rgba(157, 78, 221, 0.08);
    box-shadow: 0 0 0 3px rgba(157, 78, 221, 0.15);
}

.stats-badge {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: #a0a0a0;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    padding: 8px 14px;
    border-radius: 10px;
    white-space: nowrap;
}

.stats-badge strong {
    color: var(--#3989ff-light);
}

.badge-divider {
    margin: 0 8px;
    opacity: 0.3;
}

/* Storage Table Component */
.table-container {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    max-height: 480px;
    overflow-y: auto;
    overflow-x: hidden;
}

.storage-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
}

.storage-table th {
    background: rgba(15, 12, 22, 0.95);
    color: var(--#3989ff-light);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 2;
}

.col-key { width: 30%; }
.col-val { width: 48%; }
.col-actions { width: 22%; text-align: right; }

/* Responsive portrait cards layout for small screens */
@media (max-width: 639px) {
    .storage-table, .storage-table thead, .storage-table tbody, .storage-table th, .storage-table td, .storage-table tr {
        display: block;
    }
    
    .storage-table thead {
        display: none; /* Hide standard headers on mobile portrait */
    }

    .storage-table tr {
        padding: 12px;
        border-bottom: 1px solid var(--border-color);
        background: rgba(255, 255, 255, 0.01);
        margin-bottom: 6px;
    }

    .storage-table td {
        padding: 4px 0;
        border: none;
        word-break: break-word;
    }

    .key-cell {
        font-size: 14px;
        margin-bottom: 6px;
    }

    .val-cell {
        max-width: 100% !important;
        white-space: normal !important;
        font-size: 12px;
        color: #cccccc;
        background: rgba(0, 0, 0, 0.2);
        padding: 8px !important;
        border-radius: 6px;
        margin-bottom: 8px;
    }

    .actions-cell {
        display: flex;
        justify-content: flex-end;
        gap: 6px;
        padding-top: 6px !important;
    }
}

.storage-table td {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.storage-table tr:hover {
    background: rgba(157, 78, 221, 0.05);
}

.key-cell {
    font-weight: 700;
    color: #ffffff;
    word-break: break-all;
}

.val-cell {
    color: #b8b8b8;
    max-width: 280px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.actions-cell {
    text-align: right;
    white-space: nowrap;
}

.row-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: #e0e0e0;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
    margin-left: 4px;
    transition: all 0.2s ease;
}

.row-btn:hover {
    background: rgba(157, 78, 221, 0.25);
    border-color: var(--#3989ff-light);
    color: #fff;
}

.row-btn.delete {
    color: #ff6b6b;
    border-color: rgba(255, 77, 77, 0.2);
}

.row-btn.delete:hover {
    background: rgba(255, 77, 77, 0.2);
    border-color: #ff4d4d;
    color: #fff;
}

.empty-state {
    padding: 40px 16px;
    text-align: center;
    color: #888888;
    font-size: 13px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(5, 3, 8, 0.82);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 16px;
}

.modal-card {
    background: #0e141a;
    border: 1px solid var(--#3989ff-primary);
    border-radius: 18px;
    padding: 20px;
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 30px rgba(157, 78, 221, 0.2);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-card h3 {
    margin: 0;
    font-size: 16px;
    color: #ffffff;
}

.icon-close-btn {
    background: transparent;
    border: none;
    color: #888;
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
}

.icon-close-btn:hover {
    color: #fff;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.m-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--#3989ff-light);
    letter-spacing: 1px;
}

.custom-textarea {
    resize: vertical;
    min-height: 120px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
}

.primary-btn {
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
    background: var(--#3989ff-primary);
    color: #ffffff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(157, 78, 221, 0.4);
    transition: all 0.2s ease;
}

.primary-btn:hover {
    background: var(--#3989ff-light);
    box-shadow: 0 4px 22px rgba(199, 125, 255, 0.5);
}

/* Footer */
.site-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 0 2px 0;
    border-top: 1px solid rgba(57, 137, 255, 0.15);
    font-size: 8px;
    color: #71717a;
    width: 100%;
    margin-top: auto;
    flex-shrink: 0;
    gap: 1px;
}

.footer-brand-info {
    display: flex;
    align-items: center;
    gap: 4px;
}

.footer-icon-logo {
    width: 11px;
    height: 11px;
    object-fit: contain;
    opacity: 0.85;
}

.footer-brand-name {
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 1px;
    color: #b4d7fe;
}

.footer-tagline {
    color: #a1a1aa;
    font-size: 7.5px;
}

.footer-copyright {
    color: #71717a;
    font-size: 7px;
    width: 100%;
    text-align: center;
}