/* === Root & Theme === */

table, th, td {
  border: 1px solid black;
  border-collapse: collapse;
}
 .chat {
    width:100%;
    max-width:var(--max-width);
    display:block;
    position:relative;
    padding:20px;
    box-sizing:border-box;
  }

  /* message base */
  .msg {
    position:relative;
    display:inline-block;
    max-width:75%;
    padding:12px 16px;
    border-radius:14px;
    margin: var(--gap) 0;
    box-shadow: 0 6px 18px rgba(2,6,23,0.6);
    line-height:1.35;
  }

  /* alternating alignments */
  .msg.left {
    background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
    color:var(--left-text);
    align-self:flex-start;
    margin-left:0;
    margin-right:auto;
    border: 1px solid rgba(255,255,255,0.035);
  }

  .msg.right {
    background: linear-gradient(180deg, var(--right-bg), color-mix(in srgb, var(--right-bg) 86%, white 14%));
    color:var(--right-text);
    margin-left:auto;
    margin-right:0;
    border: 1px solid rgba(0,0,0,0.15);
  }

  /* big ZigZAK offsets: odd / even children */
  .chat .msg:nth-child(odd) {
    transform: translateX(-6%) translateY(-8px) rotate(-0.3deg);
  }
  .chat .msg:nth-child(even) {
    transform: translateX(6%) translateY(8px) rotate(0.3deg);
  }

  /* stronger horizontal offset for right messages so they appear zig-zag */
  .chat .msg.right:nth-child(even) { transform: translateX(12%) translateY(10px) rotate(0.5deg); }
  .chat .msg.left:nth-child(odd)  { transform: translateX(-12%) translateY(-10px) rotate(-0.5deg); }

  /* diagonal connector (small slanted line) to emphasize zig-zag */
  

  /* left connector points leftwards */
  

  /* right connector points rightwards */
  

  /* small timestamp under each message */
  .time{
    display:block;
    font-size:12px;
    opacity:0.6;
    margin-top:8px;
  }

  /* responsive: reduce offset on small screens */
  @media (max-width:520px){
    .chat .msg { max-width:86%; padding:10px 12px; border-radius:12px; }
    .chat .msg.left:nth-child(odd),
    .chat .msg.right:nth-child(even),
    .chat .msg.right:nth-child(even),
    .chat .msg.left:nth-child(odd) {
      transform: translateX(0) translateY(0) rotate(0deg);
    }
    .msg::before { display:none; } /* simpler on tiny screens */
  }

  /* optional: small avatar circles */
  .avatar {
    width:34px;
    height:34px;
    border-radius:50%;
    display:inline-block;
    vertical-align:top;
    margin-right:10px;
    margin-left:10px;
    flex-shrink:0;
  }
  .row { display:flex; align-items:flex-start; gap:8px;     align-items: center;}
  .row.left { justify-content:flex-start; }
  .row.right { justify-content:flex-end; flex-direction:row-reverse; }


/* === Header === */
.ticket-header {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-top h1 {
  font-size: 1.6rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-actions .btn {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 10px 16px;
  cursor: pointer;
  transition: 0.3s;
  font-weight: 500;
}

.header-actions .btn:hover {
  background: #003c99;
}

/* === Navigation === */
.ticket-nav {
  margin-top: 15px;
  display: flex;
  gap: 20px;
}

.ticket-nav a {
  text-decoration: none;
  color: var(--text-light);
  font-weight: 500;
  transition: 0.3s;
  padding-bottom: 5px;
  border-bottom: 2px solid transparent;
}

.ticket-nav a.active,
.ticket-nav a:hover {
  color: var(--primary);
  border-color: var(--primary);
}

/* === Table === */
.ticket-table-container {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}

.ticket-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.ticket-table th,
.ticket-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.ticket-table th {
  background: var(--primary-light);
  color: var(--text-dark);
  font-weight: 600;
}

.ticket-table tr:hover {
  background: #f7faff;
}

/* === Status Labels === */
.status {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: capitalize;
}

.status.open { background: #e6f4ff; color: #0052cc; }
.status.in-progress { background: #fff4e5; color: #974f0c; }
.status.closed { background: #e3fcef; color: #006644; }

/* === Buttons === */
.btn {
  display: inline-block;
  background: var(--primary);
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: 0.3s;
}

.btn:hover {
  background: #003c99;
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-outline:hover {
  background: var(--primary);
  color: white;
}

/* === Modal === */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(2px);
  justify-content: center;
  align-items: center;
  padding: 20px;
  z-index: 999;
}

.modal.active {
  display: flex;
  animation: fadeIn 0.25s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

.modal-content {
  background: #e6f4ff;
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 500px;
  box-shadow: var(--shadow);
  position: relative;
}

.modal-content.large {
  max-width: 700px;
  display: flex;
  flex-direction: column;
  height: 90vh;
}

/* === Form === */
.form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  margin-bottom: 15px;
  padding-bottom: 8px;
}

.form-header h2 {
  font-size: 1.2rem;
  color: var(--text-dark);
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-light);
  cursor: pointer;
  transition: 0.3s;
}

.close-btn:hover {
  color: var(--danger);
}

.ticket-form .form-group {
  margin-bottom: 15px;
}

.ticket-form label {
  display: block;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-dark);
}

.ticket-form input,
.ticket-form select,
.ticket-form textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: 0.3s;
}

.ticket-form input:focus,
.ticket-form textarea:focus,
.ticket-form select:focus {
  border-color: var(--primary);
  background: var(--primary-light);
}

/* === Message Modal === */
.messages-container {
  flex: 1;
  overflow-y: auto;
  background: #f8f9fb;
  padding: 12px;
  margin: 10px 0;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  max-width: 80%;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
}

.message-bubble.customer {
  background: #e6f4ff;
  align-self: flex-end;
}

.message-bubble.support {
  background: #fff;
  align-self: flex-start;
}

.message-bubble .meta {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-bottom: 5px;
}

.message-bubble .attachment {
  font-size: 0.8rem;
  color: var(--primary);
  text-decoration: underline;
  display: block;
  margin-top: 4px;
}

.message-form {
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.message-form .form-row {
  margin-bottom: 10px;
}

.message-form textarea {
  width: 100%;
  resize: none;
  border-radius: var(--radius);
  padding: 10px;
}

.sender-select {
  display: flex;
  gap: 15px;
}

.form-row.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* === Ticket Description === */
.ticket-detail {
  background: #fff;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
}

.ticket-description strong {
  font-size: 1rem;
  color: var(--primary);
}

/* === Responsive === */
@media (max-width: 768px) {
  .header-top h1 {
    font-size: 1.3rem;
  }

  .ticket-table th, .ticket-table td {
    font-size: 0.85rem;
    padding: 10px;
  }

  .modal-content.large {
    height: 85vh;
    max-width: 95%;
  }

  .btn {
    font-size: 0.9rem;
    padding: 8px 10px;
  }
}
