/**
 * Frontend CSS for Amazon Product Manager.
 *
 * @since 1.1.0
 */

/* ------------------- Zmienne CSS ------------------- */
:root {
  --color-primary: #0d6efd;
  --color-secondary: #6c757d;
  --color-success: #28a745;
  --color-warning: #ffc107;
  --color-danger: #dc3545;
  --color-light: #f8f9fa;
  --color-dark: #343a40;
  --color-border: #dee2e6;
  --color-light-grey: #e9ecef;
  
  --border-radius: 0.25rem;
  --padding-cell: 5px;
}

/* ------------------- Ogólne ------------------- */
.apm-dashboard-container {
  max-width: 100%;
  overflow-x: auto;
  padding: 15px 0;
}

.form-control-static {
  padding-top: 0.375rem;
  padding-bottom: 0.375rem;
  font-weight: 500;
}

/* Styl dla komunikatu o wymaganiu logowania */
.apm-login-required {
  padding: 20px;
  text-align: center;
  margin: 20px 0;
}

/* ------------------- Dashicons dla frontendu ------------------- */
.apm-frontend .dashicons {
  font-family: dashicons;
  display: inline-block;
  line-height: 1;
  font-weight: 400;
  font-style: normal;
  speak: never;
  text-decoration: inherit;
  text-transform: none;
  text-rendering: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  width: 20px;
  height: 20px;
  font-size: 20px;
  vertical-align: top;
  text-align: center;
  transition: color .1s ease-in;
}

.apm-frontend .dashicons-yes-alt:before {
  content: "\f12a";
}

.apm-frontend .dashicons-clock:before {
  content: "\f469";
}

.apm-frontend .dashicons-warning:before {
  content: "\f534";
}

.apm-frontend .dashicons-minus:before {
  content: "\f460";
}

/* ------------------- Status i odznaki ------------------- */
.status-badge {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 30px;
  height: 30px;
  margin: 0 auto;
  padding: 0;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  border-radius: var(--border-radius);
  color: #fff;
  cursor: pointer;
  transition: background-color 0.15s ease-in-out;
}

.status-badge .dashicons {
  margin: 0;
  font-size: 18px;
}

.status-badge.status-empty {
  background-color: var(--color-light-grey);
  color: var(--color-secondary);
}

.status-badge:hover:not(.status-empty) {
  opacity: 0.9;
}

/* ------------------- Tabela ------------------- */
#dashboard-table th,
#dashboard-table td {
  vertical-align: middle;
}

#dashboard-table th {
  font-size: 0.875rem;
  text-align: center;
  white-space: normal !important;
  word-wrap: break-word !important;
  hyphens: auto;
  background-color: var(--color-light);
  border: 1px solid var(--color-border);
  padding: 10px 5px;
  min-width: 70px !important;
  max-width: 120px !important;
}

#dashboard-table thead tr:first-child th {
  background-color: var(--color-light-grey);
}

#dashboard-table thead tr:nth-child(2) th {
  background-color: #f1f1f1;
}

#dashboard-table .status-cell {
  text-align: center;
  min-width: 70px !important;
  max-width: 120px !important;
  width: auto !important;
  padding: var(--padding-cell) !important;
}


/* ------------------- Modal i komponenty ------------------- */
/* Modal styles */
.modal-dialog {
  margin: 1.75rem auto !important;
  left: 0;
}

.modal.show {
  padding-left: 17px !important;
}

/* Historia i komentarze */

#task-history {
  max-height: 250px;
  overflow-y: auto;
}

.history-item {
  border-left: 4px solid #cccccc;
  padding-left: 10px;
  margin-bottom: 10px;
}

.history-status {
  display: inline-block;
  padding: 0.2rem 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  vertical-align: baseline;
  border-radius: var(--border-radius);
  color: #fff;
}

.history-meta, 
.comment-meta {
  font-size: 0.8rem;
  color: var(--color-secondary);
  margin-top: 5px;
}

.comment-text {
  margin-top: 5px;
  white-space: pre-wrap;
}

/* ------------------- DataTables kontrolki ------------------- */
/* Kontenery kontrolek */
#datatables-top-container,
#datatables-bottom-container {
  width: 100%;
  margin: 15px 0;
  overflow: hidden; /* Zapobiega "wylewaniu się" elementów */
}

/* Kontrolki długości i filtrowania */
.dataTables_length {
  float: left;
  width: 100%;
  margin-bottom: 10px;
}

.dataTables_length select {
  min-width: 80px;
  display: inline-block;
  width: auto;
  margin: 0 5px;
}

.dataTables_filter {
  float: right;
  width: 100%;
  text-align: right;
}

.dataTables_filter input {
  min-width: 250px;
  display: inline-block;
  width: auto;
  margin-left: 10px;
}

/* Paginacja i informacje */
.dataTables_paginate {
  float: right !important;
  text-align: right !important;
  margin: 0 auto;
}

.dataTables_info {
  text-align: left;
}

/* Struktura niestandardowych kontenerów kontrolek */
.dt-control-container {
  width: 50%;
  float: left;
  clear: none;
  align-content: center;
  padding: 0 15px;
}

.dt-info-container {
  width: 40%;
  float: left;
  clear: none;
  align-content: center;
  padding: 0 15px;
}

.dt-pagination-container {
  width: 60%;
  float: right;
  clear: none;
  align-content: center;
  padding: 0 15px;
}

/* Czyszczenie float */
.clearfix::after {
  content: "";
  display: table;
  clear: both;
}

/* ------------------- Responsywność ------------------- */
@media (max-width: 1200px) {
  #dashboard-table thead th {
    font-size: 0.8rem;
  }
  
  #dashboard-table .status-cell {
    min-width: 60px !important;
  }
}

@media (max-width: 992px) {
  #dashboard-table thead th {
    font-size: 0.75rem;
  }
  
  #dashboard-table .status-cell {
    min-width: 50px !important;
  }
  
  .dataTables_filter input {
    min-width: 200px;
  }
}

@media (max-width: 768px) {
  .apm-dashboard-container {
    padding: 10px;
  }
  
  .dataTables_length,
  .dataTables_filter {
    float: none;
    text-align: center;
    margin-bottom: 15px;
  }
  
  .dataTables_paginate {
    float: none !important;
    text-align: center !important;
    margin-top: 15px;
  }
  
  .dataTables_info {
    text-align: center;
    margin-bottom: 10px;
  }
  
  .dataTables_filter input {
    min-width: 150px;
  }
}

/* Poprawki dla bardzo małych ekranów */
@media (max-width: 576px) {
  .dt-control-container,
  .dt-info-container,
  .dt-pagination-container {
    width: 100%;
    float: none;
    clear: both;
    text-align: center;
    margin-bottom: 10px;
  }
}

/* Style dla nowego formatu produktu */
.product-name {
  font-weight: 500;
}

.product-details {
  font-size: 0.8rem;
  color: var(--color-secondary);
  margin-top: 3px;
}

/* Szerokości kolumn - używamy selektorów opartych na atrybucie rowspan */
#dashboard-table th[rowspan="3"]:first-child,
#dashboard-table td:first-child {
  min-width: 300px !important;
  width: 35% !important;
}

#dashboard-table th[rowspan="3"]:nth-child(2),
#dashboard-table td:nth-child(2) {
  min-width: 200px !important;
  width: 20% !important;
}

#dashboard-table th[rowspan="3"]:nth-child(3),
#dashboard-table td:nth-child(3) {
  min-width: 100px !important;
  width: 10% !important;
}

/* Wyłączenie wymuszania szerokości dla komórek nagłówka w zagnieżdżonych wierszach */
#dashboard-table thead tr:not(:first-child) th {
  min-width: auto !important;
  width: auto !important;
}

/* Specjalne reguły dla komórek status */
#dashboard-table th.status-cell {
  min-width: auto !important;
  width: auto !important;
}

/* Style dla podlinkowanych nazw produktów */
.product-name.has-link a {
    color: #0073aa;
    text-decoration: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
}

.product-name.has-link a:hover {
    color: #00a0d2;
    text-decoration: underline;
}

.product-name.has-link a .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    margin-left: 5px;
    line-height: 1;
    vertical-align: text-bottom;
}

/* Style dla podlinkowanych nazw produktów */
.product-name a {
    color: #0073aa;
    text-decoration: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
}

.product-name a:hover {
    color: #00a0d2;
    text-decoration: underline;
}

.product-name a .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    margin-left: 5px;
    line-height: 1;
    vertical-align: text-bottom;
}

/* Status icons container */
.status-badge-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

/* Status badge (original) */
.status-badge {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 30px;
  height: 30px;
  margin: 0 auto;
  padding: 0;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  border-radius: var(--border-radius);
  color: #fff;
  cursor: pointer;
  transition: background-color 0.15s ease-in-out;
}

/* Status icons */
.status-icons {
  display: flex;
  gap: 3px;
  justify-content: center;
}

.status-icon {
  font-size: 14px;
  line-height: 1;
  cursor: help;
  display: inline-block;
}

/* Make table cells wider to accommodate the new status format */
#dashboard-table .status-cell {
  min-width: 80px !important;
  padding: 10px 5px !important;
}

/* Mobile optimization */
@media (max-width: 768px) {
  .status-badge-container {
    flex-direction: row;
    gap: 3px;
  }
  
  .status-icons {
    flex-direction: column;
  }
  
  .status-icon {
    font-size: 12px;
  }
}

.vikunja-synced {
    background: rgba(32, 156, 238, 0.2);
    border-radius: 50%;
    padding: 2px;
    margin-left: 2px;
    box-shadow: 0 0 3px rgba(32, 156, 238, 0.5);
}

.status-icons {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-top: 3px;
}

.status-icon {
    margin: 0 2px;
}

/* Style dla modalu zadania */
@media (min-width: 1200px) {
    #task-modal .modal-xl {
        max-width: 90%;
    }
}

/* Style dla komentarzy */
.comment-item {
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 8px;
    margin-bottom: 8px;
}

.comment-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.comment-text {
    margin-bottom: 5px;
}

.comment-meta {
    font-size: 12px;
    color: #777;
}

.vikunja-sync-icon {
    color: #0d6efd;
    font-weight: bold;
}

/* Style dla załączników */
#task-attachments .dashicons {
    margin-right: 5px;
    color: #555;
}

/* Style dla historii zmian */
.history-item {
    margin-bottom: 5px;
}

.history-status {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    color: white;
    font-size: 12px;
    margin-right: 5px;
}

.history-message {
    margin-top: 3px;
    font-style: italic;
}

.history-meta {
    font-size: 12px;
    color: #777;
    margin-top: 3px;
}

/* Dodatkowe style odpowiedzialne za responsywność */
@media (max-width: 991px) {
    #task-modal .col-md-8,
    #task-modal .col-md-4 {
        width: 100%;
    }
    
    #task-modal .col-md-4 {
        margin-top: 20px;
    }
    
    #comments-container {
        height: 250px !important;
    }
}

ul#task-comments,
ul#task-history {
  margin-left: 0px;
  padding-left: 0px;
}
#comments-container {
    max-height: 700px;
    overflow-y: auto;
    scrollbar-width: thin;
}

#task-comments {
    margin-bottom: 0;
}

#task-comments .list-group-item {
    padding: 0.5rem 0.75rem;
    border-left: none;
    border-right: none;
}

.comment-header {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 0.25rem;
    display: flex;
    justify-content: space-between;
}

.comment-user {
    font-weight: 500;
}

.comment-user[style*="color"] {
    padding: 1px 5px;
    border-radius: 3px;
    background-color: rgba(0,0,0,0.05);
}

.user-badge {
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 600;
    display: inline-block;
}

.comment-status-badge {
    background-color: #ccc;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 5px;
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 500;
}

.comment-time {
    color: #999;
    font-size: 0.8rem;
}

.comment-content {
    font-size: 0.9rem;
    white-space: pre-line;
    word-break: break-word;
}

.comment-source {
    font-size: 0.8rem;
    margin-top: 0.25rem;
    padding: 2px 6px;
    border-radius: 3px;
    display: inline-block;
}

.comment-source-apm {
    background-color: #e6f3ff;
    color: #0073aa;
}

.comment-source-vikunja {
    background-color: #fef5e7;
    color: #e67e22;
}

/* Style dla wyłączonego pola formularza */
.disabled-field {
    position: relative;
}

.disabled-field::after {
    content: "Dostępne tylko dla statusu 'Gotowe'";
    position: absolute;
    right: 10px;
    top: 50%;
    font-size: 11px;
    color: #888;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.disabled-field:hover::after {
    opacity: 1;
}

select:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
    border-color: #ddd;
    color: #999;
}