/* --- Global Resets & Layout (Same as before) --- */
body {
    font-family: Arial, sans-serif;
    background-color: #f4f4f9;
    margin: 0;
    padding: 20px;
    line-height: 1.6;
}

header {
    background: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    margin: 0;
    color: #28a745;
}

/* --- Buttons & Filters (Same as before) --- */
button {
    padding: 10px 15px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 5px;
}

button:hover {
    background-color: #0056b3;
}

.filter-btn { background-color: #6c757d; }
.filter-btn.active { background-color: #28a745; font-weight: bold; }
#add-card-btn { background-color: #28a745; }


/* --- Card Container Layout (Same as before) --- */
.card-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

/* --- Individual Card Styling (Updated with menu positioning) --- */
.card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    position: relative; /* Essential for positioning the menu */
    border-left: 5px solid #007bff;
    transition: transform 0.2s;
}

.card:hover {
    transform: translateY(-5px);
}

.card[data-type="typeA"] { border-left-color: #ffc107; }
.card[data-type="typeB"] { border-left-color: #dc3545; }

.card-header {
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between; /* Aligns title left, menu right */
    align-items: flex-start;
}

.card-title {
    margin: 0 0 5px 0;
    font-size: 1.2em;
}

.card-description {
    margin: 0 0 10px 0;
    color: #555;
    cursor: pointer;
}

.card-type {
    font-size: 0.8em;
    color: #888;
}

/* --- Card Menu Styling (New) --- */

.card-menu {
    display: none; /* Hidden by default */
    position: absolute;
    top: 10px;
    right: 10px;
    white-space: nowrap;
}

/* Show the menu ONLY when the parent card is hovered */
.card:hover .card-menu {
    display: block;
}

.menu-btn {
    padding: 4px 8px;
    font-size: 0.75em;
    margin-left: 5px;
}

.edit-btn { background-color: #17a2b8; }
.delete-btn { background-color: #dc3545; }


/* --- Inline Editing Styles (Same as before) --- */
.edit-input {
    width: 90%;
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: inherit;
    font-size: inherit;
    box-sizing: border-box;
}

.card-description.edit-input {
    min-height: 80px;
    resize: vertical;
}

.hidden {
    display: none !important;
}
/* --- Modal Styles --- */

.modal-overlay {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 100; /* Sit on top of everything */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7); /* Black background with opacity */
    overflow-y: auto; /* Enable scrolling within the modal if content is long */
}

/* Freezes the background scroll when modal is active */
body.modal-open {
    overflow: hidden;
}

.modal-content {
    /* Reuses the existing .card styling, but adds modal-specific positioning */
    background-color: #fefefe;
    margin: 10% auto; /* Center the modal vertically and horizontally */
    padding: 20px;
    width: 80%; /* Adjust width as needed */
    max-width: 500px;
    position: relative;
    z-index: 101;
}

.close-btn {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-btn:hover,
.close-btn:focus {
    color: #000;
    text-decoration: none;
    cursor: pointer;
}

/* Styling for form elements within the modal */
.cardForm label {
    display: block;
    margin-top: 10px;
    font-weight: bold;
    width: auto;
    float: left;
}

.cardForm input,
.cardForm textarea,
.cardForm select {
    width: 100%;
    padding: 8px;
    margin-top: 5px;
    margin-bottom: 10px;
    box-sizing: border-box;
}

.cardForm button {
    margin-top: 10px;
}
.img-update {
   height: 1em;
   float: left;
   margin-left: 5px;
   margin-top: 10px;
}
.editingField:hover {
   background-color: rgb(23, 162, 184);
   transform: scale(1.05);
}
.editingFieldClicked {
   background-color: #2ecc71;
   cursor: default;
   box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}
.editingFieldDisabled {
   background-color: #95a5a6;
   cursor: not-allowed;
   opacity: 0.6; 
}
.editing-save-button:disabled {
   background-color: #cccccc;
   cursor: not-allowed;
}
