/* GENERAL STYLES */
* {
    box-sizing: border-box;
}

body {
    font-family: monospace;
    background-color: #1e1e1e;
    color: #d4d4d4;
    margin: 0;
    padding: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Navigation */
.menu {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
    border-bottom: 1px solid #333;
    padding-bottom: 15px;
}

.menu a {
    text-decoration: none;
    color: #007acc;
    font-weight: bold;
}

.menu button {
    margin-left: auto;
}

/* CONTROLS (Inputs, Buttons, Tables) */
input, select, textarea {
    display: block;
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    border: 1px solid #3c3c3c;
    border-radius: 3px;
    background-color: #3c3c3c;
    color: #d4d4d4;
}

button {
    padding: 10px 20px;
    background-color: #007acc;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    transition: background-color 0.2s;
}

button:hover {
    background-color: #005f99;
}

button:disabled {
    background: #555;
    cursor: not-allowed;
}

/* Data tables */
table {
    width: 100%;
    border-collapse: collapse;
    background-color: #252526;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 20px;
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #333;
}

th {
    background-color: #333;
    color: #fff;
}

/* ERROR PAGES (4xx, 5xx) */
.error-page {
    text-align: center;
    padding: 100px 20px;
}

.error-page h1 {
    font-size: 48px;
    margin-bottom: 20px;
    color: #f44336;
}

.error-page p {
    font-size: 24px;
    margin-bottom: 40px;
    color: #bbb;
}

.error-page a {
    color: #007acc;
    text-decoration: none;
    font-weight: bold;
    font-size: 18px;
}

.error-page a:hover {
    text-decoration: underline;
}

/* MODAL WINDOWS */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
}

.modal-content {
    background-color: #2d2d2d;
    margin: 10% auto;
    padding: 20px;
    width: 100%;
    max-width: 500px;
    border-radius: 8px;
    position: relative;
    border: none !important;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}

.close {
    position: absolute;
    top: 10px;
    right: 15px;
    color: #888;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
    z-index: 1010;
}

.close:hover {
    color: #fff;
}

/* LOGIN AND PROFILE */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.login-box {
    background-color: #2d2d2d;
    padding: 30px;
    border-radius: 5px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
    width: 350px;
}

#loginForm button {
    width: 100%;
    margin-top: 10px;
}

.profile-container {
    max-width: 500px;
    margin: 40px auto;
    padding: 0 20px;
}

.profile-container h1 {
    margin-bottom: 30px;
}

.profile-container label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #bbb;
}

.profile-container form#usernameForm {
    margin-bottom: 40px;
}

.profile-container button {
    display: block;
    width: 100%;
    padding: 12px;
    background-color: #0e639c;
}

button[onclick="openPasswordModal()"] {
    margin-top: 10px;
    background-color: #444;
}

/* KEY MANAGEMENT (SSH Keys) */
.keys-container { 
    max-width: 600px; 
    margin: 40px auto; 
}

.key-block {
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    padding: 15px 0; 
    border-bottom: 1px solid #3c3c3c;
}

.keys-container textarea {
    font-family: 'Consolas', monospace;
    min-height: 100px;
}

.add-btn { 
    margin-top: 20px; 
    width: 100%; 
    background: #0e639c; 
}

#confirmDeleteButton { 
    background: #a31515; 
    width: 100%; 
}

/* TERMINAL (Xterm.js) */
.term-window {
    position: fixed;
    z-index: 1000;
    background: #1e1e1e;
    border: 1px solid #444;
    display: flex;
    flex-direction: column;
    transition: opacity 0.2s, transform 0.2s;
    touch-action: none; 
}

.term-header {
    background: #333;
    padding: 8px;
    cursor: move;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.term-body {
    flex-grow: 1;
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
}

.term-controls button {
    margin-left: 5px;
    padding: 2px 8px;
}

.is-maximized {
    width: 100vw !important;
    height: 100vh !important;
    top: 0 !important;
    left: 0 !important;
    transform: none !important;
    z-index: 9999 !important;
}

.resizer {
    width: 20px;
    height: 20px;
    position: absolute;
    right: -10px;
    bottom: -10px;
    cursor: nwse-resize !important;
    z-index: 99999;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
    filter: drop-shadow(0px 0px 1px rgba(0,0,0,0.8));
    opacity: 0.6;
    transition: all 0.2s;
}

.resizer:hover {
    opacity: 1;
    transform: scale(1.1);
}

.term-toolbar {
    background: #222;
    display: none !important;
    justify-content: flex-start;
    align-items: center;
    padding: 5px 8px;
    border-top: 1px solid #444;
    overflow-x: auto;
    white-space: nowrap;
    gap: 6px;
    scrollbar-width: none; 
}

.term-toolbar::-webkit-scrollbar { 
    display: none;
}

.term-toolbar-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.term-btn {
    all: unset;
    cursor: pointer;
    background: #3d3d3d;
    color: #ddd;
    padding: 4px 8px;
    font-size: 11px;
    border-radius: 3px;
    transition: background 0.2s;
    user-select: none;
    text-align: center;
}

.term-btn:hover { 
    background: #4a4a4a; 
}

.term-btn-danger { 
    color: #ff5555; 
    font-weight: bold; 
}

.term-btn-arrow { 
    color: #ffffff; 
}

.term-btn-action { 
    background: #444; 
}

.term-divider {
    border-left: 1px solid #444;
    height: 16px;
    margin: 0 4px;
}

.selection-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    color: transparent;
    white-space: pre;
    font-family: monospace;
    z-index: 50;
    overflow-y: auto;
    user-select: text !important;
}

.term-body::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.term-body::-webkit-scrollbar-track {
    background: #bdbdbd;
    border-left: 1px solid #444;
}

.term-body::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 2px;
}

.term-body::-webkit-scrollbar-thumb:hover {
    background: #303030;
    cursor: pointer;
}

.term-body {
    scrollbar-color: #888 #bdbdbd;
    scrollbar-width: thin;
}

@media screen and (max-width: 768px) {
    .term-window {
        width: 100vw !important;
        left: 0 !important;
        top: 0 !important;
        margin: 0 !important;
        border: none !important;
        position: fixed !important;
        display: flex !important;
        flex-direction: column !important;
        z-index: 9999 !important;
        background: #1e1e1e;
        height: 100% !important; 
    }


    .term-header {
        flex: 0 0 auto !important;
        padding: 10px !important;
    }

    .term-body {
        flex: 1 1 auto !important;
        height: auto !important;
    }

    .term-toolbar {
        display: flex !important;
        flex-wrap: wrap !important;
        overflow: hidden !important;
        touch-action: manipulation;

        position: relative;
        z-index: 10001;
        background: #222;
    }

    .term-btn {
        flex: 0 1 auto !important;
        min-width: 40px;
        font-size: 14px !important;
        padding: 3px 6px !important;
    }

    .xterm-helper-textarea {
        display: block !important;
    }
}
