/* Global Reset and Layout */
body { 
    font-family: sans-serif; 
    margin: 0;                
    background-color: #f8f9fa; 
    color: #333; 
}

/* Main Content Box */
.container { 
    max-width: 850px; 
    margin: 40px auto;        
    background: #fff; 
    border: 1px solid #ccc; 
    padding: 40px; 
    border-radius: 8px; 
    box-shadow: 0 2px 10px rgba(0,0,0,0.1); 
}

.container-wide {
    max-width: 1250px; /* Increased from 1100px */
    margin: 40px auto;
}

/* Header */
.header-container { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    border-bottom: 2px solid #007bff; 
    margin-bottom: 25px;
    padding-bottom: 10px;
}

.header-container h2 { 
    margin: 0; 
    color: #343a40; 
    font-size: 24px;
}

.header-icon { 
    height: 35px; 
    width: auto; 
}

/* Tables and Buckets */
.bucket-container {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    padding: 20px;
    margin-top: 20px;
}

.bucket-table { 
    width: 100%; 
    border-collapse: separate; 
    border-spacing: 0;
}

.bucket-table th { 
    background-color: #fcfcfc; 
    color: #555; 
    padding: 15px;
    border-bottom: 2px solid #eee;
    text-align: left;
}

.bucket-table td { 
    padding: 18px 15px; 
    border-bottom: 1px solid #f1f1f1; 
    vertical-align: middle;
}

/* Form Elements */
.input-group { margin-bottom: 20px; }
.input-group label { display: block; font-weight: bold; margin-bottom: 8px; color: #495057; }

.input-control { 
    width: 100%; 
    padding: 12px; 
    border: 1px solid #ced4da; 
    border-radius: 4px; 
    box-sizing: border-box; 
    font-size: 16px;
    transition: border-color 0.2s;
}

.input-control:focus {
    border-color: #007bff;
    outline: none;
}

/* --- Password Specific Fixes --- */

.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

/* This forces the SVG to be small regardless of its source resolution */
.toggle-password {
    position: absolute;
    right: 12px;
    cursor: pointer;
    color: #6c757d;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.toggle-password svg {
    width: 22px !important;
    height: 22px !important;
    pointer-events: none; /* Prevents the SVG from stealing the click from the span */
}

.password-wrapper .input-control {
    padding-right: 45px; /* Space for the eye icon */
}

/* --- Script Key (GUID) Box --- */
.script-key-container {
    display: flex;
    gap: 10px;          /* This adds the space you requested */
    align-items: stretch; /* Keeps the button at the same height as the box */
}

.script-key-box {
    flex-grow: 1;
    background: #f1f3f5;
    padding: 12px;
    border-radius: 4px; /* Restored full rounding for all corners */
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.95rem;
    color: #495057;
    border: 1px solid #dee2e6; /* Restored the right border */
    word-break: break-all;
    display: flex;
    align-items: center;
}

.copy-btn {
    width: 45px;
    cursor: pointer;
    background-color: #e9ecef;
    border: 1px solid #dee2e6;
    border-radius: 4px; /* Restored full rounding for all corners */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: background 0.2s;
    padding: 0;
    height: auto; 
}

.copy-btn:hover {
    background-color: #dee2e6;
}

/* --- Buttons --- */
.btn-action { 
    height: 42px; /* Fixed height to ensure alignment */
    padding: 0 20px; /* Adjusted padding (top/bottom now handled by height) */
    display: inline-flex; /* Use flex for perfect vertical centering of text */
    align-items: center;
    justify-content: center;
    cursor: pointer; 
    border-radius: 6px; 
    border: none; 
    font-weight: 600;
    transition: all 0.2s;
    text-decoration: none;
    box-sizing: border-box; /* Ensures padding doesn't add to the height */
}

.btn-submit { 
    background-color: #007bff; 
    color: white; 
    width: auto; 
    min-width: 150px;
}

.btn-edit { 
    background-color: #6c757d; 
    color: white; 
}

.btn-edit:hover { background-color: #5a6268; }

.btn-delete { 
    background-color: #dc3545; 
    color: white; 
}
.btn-delete:hover { background-color: #c82333; }

.btn-contents {
    background-color: #28a745;
    color: white;
}
.btn-contents:hover { background-color: #218838; }

.btn-share {
    background-color: #17a2b8;
    color: white;
}
.btn-share:hover { background-color: #138496; }

/* --- Collapsible Logic --- */
.collapsible-toggle { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    cursor: pointer; 
    color: #007bff; 
    font-weight: bold; 
    margin: 25px 0 10px 0; 
}

.collapsible-arrow { 
    width: 0; height: 0; 
    border-left: 5px solid transparent; 
    border-right: 5px solid transparent; 
    border-top: 7px solid #007bff; 
    transition: transform 0.2s; 
}

.collapsed .collapsible-arrow { transform: rotate(-90deg); }

.collapsible-content {
    padding: 20px;
    background: #fcfcfc;
    border-left: 4px solid #007bff;
    border-radius: 0 4px 4px 0;
    margin-bottom: 20px;
}

.hidden { display: none !important; }

/* Alerts */
.alert { padding: 15px; margin-bottom: 20px; border-radius: 4px; }
.success { background-color: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.danger { background-color: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* --- Loader --- */
#loader { display: none; text-align: center; margin-top: 15px; font-weight: bold; color: #007bff; }
#loader::before {
    content: "";
    display: inline-block;
    width: 18px; height: 18px; margin-right: 10px;
    vertical-align: middle;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* --- Table Edit Mode Styling --- */

/* Ensures the input fields and dropdowns fill the cell and match button height */
.edit-input, 
.edit-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 14px;
    height: 42px; /* Matches the height we set for .btn-action */
}

/* Forces the action buttons to stay in a neat row during edit mode */
.actions-cell {
    display: flex;
    gap: 10px;
    justify-content: flex-start; /* Aligns all buttons to the left */
    align-items: center;
    width: 100%;
}

/* Ensure buttons don't shrink if the container gets tight */
.btn-action {
    flex-shrink: 0;
}

/* Optional: Slight adjustment to make the inputs pop against the white table background */
.edit-input:focus, 
.edit-select:focus {
    border-color: #007bff;
    outline: none;
    background-color: #fff;
}

.actions-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.actions-wrap .btn-share {
    margin-left: auto;
}

/* Modal Background */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5); /* Dimmed background */
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Modal Box */
.modal-content {
    background-color: #fff;
    padding: 30px;
    border-radius: 12px;
    width: 400px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

/* Helper to hide the modal */
.hidden {
    display: none !important;
}

/* Custom colors for the Export tab buttons */
.btn-export {
    background-color: #007bff; /* Blue */
    color: white;
}
.btn-export:hover {
    background-color: #0056b3;
}

.btn-mark {
    background-color: #6f42c1; /* Purple */
    color: white;
}
.btn-mark:hover {
    background-color: #59359a;
}

/* --- Added for Horizontal Admin Search --- */
/* Force this specific row to act like search.php */
.admin-search-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 15px;
    padding: 10px;
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Force the labels to sit LEFT and the inputs to be SMALL */
.field-group-inline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.field-group-inline label {
    display: inline !important; /* Overrides the 'block' rule */
    margin-bottom: 0 !important;
    white-space: nowrap;
}

.field-group-inline input {
    width: 130px !important; /* Overrides the '100%' rule */
}

/* Responsive Table to Cards */
@media screen and (max-width: 768px) {
    .container-wide {
        padding: 10px; /* Reduce padding on mobile */
    }

    .bucket-table thead {
        display: none; /* Hide the headers */
    }

    .bucket-table, .bucket-table tbody, .bucket-table tr, .bucket-table td {
        display: block;
        width: 100% !important;
    }

    .bucket-table tr {
        margin-bottom: 15px;
        border: 1px solid #ddd;
        border-radius: 8px;
        padding: 10px;
        background: #fff;
        box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    }

    .bucket-table td {
        text-align: right;
        padding-left: 50%;
        position: relative;
        border-bottom: 1px solid #eee;
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: flex-end;
    }

    .bucket-table td:last-child {
        border-bottom: 0;
    }

    /* Create the labels using the data-label attribute */
    .bucket-table td::before {
        content: attr(data-label);
        position: absolute;
        left: 10px;
        width: 45%;
        text-align: left;
        font-weight: bold;
        color: #555;
    }

    .actions-wrap {
        justify-content: flex-end;
        flex-wrap: wrap; /* Let buttons wrap if they are too wide */
        gap: 5px;
    }

    /* Adjust Modal for Mobile */
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
}