/*-------------------------------------------------------------------------------------------*/
/* Redmine CMDB plugin: Configuration Management DataBase                                    */
/* Copyright (C) 2025 Franz Apeltauer                                                        */
/*                                                                                           */
/* This program is free software: you can redistribute it and/or modify it under the terms   */
/* of the GNU Affero General Public License as published by the Free Software Foundation,    */
/* either version 3 of the License, or (at your option) any later version.                   */
/*                                                                                           */
/* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; */
/* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */
/* See the GNU Affero General Public License for more details.                               */
/*                                                                                           */
/* You should have received a copy of the GNU Affero General Public License                  */
/* along with this program.  If not, see <https://www.gnu.org/licenses/>.                    */
/*-------------------------------------------------------------------------------------eohdr-*/
/* Purpose: Stylesheet for CMDB plugin UI components including tree navigation, forms, modals, and tables.
            Defines layout and styling for the main CMDB page, CI selection modal, and issue CI sections. */

#cmdb-container {
  padding: 10px;
}

.cmdb-content {
  display: flex;
  gap: 20px;
  margin-top: 20px;
  min-height: 600px;
}

/* Sidebar with tree */
.cmdb-sidebar {
  flex: 0 0 350px;
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 4px;
  overflow: auto;
  max-height: 700px;
}

.tree-container {
  padding: 0;
}

.tree-header {
  padding: 10px;
  background: #e0e0e0;
  border-bottom: 1px solid #ccc;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 5px;
}

.tree-content {
  padding: 5px;
}

/* Tree structure */
.tree-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.tree-node {
  margin: 0;
  padding: 0;
}

.node-content {
  display: flex;
  align-items: center;
  padding: 4px 8px;
  cursor: pointer;
  user-select: none;
}

.node-content:hover {
  background: #e8e8e8;
}

.tree-node.selected > .node-content {
  background: #628DB6;
  color: white;
}

.expander {
  width: 16px;
  text-align: center;
  cursor: pointer;
  font-size: 10px;
  flex-shrink: 0;
}

.spacer {
  width: 16px;
  display: inline-block;
}

.node-icon {
  width: 16px;
  height: 16px;
  margin: 0 5px;
  display: inline-block;
  flex-shrink: 0;
}

.node-icon.icon-folder::before {
  content: "📁";
}

.node-icon.icon-page::before {
  content: "📄";
}

.node-icon.icon-add::before {
  content: "➕";
}

.node-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-children {
  padding-left: 20px;
}

/* Main content area */
.cmdb-main {
  flex: 1;
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 20px;
  overflow: auto;
}

.cmdb-details {
  min-height: 400px;
}

.no-selection {
  color: #999;
  text-align: center;
  padding: 50px 20px;
  font-style: italic;
}

/* Forms */
.location-form,
.hierarchy-form {
  max-width: 800px;
}

.form-group {
  margin-bottom: 10px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.form-group label {
  font-weight: bold;
  color: #484848;
  min-width: 180px;
  padding-top: 8px;
  text-align: right;
  flex-shrink: 0;
}

.form-group .field-wrapper {
  flex: 1;
  max-width: 600px;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid #d7d7d7;
  border-radius: 3px;
  font-size: 13px;
}

/* Compact field widths for better usability */
.form-group input.form-control-short {
  width: 200px;
  max-width: 100%;
}

.form-group input.form-control-medium {
  width: 400px;
  max-width: 100%;
}

.form-group select.form-control-short {
  width: 200px;
  max-width: 100%;
}

.form-group select.form-control-medium {
  width: 400px;
  max-width: 100%;
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-group .hint {
  display: block;
  margin-top: 4px;
  color: #666;
  font-size: 11px;
  font-style: italic;
  line-height: 1.3;
}

.form-group .url-field-container {
  display: flex;
  gap: 8px;
  align-items: center;
}

.form-group .url-field-container input {
  flex: 1;
}

.form-group .url-open-icon {
  display: inline-block;
  width: 24px;
  height: 24px;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s;
  flex-shrink: 0;
}

.form-group .url-open-icon:hover {
  opacity: 1;
}

.form-group .url-open-icon::before {
  content: "🔗";
  font-size: 16px;
}

.form-group .url-open-icon.disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.form-actions {
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid #e0e0e0;
  margin-left: 190px;
}

.form-actions .button {
  margin-right: 10px;
}

/* Read-only view */
.location-view,
.hierarchy-view {
  max-width: 800px;
}

.field-group {
  margin-bottom: 15px;
  display: flex;
  align-items: flex-start;
}

.field-group label {
  font-weight: bold;
  color: #484848;
  min-width: 150px;
  padding-right: 10px;
}

.field-group span,
.field-group .text-content {
  flex: 1;
}

.text-content {
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Details header */
.location-details h3,
.hierarchy-details h3 {
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid #628DB6;
}

/* Buttons */
.button {
  padding: 6px 12px;
  background: #f5f5f5;
  border: 1px solid #ccc;
  border-radius: 3px;
  cursor: pointer;
  text-decoration: none;
  color: #333;
  display: inline-block;
  font-size: 13px;
}

.button:hover {
  background: #e5e5e5;
  color: #333;
}

.button-positive,
input[type="submit"].button-positive {
  background: #628DB6;
  color: white !important;
  border-color: #4C7099;
  font-weight: normal;
}

.button-positive:hover,
input[type="submit"].button-positive:hover {
  background: #4C7099;
  color: white !important;
}

/* Fix for submit buttons to match Redmine style */
input[type="submit"] {
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  background-image: none;
}

/* Ensure form buttons are visible and styled properly */
.form-actions input[type="submit"],
.form-actions .button {
  opacity: 1 !important;
  visibility: visible !important;
  background-image: none !important;
}

/* Override any Redmine styles that might hide button text */
.form-actions input[type="submit"]:not(:hover) {
  color: #333;
}

.form-actions input[type="submit"].button-positive:not(:hover) {
  color: white !important;
}

/* Flash messages */
.flash {
  padding: 10px;
  margin-bottom: 10px;
  border-radius: 3px;
  animation: slideDown 0.3s ease;
}

.flash.notice {
  background: #d4f4dd;
  border: 1px solid #90c090;
  color: #2a5a2a;
}

.flash.error {
  background: #fdd;
  border: 1px solid #fcc;
  color: #800;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Status Information Fieldset */
.status-info {
  margin-top: 20px;
  margin-bottom: 15px;
  padding: 10px;
  border: 1px solid #d7d7d7;
  border-radius: 3px;
  background-color: #f8f8f8;
}

.status-info legend {
  padding: 0 8px;
  font-weight: bold;
  color: #484848;
  font-size: 12px;
  background-color: white;
}

.status-info-content {
  font-size: 12px;
  color: #666;
  line-height: 1.5;
}

.status-info .user-link {
  color: #169;
  text-decoration: none;
  cursor: help;
  border-bottom: 1px dotted #169;
}

.status-info .user-link:hover {
  color: #c61a1a;
  border-bottom-color: #c61a1a;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  .cmdb-content {
    flex-direction: column;
  }

  .cmdb-sidebar {
    flex: none;
    max-height: 300px;
    margin-bottom: 20px;
  }
}

@media (max-width: 768px) {
  .form-group {
    flex-direction: column;
    align-items: stretch;
  }

  .form-group label {
    text-align: left;
    padding-top: 0;
    margin-bottom: 5px;
  }

  .form-group .field-wrapper {
    max-width: 100%;
  }

  .form-actions {
    margin-left: 0;
  }
}

/* Issue CI Integration */
.issue-cis-section {
  margin-top: 20px;
}

.issue-cis-table {
  width: 100%;
  margin-top: 10px;
}

.issue-cis-table th {
  background-color: #f5f5f5;
  padding: 8px;
  text-align: left;
  font-weight: bold;
  border-bottom: 2px solid #ddd;
}

.issue-cis-table td {
  padding: 8px;
  border-bottom: 1px solid #eee;
  text-align: left;
}

.ci-row:hover {
  background-color: #f9f9f9;
}

.ci-link {
  color: #169;
  text-decoration: none;
  text-align: left;
}

.ci-link:hover {
  color: #c61a1a;
  text-decoration: underline;
  text-align: left;
}

.ci-class, .ci-location, .ci-status {
  text-align: left;
}

/* CI Selection Modal */
.ci-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
}

.ci-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
}

.ci-modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  width: 600px;
  max-width: 90%;
  max-height: 80%;
  display: flex;
  flex-direction: column;
}

.ci-modal-header {
  padding: 15px 20px;
  border-bottom: 1px solid #ddd;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f5f5f5;
  border-radius: 4px 4px 0 0;
}

.ci-modal-header h3 {
  margin: 0;
  font-size: 18px;
  color: #333;
}

.ci-modal-close {
  font-size: 28px;
  color: #999;
  cursor: pointer;
  line-height: 1;
  font-weight: bold;
}

.ci-modal-close:hover {
  color: #333;
}

.ci-modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  min-height: 300px;
}

.ci-selection-tree {
  min-height: 250px;
}

.ci-selection-tree .node-content.selectable {
  cursor: pointer;
}

.ci-selection-tree .node-content.selectable:hover {
  background-color: #e0f0ff;
}

.ci-selection-loading {
  text-align: center;
  padding: 40px;
  color: #999;
  font-style: italic;
}

.ci-modal-footer {
  padding: 15px 20px;
  border-top: 1px solid #ddd;
  text-align: right;
  background: #f9f9f9;
  border-radius: 0 0 4px 4px;
}
