:root {
    /* Cyber Theme Palette */
    --bg-body: #0d0e12;
    --bg-container: #0d0e12;
    --panel-bg: #16181d;
    
    --text-main: #e0e0e0;
    --text-bright: #ffffff;
    --text-muted: #8b9bb4;
    
    --accent-primary: #0e62c2; 
    --accent-cyan: #00f0ff;    
    --accent-danger: #ff2a6d;
    --accent-success: #05d5fa;
    
    --border-color: #333;
    
    --font-stack: 'Courier New', Courier, monospace;

    /* Standardized Animation Config */
    --body-anim-duration: 0.25s;
    --body-anim-delay: 0.0s;
}

/* --- Base Setup --- */
@font-face {
    font-family: 'CustomFont';
    src: url('/font.woff2') format('woff2');
}

* {
    box-sizing: border-box;
    outline: none;
}

html {
    background-color: var(--bg-body);
}

body {
    background-color: var(--bg-body);
    /* Cyber Grid Background Pattern */
    background-image: 
        linear-gradient(rgba(14, 98, 194, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(14, 98, 194, 0.03) 1px, transparent 1px);
    background-size: 20px 20px;
    
    color: var(--text-main);
    font-family: var(--font-stack);
    margin: 0;
    padding: 0;
    font-size: 14px;
    min-height: 100vh;
    overflow-x: hidden;

    opacity: 0; 
    animation: bodyLoad var(--body-anim-duration) forwards; 
    animation-delay: var(--body-anim-delay); 
}

.content {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* --- Typography --- */
.glow-title {
    display: block;
    position: relative;
    text-align: center;
    background: rgba(14, 98, 194, 0.1);
    color: #fff;
    padding: 20px;
    margin-bottom: 20px;
    font-size: 2.2rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    border: 1px solid var(--accent-primary);
    box-shadow: 0 0 15px rgba(14, 98, 194, 0.2);
    text-shadow: 0 0 10px var(--accent-primary);
    border-radius: 0;
}

/* Decorative Corners for Title */
.glow-title::before, .glow-title::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    border: 2px solid var(--accent-cyan);
    transition: all 0.3s;
}
.glow-title::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.glow-title::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

.section-title {
    font-size: 1.1rem;
    color: var(--accent-cyan);
    background: transparent;
    padding: 0 0 5px 0;
    margin: 30px 0 15px 0;
    border: none;
    border-bottom: 1px solid var(--accent-primary);
    display: flex;
    align-items: center;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: 0;
}

.section-title::before {
    content: '>';
    margin-right: 10px;
    color: var(--accent-primary);
    font-weight: bold;
}

/* Info Section styling */
.info-section {
    margin-top: 10px;
    padding: 10px;
    background: var(--panel-bg);
    border: 1px solid #333;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.info-text {
    margin: 2px 0;
    color: var(--text-muted);
}

/* --- Forms & Buttons --- */
.button-grid {
    display: grid;
    /* Forces exactly 2 columns on mobile, scaling up on desktop */
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.button-grid form {
    margin: 0;
    display: flex;
}

button {
    width: 100%;
    height: 40px; 
    padding: 4px 8px;
    background: var(--panel-bg);
    border: 1px solid #333;
    border-left: 3px solid var(--accent-primary);
    color: var(--text-main);
    font-family: var(--font-stack);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 0;
    
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    white-space: normal; 
    overflow: hidden; 
}

button:hover {
    background: #20242b;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.3);
    color: #fff;
    transform: translateY(-1px);
}

button:active {
    transform: translateY(1px);
}

/* File Input & Button */
input[type="file"] {
    background: var(--panel-bg);
    border: 1px solid #333;
    color: var(--text-muted);
    padding: 5px;
    font-family: var(--font-stack);
    width: 100%;
}

input[type="file"]::file-selector-button {
    background: var(--panel-bg);
    border: 1px solid #333;
    border-left: 3px solid var(--accent-primary);
    color: var(--text-main);
    padding: 8px 12px;
    margin-right: 15px;
    font-family: var(--font-stack);
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s ease;
}

input[type="file"]::file-selector-button:hover {
    background: #20242b;
    border-color: var(--accent-cyan);
    color: #fff;
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.3);
}

input[type="file"]::-webkit-file-upload-button {
    background: var(--panel-bg);
    border: 1px solid #333;
    border-left: 3px solid var(--accent-primary);
    color: var(--text-main);
    padding: 8px 12px;
    margin-right: 15px;
    font-family: var(--font-stack);
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s ease;
    /* Removes default system 3D look */
    -webkit-appearance: none; 
}

input[type="file"]::-webkit-file-upload-button:hover {
    background: #20242b;
    border-color: var(--accent-cyan);
    color: #fff;
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.3);
}

/* Danger Buttons */
button.btn-danger {
    border-left-color: var(--accent-danger);
}
button.btn-danger:hover {
    border-color: var(--accent-danger);
    box-shadow: 0 0 8px rgba(255, 42, 109, 0.3);
}

/* Active/Primary Buttons */
button.btn-primary {
    border-left-color: var(--accent-cyan);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}
button.btn-primary:hover {
    background: var(--accent-cyan);
    color: #000;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-left-color: #555;
}

/* Inputs */
input[type="text"], input[type="password"] {
    background: var(--panel-bg);
    border: 1px solid #333;
    color: var(--text-main);
    padding: 10px;
    width: 100%;
    font-family: var(--font-stack);
    border-radius: 0;
}

label {
    color: var(--text-muted);
    font-size: 0.9em;
}

/* --- Tables --- */
.table-container {
    overflow-x: auto;
    margin-top: 15px;
    border: 1px solid #333;
    background: var(--panel-bg);
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background-color: var(--panel-bg);
    color: var(--text-main);
    white-space: nowrap;
}

th {
    background: rgba(14, 98, 194, 0.2);
    color: var(--accent-cyan);
    padding: 12px;
    text-align: left;
    border-bottom: 2px solid var(--accent-primary);
    font-weight: bold;
}

td {
    padding: 10px 12px;
    border-bottom: 1px solid #2a2a2a;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.05);
}



/* --- Table Layout Proportions --- */
/* Force the table to respect our specific widths */
table {
    table-layout: fixed; 
    width: 100%;
}

/* Allocate width percentages */
.col-ssid { width: 55%; }
.col-mini { width: 12%; } /* For CH and SIG */
.col-medium { width: 40%; } /* For File Size */
.col-btn  { width: 21%; } /* For the Select Button */

/* 1. Squeeze the vertical padding in all cells */
th, td {
    padding: 3px 8px; /* Reduced vertical padding to 3px */
    vertical-align: middle; /* Base baseline centering */
}

/* 2. Kill the invisible Form margins and use Flexbox to perfect the centering */
td.col-btn form {
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center; /* Centers the button horizontally */
    align-items: center;     /* Centers the button vertically */
    height: 100%;            /* Fills the cell so flexbox works perfectly */
}

/* 3. Shrink the Button itself so it doesn't force the row open */
td.col-btn button {
    height: 28px;            /* Forces a compact height */
    padding: 0 12px;
    line-height: 1;          /* Prevents line-height from adding hidden vertical bulk */
    font-size: 0.7rem;       
    margin: 0;
    display: inline-flex;
    align-items: center;
}

/* File List Specific Row Colors */
tr.row-bin {
    background: rgba(14, 98, 194, 0.15);
    color: var(--accent-cyan);
}

tr.row-dir {
    color: var(--accent-success);
    font-weight: bold;
}


/* Alignment Utilities */
.center-text { text-align: center; }
th.col-mini, th.col-btn { text-align: center; } /* Center headers for small columns */

/* Text Truncation for extremely long Wi-Fi names */
.ssid-text {
    font-weight: bold;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* Adds '...' if the SSID is too long */
}

.bssid-text {
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Fix for your Signal Colorization Note */
.color-sig {
    color: var(--accent-success);
}

/* Signal Strength Column Highlight (approximate via nth-child) */
td:nth-child(4) {
    color: var(--accent-success);
}

/* --- Merged Column Logic (SSID + BSSID) --- */
.dual-info-cell {
    cursor: pointer;
    position: relative;
    user-select: none; 
    min-width: 150px;
}

.dual-info-cell .secondary-info { display: none; }
.dual-info-cell:active .primary-info { display: none; }
.dual-info-cell:active .secondary-info {
    display: inline-block;
    font-family: monospace;
}

/* Tiny forms inside tables (Select buttons) */
td button {
    padding: 4px 10px;
    height: auto;
    font-size: 0.7rem;
    border-left: 0;
    border: 1px solid var(--accent-cyan);
    background: transparent;
    color: var(--accent-cyan);
    width: auto;
    display: inline-block;
}

td button:hover {
    background: var(--accent-cyan);
    color: #000;
    box-shadow: none;
    transform: none;
}

/* Selected State for Table Buttons */
td button.btn-primary {
    background: var(--accent-cyan);
    color: #000;
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
    font-weight: bold;
}

/* --- Log Page --- */
.log-container {
    width: 100%;
    height: 400px; 
    background-color: var(--bg-secondary, #1a1a1a); /* Fallback to dark grey */
    color: var(--text-primary, #00ff00); /* Fallback to terminal green */
    border: 1px solid var(--main-color, #ccc);
    overflow-y: auto;
    font-family: monospace;
    padding: 10px;
    box-sizing: border-box;
    white-space: pre-wrap;
  }

  .log-controls {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary, #fff);
  }


/* --- Generic Progress Bar Styling --- */

/* 1. Base Element Reset */
progress {
    -webkit-appearance: none; 
    appearance: none;         
    
    width: 100%;
    height: 20px;             
    vertical-align: baseline; /
    
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    box-sizing: border-box;
}

progress::-webkit-progress-bar {
    background: var(--panel-bg);
    border-radius: 0;
}

progress::-webkit-progress-value {
    background-color: var(--accent-primary);
    box-shadow: 0 0 10px var(--accent-primary); 
    transition: width 0.3s ease; 
}

progress::-moz-progress-bar {
    background-color: var(--accent-primary);
    box-shadow: 0 0 10px var(--accent-primary);
}

progress::-webkit-progress-value {
    background-image: linear-gradient(
        45deg, 
        rgba(255, 255, 255, 0.15) 25%, 
        transparent 25%, 
        transparent 50%, 
        rgba(255, 255, 255, 0.15) 50%, 
        rgba(255, 255, 255, 0.15) 75%, 
        transparent 75%, 
        transparent
    );
    background-size: 40px 40px;
}

/* --- Utility --- */
hr {
    border: 0;
    border-top: 1px solid #333;
    margin: 20px 0;
}

/* Toast Notification*/
#toast {
  position: fixed;
  z-index: 9999;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);

  min-width: 250px; 
  padding: 16px;
  
  background-color: var(--header-bg, #333); 
  color: var(--text-main, #fff);
  border: 1px solid var(--border-color, #555);
  border-radius: 8px;
  
  text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  font-family: inherit;

  visibility: hidden;
  opacity: 0;
  transition: opacity 0.3s ease-in-out, bottom 0.3s ease-in-out;
}

#toast.show {
  visibility: visible;
  opacity: 1;
  bottom: 50px;
}

/* --- Custom Modal / Internal Pop-up --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10000; 
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.modal-overlay.open {
    display: flex;
    opacity: 1;
}

.modal-box {
    background: var(--bg-body);
    border: 1px solid var(--accent-primary);
    box-shadow: 0 0 25px var(--accent-primary), 
                inset 0 0 15px var(--term-dim);
    padding: 20px;
    width: 90%;
    max-width: 400px;
    position: relative;

    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.modal-overlay.open .modal-box {
    transform: scale(1);
}

.modal-header {
    font-size: 1.4rem;
    color: var(--accent-cyan);
    margin-bottom: 15px;
    text-transform: uppercase;
    border-bottom: 1px solid #333;
    padding-bottom: 10px;
    font-weight: bold;
}

.modal-body {
    margin-bottom: 20px;
    color: var(--text-main);
    font-size: 0.95rem;
    line-height: 1.4;
}

/* Custom Input inside Modal */
.modal-body input {
    margin-top: 10px;
    background: var(--panel-bg);
    border: 1px solid var(--accent-primary);
    color: #fff;
    width: 100%;
    padding: 10px;
    font-family: inherit;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Force buttons in modal to not stretch full width */
.modal-footer button {
    width: auto;
    min-width: 80px;
}

/* --- Animations --- */
@keyframes bodyLoad {
    to { opacity: 1; }
}

@keyframes fadein { from { bottom: 0; opacity: 0; } to { bottom: 30px; opacity: 1; } }
@keyframes fadeout { from { bottom: 30px; opacity: 1; } to { bottom: 0; opacity: 0; } }
/* --- Advanced Entry Animations --- */

/* 1. Slide Up */
@keyframes slideUpFade {
    from { 
        opacity: 0;
        transform: translateY(40px); 
    }
    to { 
        opacity: 1;
        transform: translateY(0); 
    }
}

.anim-slide-up {
    animation: slideUpFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    animation-delay: var(--body-anim-delay, 0.1s); 
    opacity: 0; 
}

/* 2. Zoom Forward*/
@keyframes zoomForward {
    from { 
        opacity: 0;
        transform: scale(0.95); 
    }
    to { 
        opacity: 1;
        transform: scale(1); 
    }
}

.anim-forward {
    animation: zoomForward 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    animation-delay: var(--body-anim-delay, 0.1s);
    opacity: 0;
}

@media (max-width: 480px) {
    .content {
        padding: 10px; /* Reduces wasted empty space on the sides */
    }

    table {
        font-size: 0.75rem; /* Shrinks overall table text */
    }

    th, td {
        padding: 8px 4px; /* Dramatically reduces horizontal padding */
    }

    /* Force long SSIDs to wrap instead of stretching the table */
    td div {
        word-break: break-all; 
        max-width: 160px; /* Limits the max width of the network name column */
    }

    /* Shrink the select buttons slightly to save space */
    td button {
        height: 36px;
        padding: 4px;
        font-size: 0.65rem;
    }
}