/**
 * Interactive Content Elements - Frontend Styles
 * Version: 2.0
 */

/* --------------------------------
 * 1. CSS Reset & Variables
 * -------------------------------- */
:root {
  --ice-primary: #4a6ee0;
  --ice-success: #28a745;
  --ice-danger: #dc3545;
  --ice-info: #17a2b8;
  --ice-light: #f8f9fa;
  --ice-dark: #343a40;
  --ice-gray: #6c757d;
  --ice-border: #dee2e6;
  --ice-shadow: rgba(0, 0, 0, 0.1);
  --ice-radius: 6px;
  --ice-transition: all 0.2s ease-in-out;
  --ice-font-size: 14px;
  --ice-font-size-sm: 12px;
  --ice-spacing: 8px;
}

/* --------------------------------
 * 2. Vote Button Styles
 * -------------------------------- */
.ice-vote-container {
  display: inline-flex;
  vertical-align: middle;
  margin: 0 var(--ice-spacing);
  white-space: nowrap;
  float: none;
  width: auto;
  line-height: normal;
}

.ice-vote-box {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--ice-light);
  padding: 5px 8px;
  border-radius: var(--ice-radius);
  box-shadow: 0 1px 3px var(--ice-shadow);
  max-width: fit-content;
  border: 1px solid var(--ice-border);
}

.ice-vote-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: var(--ice-transition);
  background: transparent;
  font-size: var(--ice-font-size-sm);
  line-height: 1.2;
  font-family: inherit;
  color: var(--ice-gray);
}

.ice-vote-button:hover {
  background: rgba(0, 0, 0, 0.05);
}

.ice-vote-button:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(74, 110, 224, 0.25);
}

.ice-vote-button.ice-upvote {
  color: var(--ice-gray);
}

.ice-vote-button.ice-downvote {
  color: var(--ice-gray);
}

.ice-vote-button.active {
  font-weight: bold;
}

.ice-vote-button.ice-upvote.active {
  color: var(--ice-gray);
}

.ice-vote-button.ice-downvote.active {
  color: var(--ice-gray);
}

/* Hide vote counts initially */
.ice-vote-count.hide-count {
  display: none;
}

/* Hide empty vote text */
.ice-vote-text:empty {
  display: none;
}

.ice-vote-button .ice-vote-icon {
  width: 16px;
  height: 16px;
  display: inline-block;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  flex-shrink: 0;
}

.ice-vote-button.ice-upvote .ice-vote-icon {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%2328a745"><path d="M12 4.5l7 6.5-1.5 1.5L13 8.5V20h-2V8.5L6.5 12.5 5 11l7-6.5z"/></svg>');
}

.ice-vote-button.ice-downvote .ice-vote-icon {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23dc3545"><path d="M12 19.5l-7-6.5 1.5-1.5L11 15.5V4h2v11.5l4.5-4 1.5 1.5-7 6.5z"/></svg>');
}

.ice-vote-divider {
  width: 1px;
  height: 16px;
  background: var(--ice-border);
  margin: 0 6px;
}

.ice-vote-count {
  font-weight: 600;
  min-width: 16px;
  text-align: center;
}

.ice-vote-text {
  font-size: var(--ice-font-size-sm);
  font-weight: 500;
}

/* --------------------------------
 * 3. Toast Notification Styles
 * -------------------------------- */
.ice-toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 12px 24px;
  border-radius: var(--ice-radius);
  background: var(--ice-dark);
  color: #fff;
  font-size: var(--ice-font-size);
  z-index: 9999;
  opacity: 0;
  transform: translateY(20px);
  transition: var(--ice-transition);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  max-width: 300px;
  word-break: break-word;
}

.ice-toast-show {
  opacity: 1;
  transform: translateY(0);
}

.ice-toast-success {
  background: var(--ice-success);
}

.ice-toast-error {
  background: var(--ice-danger);
}

.ice-toast-info {
  background: var(--ice-info);
}

/* --------------------------------
 * 4. Table Styles
 * -------------------------------- */
.ice-table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 20px;
  border-radius: var(--ice-radius);
  box-shadow: 0 1px 3px var(--ice-shadow);
}

.ice-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
  max-width: 100%;
  margin: 0;
  background: #fff;
  border: 1px solid var(--ice-border);
}

.ice-table td, 
.ice-table th {
  border: 1px solid var(--ice-border);
  padding: 10px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  text-align: left;
  min-width: 60px;
  max-width: none;
  vertical-align: middle;
}

.ice-table th {
  background-color: var(--ice-light);
  font-weight: bold;
  border-bottom: 2px solid var(--ice-border);
}

.ice-table tbody tr:nth-child(even) {
  background-color: rgba(0, 0, 0, 0.02);
}

.ice-table tbody tr:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

/* Style for vote buttons inside table cells */
.ice-table td .ice-vote-container,
.ice-table th .ice-vote-container {
  margin: 0;
  display: inline-flex;
  width: auto;
}

/* --------------------------------
 * 5. Responsive Styles
 * -------------------------------- */
@media screen and (max-width: 767px) {
  .ice-vote-container {
    display: inline-flex;
    margin: 0 4px;
    vertical-align: middle;
  }
  
  .ice-vote-box {
    padding: 3px 6px;
  }
  
  .ice-vote-text {
    font-size: 11px;
  }
  
  .ice-table td, 
  .ice-table th {
    min-width: 50px;
    padding: 6px;
  }
  
  .ice-toast {
    left: 20px;
    right: 20px;
    max-width: none;
    text-align: center;
  }
}

/* --------------------------------
 * 6. Print Styles
 * -------------------------------- */
@media print {
  .ice-vote-container {
    display: inline-flex !important;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
  
  .ice-table-wrapper {
    overflow-x: visible;
    box-shadow: none;
  }
  
  .ice-table {
    border: 1px solid #000;
  }
  
  .ice-table td,
  .ice-table th {
    border: 1px solid #000;
  }
}
