/* --- Global & Base Styles --- */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #2c3e50;
    color: #ecf0f1;
    margin: 0;
}
.container { max-width: 800px; margin: 2em auto; padding: 20px; background-color: #34495e; border-radius: 8px; box-shadow: 0 0 15px rgba(0, 0, 0, .5); }
h1, h2 { color: #3498db; margin-top: 0; }
h3 { color: #95a5a6; border-bottom: 1px solid #7f8c8d; padding-bottom: 5px; margin-top: 20px; }
h4 { color: #bdc3c7; margin-top: 25px; margin-bottom: 10px; }
/* --- Navigation --- */
.top-nav { background-color: #34495e; padding: 0 2em; box-shadow: 0 2px 4px rgba(0,0,0,0.3); display: flex; justify-content: space-between; align-items: center; }
.top-nav ul { list-style-type: none; margin: 0; padding: 0; display: flex; }
.top-nav ul li a { display: block; color: #ecf0f1; text-align: center; padding: 14px 16px; text-decoration: none; font-weight: 700; }
.top-nav ul li a:hover { background-color: #4f6a85; }
.top-nav ul li a.active { background-color: #3498db; }
.logout-link { color: #e74c3c !important; }
/* --- Forms & Buttons --- */
form { display: grid; grid-template-columns: 1fr; gap: 15px; margin-bottom: 20px; }
input, select { width: 100%; box-sizing: border-box; padding: 10px; border-radius: 4px; border: 1px solid #7f8c8d; background-color: #2c3e50; color: #fff; font-size: 14px; }
label { display: block; margin-bottom: 5px; font-weight: 700; }
button { padding: 10px 20px; border-radius: 4px; border: none; background-color: #3498db; color: #fff; cursor: pointer; font-weight: 700; font-size: 16px; }
button:disabled { background-color: #7f8c8d; cursor: not-allowed; }
/* --- Specific Components --- */
.app-list { list-style-type: none; padding: 0; background-color: #2c3e50; border-radius: 4px; max-height: 200px; overflow-y: auto; }
.app-list li { padding: 10px; border-bottom: 1px solid #34495e; }
.app-list li:last-child { border-bottom: none; }
.app-list input[type="checkbox"] { margin-right: 10px; }
.button-group { display: flex; gap: 10px; }
.notice { background-color: #2c3e50; border-left: 5px solid #3498db; padding: 10px 20px; margin-bottom: 20px; }
#output { background-color: #1c2833; border: 1px solid #7f8c8d; padding: 15px; border-radius: 4px; white-space: pre-wrap; font-family: "Menlo", "Monaco", monospace; min-height: 200px; max-height: 500px; overflow-y: auto; }
/* --- Login & Setup Pages --- */
.login-body, .setup-body { display: flex; justify-content: center; align-items: center; height: 100vh; }
.login-container, .setup-container { width: 350px; padding: 40px; background-color: #34495e; border-radius: 8px; box-shadow: 0 0 15px rgba(0, 0, 0, .5); }
.setup-container { width: 400px; }
.setup-container h1 { color: #f39c12; }
.setup-container p { text-align: center; margin-bottom: 20px; }
/* --- Flash Messages --- */
.flash-error { border-left-color: #e74c3c; background-color: #c0392b; color: white; padding: 10px; border-radius: 4px; text-align: center; margin-bottom: 15px; }
.flash-success { border-left-color: #2ecc71; background-color: #27ae60; color: white; padding: 10px; border-radius: 4px; text-align: center; margin-bottom: 15px; }
.flash-info { border-left-color: #3498db; background-color: #2980b9; color: white; padding: 10px; border-radius: 4px; text-align: center; margin-bottom: 15px; }
/* --- User Management Table --- */
.user-table { width: 100%; border-collapse: collapse; margin-top: 15px; }
.user-table th, .user-table td { padding: 12px; border-bottom: 1px solid #7f8c8d; text-align: left; }
.user-table th { color: #3498db; }
.user-table .actions { display: flex; gap: 10px; align-items: center; }
.user-table .inline-form { display: flex; gap: 5px; margin: 0; }
.user-table .action-button { padding: 5px 10px; font-size: 12px; }
.user-table .danger { background-color: #c0392b; }
/* --- Theme Switcher Dropdown --- */
.theme-switcher { position: relative; }
.theme-switcher .dropdown {
    display: none;
    position: absolute;
    background-color: #34495e; /* Belize Deep specific color */
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 1;
    list-style: none;
    padding: 0;
    margin: 0;
    border-radius: 4px;
    right: 0;
}
.theme-switcher:hover .dropdown { display: block; }
.theme-switcher .dropdown li a { padding: 12px 16px; }

/* --- Branding & Logo --- */
.logo-container {
    display: flex;
    align-items: center;
    padding-right: 1em;
}

.logo-container a {
    display: flex; /* Helps with vertical alignment */
    align-items: center;
    padding: 0; /* Override default link padding */
}

.logo-container a:hover {
    background-color: transparent !important; /* Prevent hover effect on the logo container */
}

.logo-container img {
    height: 35px; /* Adjust this value to fit your logo's aspect ratio */
    width: auto;
}

/* --- Library Side Panel --- */
.side-panel {
    height: 100%;
    width: 0; /* Initially hidden */
    position: fixed;
    z-index: 1001;
    top: 0;
    right: 0;
    background-color: var(--content-bg, #34495e);
    overflow-x: hidden;
    transition: 0.5s;
    box-shadow: -5px 0 15px rgba(0,0,0,0.3);
    
    /* THE FIX: Use Flexbox for layout */
    display: flex;
    flex-direction: column;
}

.side-panel .close-button {
    position: absolute;
    top: 15px;
    right: 25px;
    font-size: 36px;
    margin-left: 50px;
    text-decoration: none;
    color: var(--text-light-color, #aaa);
}
.side-panel .close-button:hover {
    color: var(--danger-color, #e74c3c);
}

.side-panel h2, .side-panel form, .library-search-wrapper {
    padding: 0 25px;
    flex-shrink: 0; /* Prevent header and forms from shrinking */
}

/* Style for the new search bar */
.library-search-wrapper {
    padding-top: 15px;
    padding-bottom: 15px;
    border-top: 1px solid var(--border-color, #7f8c8d);
    margin-top: 20px;
}
#library-search {
    width: 100%;
}

#library-content {
    /* THE FIX: Let this element grow and scroll */
    flex-grow: 1;
    overflow-y: auto;
    padding: 0 25px 25px 25px;
    min-height: 0; /* A flexbox trick to make overflow work correctly */
}

#panel-overlay {
    display: none;
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1000;
}

.library-category {
    border-left: 3px solid var(--primary-color, #3498db);
    margin-bottom: 10px;
    padding: 10px;
    padding-left: 15px;
    background-color: var(--bg-color, #2c3e50);
    border-radius: 4px;
}

.library-category .library-category {
    background-color: rgba(0,0,0,0.1);
}

.library-category-header {
    font-weight: bold;
    color: var(--primary-color, #3498db);
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.category-name {
    word-break: break-all;
}

.library-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px;
    border-radius: 4px;
    background-color: var(--input-bg, #2c3e50);
    margin-bottom: 5px;
}

.item-text {
    word-break: break-all;
    margin-right: 10px;
}

.item-buttons {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
}

.library-item .copy-button {
    padding: 2px 8px;
    font-size: 12px;
}

.delete-button {
    padding: 2px 8px;
    font-size: 14px;
    font-weight: bold;
    background-color: transparent;
    border: 1px solid transparent;
    color: var(--text-light-color, #aaa);
    cursor: pointer;
}
.delete-button:hover {
    color: var(--danger-color, #e74c3c);
}

.error-message {
    color: var(--danger-color, #e74c3c);
}

/* --- Responsive Design for Mobile & Tablet --- */
@media (max-width: 768px) {
    .container {
        margin: 1em;
        padding: 15px;
    }

    .top-nav {
        flex-direction: column;
        padding: 0.5em;
    }

    .nav-left, .nav-right {
        flex-direction: column;
        width: 100%;
        align-items: center;
    }
    
    .nav-left {
        border-bottom: 1px solid var(--border-color, #7f8c8d);
        margin-bottom: 0.5em;
    }

    .top-nav ul li a {
        padding: 10px 12px;
    }

    .logo-container {
        padding: 0.5em 0;
    }

    .side-panel {
        width: 0; /* Hidden by default */
        max-width: 90%; /* Take up more screen space when open */
    }
    
    .modal-content, .login-container, .setup-container {
        width: 90%;
        margin: 10% auto;
    }
}

.top-nav {
    /* ... existing styles ... */
    position: sticky;
    top: 0;
    z-index: 999;
}

/* Add to your <style> block */

.app-card-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.order-controls {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.order-btn {
    background: var(--border-color);
    border: none;
    cursor: pointer;
    font-size: 10px;
    padding: 2px 6px;
    line-height: 1;
    border-radius: 2px;
    color: var(--text-color);
}

.order-btn:hover {
    background: var(--primary-color);
    color: white;
}

.order-btn:disabled {
    opacity: 0.3;
    cursor: default;
    background: var(--border-color);
    color: var(--text-color);
}

.app-number {
    font-weight: bold;
    font-size: 1.2em;
    color: var(--text-light-color);
    min-width: 25px;
}
/* --- Build Manager Specific Styles --- */
.build-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.profile-controls { display: flex; gap: 10px; }

.panel { background: var(--content-bg); border: 1px solid var(--border-color); border-radius: 8px; padding: 20px; margin-bottom: 20px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); }
.hint { font-size: 0.85em; color: var(--text-light-color); margin-bottom: 15px; margin-top: -10px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.grid-target { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 15px; }

/* App Card Styling */
.app-card { background: var(--bg-color); border: 1px solid var(--border-color); padding: 15px; border-radius: 6px; margin-bottom: 10px; transition: transform 0.2s; }
.app-card:hover { border-color: var(--primary-color); }
.app-card-header { display: flex; justify-content: space-between; margin-bottom: 10px; color: var(--text-light-color); font-size: 0.9em; }
.app-card-actions { display: flex; gap: 15px; align-items: center; }

/* Left side of card (Number + Arrows) */
.app-card-left { display: flex; align-items: center; gap: 10px; }
.app-number { font-weight: bold; font-size: 1.2em; color: var(--text-light-color); min-width: 25px; }
.order-controls { display: flex; flex-direction: column; gap: 2px; }
.order-btn { background: var(--border-color); border: none; cursor: pointer; font-size: 10px; padding: 2px 6px; line-height: 1; border-radius: 2px; color: var(--text-color); }
.order-btn:hover { background: var(--primary-color); color: white; }
.order-btn:disabled { opacity: 0.3; cursor: default; background: var(--border-color); color: var(--text-color); }

.grid-app { display: grid; grid-template-columns: 3fr 1fr; gap: 10px; }

.private-auth-box { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border-color); }

/* Console Output */
.console-output { 
    background-color: #1e1e1e; color: #f0f0f0; 
    padding: 15px; border-radius: 6px; 
    font-family: 'Courier New', Courier, monospace; 
    min-height: 300px; max-height: 600px; 
    overflow-y: auto; white-space: pre-wrap; font-size: 13px;
}

/* Buttons */
.success-btn { background-color: #2ecc71; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-weight: bold; }
.secondary-btn { background-color: #95a5a6; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; }
.small-btn { font-size: 0.8em; padding: 5px 10px; }
.big-btn { width: 100%; padding: 15px; font-size: 1.1em; text-transform: uppercase; letter-spacing: 1px; }

.remove-row-btn { background: none; border: none; color: var(--danger-color); font-size: 1.2em; cursor: pointer; }
.fetch-branches-btn { border-radius: 0 4px 4px 0; border: 1px solid var(--border-color); border-left: none; cursor: pointer; background: var(--border-color); }

.input-group { display: flex; }
.input-group input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group button { border-top-left-radius: 0; border-bottom-left-radius: 0; width: 40px; padding: 0; display: flex; align-items: center; justify-content: center; }

.sticky-footer { position: sticky; bottom: 20px; z-index: 100; }

@media (max-width: 768px) {
    .grid-2, .grid-target, .grid-app { grid-template-columns: 1fr; }
}
