/* EnvVault - Retro NES / Game Boy Grayscale Theme */

@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');

:root {
    /* Grayscale palette inspired by Game Boy */
    --black: #0f0f0f;
    --dark: #2a2a2a;
    --mid-dark: #4a4a4a;
    --mid: #6e6e6e;
    --mid-light: #9a9a9a;
    --light: #c8c8c8;
    --off-white: #e0e0e0;
    --white: #f0f0f0;

    /* Semantic colors */
    --bg: #1a1a1a;
    --surface: #222222;
    --surface-raised: #2e2e2e;
    --text: #e0e0e0;
    --text-dim: #9a9a9a;
    --border: #4a4a4a;
    --border-light: #3a3a3a;

    /* Accent - muted green (Game Boy screen tint) */
    --accent: #8bac0f;
    --accent-dim: #5a7a00;
    --danger: #cc4444;
    --danger-dim: #993333;
    --success: #8bac0f;
    --warning: #ccaa44;

    /* Pixel border style */
    --pixel-border: 4px solid var(--text);
    --pixel-border-dim: 4px solid var(--border);
    --pixel-shadow: 4px 4px 0px var(--black);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: rgba(139, 172, 15, 0.2);
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: 'VT323', monospace;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 18px;
    image-rendering: pixelated;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* Scanline overlay effect */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.08) 2px,
        rgba(0, 0, 0, 0.08) 4px
    );
    pointer-events: none;
    z-index: 9999;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* ============ HEADER ============ */
.header {
    background: var(--black);
    border-bottom: var(--pixel-border);
    padding: 0.75rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}

.header-content {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-family: 'VT323', monospace;
    font-size: 28px;
    color: var(--accent);
    text-decoration: none;
    text-shadow: 2px 2px 0px var(--accent-dim);
    letter-spacing: 3px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo img {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
    filter: invert(66%) sepia(50%) saturate(700%) hue-rotate(30deg) brightness(95%);
}

.logo:hover {
    color: var(--white);
    text-shadow: 2px 2px 0px var(--mid);
}

.logo:hover img {
    filter: brightness(2);
}

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

.nav-link {
    color: var(--text-dim);
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    font-size: 18px;
    border: 2px solid transparent;
    transition: none;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.nav-link:hover {
    color: var(--white);
    border-color: var(--text-dim);
    background: var(--surface);
}

/* ============ CARDS / CONTAINERS ============ */
.card {
    background: var(--surface);
    border: var(--pixel-border);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--pixel-shadow);
    position: relative;
}

/* Inner bevel effect */
.card::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    border: 2px solid var(--border-light);
    pointer-events: none;
}

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

.card-title {
    font-size: 22px;
    color: var(--accent);
    text-shadow: 1px 1px 0px var(--accent-dim);
    letter-spacing: 1px;
}

/* ============ FORMS ============ */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 16px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.form-input {
    width: 100%;
    padding: 0.75rem;
    border: 3px solid var(--border);
    border-radius: 0;
    background: var(--black);
    color: var(--accent);
    font-family: 'VT323', monospace;
    font-size: 18px;
    outline: none;
    transition: none;
    min-height: 44px;
    -webkit-appearance: none;
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-dim);
}

.form-input::placeholder {
    color: var(--mid-dark);
}

.form-textarea {
    min-height: 80px;
    resize: vertical;
}

select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%239a9a9a' stroke-width='2'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
    cursor: pointer;
}

/* ============ BUTTONS ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1.25rem;
    border: 3px solid var(--white);
    background: var(--surface-raised);
    color: var(--white);
    font-family: 'VT323', monospace;
    font-size: 18px;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 3px 3px 0px var(--black);
    position: relative;
    transition: none;
    letter-spacing: 1px;
    min-height: 44px;
    -webkit-appearance: none;
}

.btn:hover {
    background: var(--mid-dark);
}

.btn:active {
    box-shadow: 1px 1px 0px var(--black);
    transform: translate(2px, 2px);
}

.btn-primary {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--accent);
    color: var(--black);
}

.btn-secondary {
    background: var(--dark);
    border-color: var(--mid);
    color: var(--light);
}

.btn-secondary:hover {
    background: var(--mid-dark);
    border-color: var(--light);
    color: var(--white);
}

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

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

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 16px;
    box-shadow: 2px 2px 0px var(--black);
}

.btn-sm:active {
    box-shadow: 1px 1px 0px var(--black);
    transform: translate(1px, 1px);
}

/* ============ AUTH PAGES ============ */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--bg);
}

.auth-card {
    background: var(--surface);
    border: var(--pixel-border);
    padding: 2rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 6px 6px 0px var(--black);
    position: relative;
}

.auth-card::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    border: 2px solid var(--border-light);
    pointer-events: none;
}

.auth-title {
    font-size: 32px;
    text-align: center;
    margin-bottom: 0.5rem;
    color: var(--accent);
    text-shadow: 2px 2px 0px var(--accent-dim);
    letter-spacing: 2px;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-dim);
    margin-bottom: 2rem;
    font-size: 16px;
    line-height: 1.6;
}

/* ============ TABLE ============ */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table thead {
    background: var(--dark);
}

.table th {
    text-align: left;
    padding: 0.625rem 0.75rem;
    font-size: 16px;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 2px;
    border-bottom: 2px solid var(--border);
}

.table td {
    padding: 0.625rem 0.75rem;
    font-size: 16px;
    border-bottom: 1px dashed var(--border-light);
    color: var(--light);
}

.table tbody tr:hover {
    background: var(--surface-raised);
}

/* ============ APPS GRID ============ */
.apps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.app-card {
    border: 2px solid var(--border);
    padding: 1.25rem;
    background: var(--dark);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.app-card:hover {
    border-color: var(--accent);
    background: var(--surface-raised);
}

.app-card-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 0.5rem;
    letter-spacing: 1px;
}

.app-card-description {
    font-size: 14px;
    color: var(--text-dim);
    line-height: 1.4;
    margin-bottom: 0.5rem;
}

.app-card-github {
    font-size: 13px;
    color: var(--accent);
    text-decoration: underline;
}

.app-card-github:hover {
    opacity: 0.85;
}

.environment-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.badge-selected {
    background: var(--accent) !important;
    color: var(--black) !important;
    border-color: var(--accent) !important;
}

/* ============ VARIABLE LIST ============ */
.variable-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border: 2px solid var(--border);
    margin-bottom: 0.5rem;
    background: var(--dark);
    transition: none;
}

.variable-item:hover {
    border-color: var(--accent);
    background: var(--surface-raised);
}

.variable-info {
    flex: 1;
}

.variable-name {
    font-size: 18px;
    color: var(--accent);
    margin-bottom: 0.25rem;
    letter-spacing: 1px;
}

.variable-meta {
    font-size: 14px;
    color: var(--text-dim);
}

.variable-actions {
    display: flex;
    gap: 0.375rem;
}

/* ============ BADGES ============ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.625rem;
    font-size: 14px;
    border: 2px solid;
    letter-spacing: 1px;
}

.badge-primary {
    border-color: var(--accent);
    color: var(--accent);
    background: transparent;
}

.badge-environment {
    border-color: var(--warning);
    color: var(--warning);
    background: transparent;
}

.badge-clickable {
    cursor: pointer;
}
.badge-clickable:hover {
    opacity: 0.85;
}

.badge-clickable {
    cursor: pointer;
}
.badge-clickable:hover {
    opacity: 0.85;
}

.badge-success {
    border-color: var(--success);
    color: var(--success);
    background: transparent;
}

.badge-secondary {
    border-color: var(--text-dim);
    color: var(--text-dim);
    background: transparent;
}

/* Variable type badges */
.badge-type-api_key {
    border-color: #4a9eff;
    color: #4a9eff;
    background: transparent;
}

.badge-type-password {
    border-color: #ff6b6b;
    color: #ff6b6b;
    background: transparent;
}

.badge-type-credential {
    border-color: #c084fc;
    color: #c084fc;
    background: transparent;
}

.badge-type-session_token {
    border-color: #fbbf24;
    color: #fbbf24;
    background: transparent;
}

.badge-type-config {
    border-color: #6ee7b7;
    color: #6ee7b7;
    background: transparent;
}

/* Freshness indicators */
.freshness-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: 0.5rem;
    vertical-align: middle;
}
.freshness-fresh { background: #22c55e; }
.freshness-stale { background: #eab308; }
.freshness-expired { background: #ef4444; }

/* ============ ALERTS ============ */
.alert {
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
    font-size: 16px;
    border: 3px solid;
    line-height: 1.6;
}

.alert-success {
    background: rgba(139, 172, 15, 0.1);
    color: var(--accent);
    border-color: var(--accent);
}

.alert-danger {
    background: rgba(204, 68, 68, 0.1);
    color: var(--danger);
    border-color: var(--danger);
}

.alert-warning {
    background: rgba(204, 170, 68, 0.1);
    color: var(--warning);
    border-color: var(--warning);
}

/* ============ BANNERS ============ */
.tutorial-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

/* ============ EMPTY STATE ============ */
.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
}

.empty-state-icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 20px;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
}

.empty-state-text {
    color: var(--mid);
    font-size: 16px;
    margin-bottom: 1.5rem;
}

/* ============ MODALS ============ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    z-index: 1000;
}

.modal {
    background: var(--surface);
    border: var(--pixel-border);
    padding: 1.5rem;
    max-width: 500px;
    width: 100%;
    box-shadow: 6px 6px 0px var(--black);
    position: relative;
}

.modal::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    border: 2px solid var(--border-light);
    pointer-events: none;
}

.modal-header {
    margin-bottom: 1.25rem;
}

.modal-title {
    font-size: 22px;
    color: var(--accent);
    text-shadow: 1px 1px 0px var(--accent-dim);
}

.modal-footer {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.25rem;
}

/* ============ UTILITIES ============ */
.text-center {
    text-align: center;
}

.mt-2 {
    margin-top: 1rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.hidden {
    display: none !important;
}

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

::-webkit-scrollbar-track {
    background: var(--dark);
    border-left: 2px solid var(--border);
}

::-webkit-scrollbar-thumb {
    background: var(--mid-dark);
    border: 2px solid var(--border);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--mid);
}

/* ============ LINKS ============ */
a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    color: var(--white);
    text-decoration: underline;
}

/* ============ CODE BLOCKS ============ */
code {
    font-family: 'VT323', monospace;
    font-size: 16px;
    background: var(--black);
    color: var(--accent);
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border);
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
    body {
        font-size: 16px;
    }

    .container {
        padding: 0.75rem;
        padding-left: calc(0.75rem + env(safe-area-inset-left, 0px));
        padding-right: calc(0.75rem + env(safe-area-inset-right, 0px));
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    }

    /* Header: keep row layout, just tighten */
    .header-content {
        padding: 0 0.75rem;
    }

    .logo {
        font-size: 22px;
    }

    .logo img {
        width: 24px;
        height: 24px;
    }

    .nav {
        gap: 0;
    }

    .nav-link {
        padding: 0.5rem;
        font-size: 16px;
    }

    /* Auth pages */
    .auth-container {
        padding: 1rem;
        padding-top: calc(1rem + env(safe-area-inset-top, 0px));
        padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
        align-items: flex-start;
        padding-top: 15vh;
    }

    .auth-card {
        padding: 1.25rem;
        box-shadow: 4px 4px 0px var(--black);
        max-width: 100%;
    }

    .auth-title {
        font-size: 26px;
    }

    /* Cards */
    .card {
        padding: 1rem;
        box-shadow: 3px 3px 0px var(--black);
        margin-bottom: 1rem;
    }

    .card-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }

    .card-header .btn,
    .card-header div {
        width: 100%;
    }

    .card-header div {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .card-header .btn {
        justify-content: center;
    }

    .card-title {
        font-size: 20px;
    }

    /* Variables */
    .variable-item {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        padding: 1rem 0.75rem;
    }

    .variable-actions {
        display: flex;
        gap: 0.5rem;
    }

    .variable-actions .btn {
        flex: 1;
    }

    /* Tables - horizontal scroll */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -1rem;
        padding: 0 1rem;
    }

    .table {
        font-size: 14px;
        min-width: 500px;
    }

    /* Buttons */
    .btn {
        font-size: 16px;
        padding: 0.5rem 1rem;
    }

    /* Modals - near full screen on mobile */
    .modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .modal {
        padding: 1.25rem;
        margin: 0;
        max-width: 100%;
        border-left: none;
        border-right: none;
        border-bottom: none;
        box-shadow: none;
        max-height: 90vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
    }

    .modal::before {
        border-left: none;
        border-right: none;
        border-bottom: none;
    }

    .modal-footer {
        flex-direction: column-reverse;
    }

    .modal-footer .btn {
        width: 100%;
        justify-content: center;
    }

    /* Banners */
    .tutorial-banner {
        flex-direction: column;
        align-items: stretch;
    }

    .tutorial-banner .btn {
        width: 100%;
        justify-content: center;
    }

    /* Badges */
    .badge {
        font-size: 13px;
    }

    /* Alerts */
    .alert {
        font-size: 15px;
    }

    /* Code */
    code {
        font-size: 14px;
        word-break: break-all;
    }
}

/* Extra small screens (iPhone SE, etc.) */
@media (max-width: 375px) {
    .auth-container {
        padding-top: 10vh;
    }

    .auth-title {
        font-size: 22px;
    }

    .auth-subtitle {
        font-size: 14px;
    }

    .logo {
        font-size: 20px;
    }

    .card-title {
        font-size: 18px;
    }

    .nav-link {
        font-size: 14px;
    }
}
