/* Toolsquare Mailer - Styles */

/* Reset & Base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: #f5f5f5;
  color: #333;
  line-height: 1.5;
}

/* Header */
.header {
  background: white;
  padding: 15px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e0e0e0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 15px;
}

.logo {
  height: 32px;
}

.app-title {
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #666;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ccc;
}

.status-dot.connected {
  background: #10b981;
  animation: pulse 2s infinite;
}

.status-dot.loading {
  background: #f59e0b;
  animation: pulse 0.5s infinite;
}

.status-dot.error {
  background: #ef4444;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Buttons */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: #E83F4A;
  color: white;
}

.btn-primary:hover {
  background: #d63640;
}

.btn-secondary {
  background: #f0f0f0;
  color: #333;
}

.btn-secondary:hover {
  background: #e0e0e0;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-icon {
  padding: 8px;
  background: transparent;
  border: 1px solid #e0e0e0;
}

.btn-icon:hover {
  background: #f5f5f5;
}

/* Main Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* Section Card */
.section-card {
  background: white;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
  margin-bottom: 20px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 20px;
  border-bottom: 1px solid #e0e0e0;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
}

.section-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.section-body {
  padding: 20px;
}

/* Filter Toggle */
.filter-toggle {
  display: flex;
  background: #f5f5f5;
  border-radius: 6px;
  overflow: hidden;
}

.filter-btn {
  padding: 6px 12px;
  font-size: 13px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: #666;
}

.filter-btn.active {
  background: white;
  color: #333;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Table */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid #f0f0f0;
}

th {
  background: #fafafa;
  font-weight: 600;
  font-size: 13px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

tr:hover {
  background: #fafafa;
}

tr.expanded {
  background: #f5f5f5;
}

.checkbox-cell {
  width: 40px;
}

.expand-cell {
  width: 30px;
  color: #999;
  cursor: pointer;
}

.expand-cell:hover {
  color: #333;
}

.manager-name {
  font-weight: 500;
}

.manager-email {
  color: #666;
  font-size: 13px;
}

.tenant-badge {
  display: inline-block;
  padding: 3px 8px;
  background: #e0f2fe;
  color: #0369a1;
  border-radius: 4px;
  font-size: 12px;
  margin-right: 5px;
  margin-bottom: 3px;
}

.workspace-count {
  color: #999;
  font-size: 12px;
}

/* Expanded Details Row */
.details-row {
  display: none;
}

.details-row.visible {
  display: table-row;
}

.details-content {
  padding: 15px 15px 15px 55px;
  background: #fafafa;
}

.workspace-item {
  margin-bottom: 10px;
  padding: 10px;
  background: white;
  border-radius: 4px;
  border: 1px solid #e0e0e0;
}

.workspace-name {
  font-weight: 500;
  color: #E83F4A;
}

.equipment-list {
  margin-top: 8px;
  padding-left: 15px;
  color: #666;
  font-size: 13px;
}

.equipment-list li {
  margin: 3px 0;
}

/* Preview Section */
.preview-container {
  min-height: 200px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  background: #fafafa;
}

.preview-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: #999;
}

.preview-frame {
  width: 100%;
  min-height: 400px;
  border: none;
  background: white;
}

/* Actions Bar */
.actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  background: white;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
  margin-bottom: 20px;
}

.selection-info {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #666;
  font-size: 14px;
}

.selection-count {
  font-weight: 600;
  color: #333;
}

.btn-link {
  background: none;
  border: none;
  color: #E83F4A;
  font-size: 13px;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
  transition: background 0.2s;
}

.btn-link:hover {
  background: #fef2f2;
}

.btn-link.active {
  background: #fef2f2;
  font-weight: 600;
}

.hidden {
  display: none !important;
}

/* Tab Navigation */
.tab-nav {
  display: flex;
  gap: 5px;
  padding: 0 20px;
  background: white;
  border-bottom: 1px solid #e0e0e0;
}

.tab-nav-btn {
  padding: 12px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  color: #666;
  transition: all 0.2s;
}

.tab-nav-btn:hover {
  color: #333;
  background: #f5f5f5;
}

.tab-nav-btn.active {
  color: #E83F4A;
  border-bottom-color: #E83F4A;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid #e0e0e0;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #999;
}

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

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 15px 20px;
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Form Elements */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: #333;
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  font-size: 14px;
}

.form-input:focus {
  outline: none;
  border-color: #E83F4A;
}

.form-help {
  font-size: 12px;
  color: #999;
  margin-top: 4px;
}

/* Sticky Message Bar */
.sticky-message-bar {
  position: sticky;
  top: 63px;
  z-index: 99;
  background: #f5f5f5;
  padding: 0 20px;
}

.sticky-message-bar:empty {
  display: none;
}

/* Messages */
.message {
  padding: 12px 15px;
  border-radius: 6px;
  margin: 10px 0;
  font-size: 14px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.message-success {
  background: #d1fae5;
  color: #065f46;
}

.message-error {
  background: #fee2e2;
  color: #991b1b;
}

.message-info {
  background: #dbeafe;
  color: #1e40af;
}

.message-warning {
  background: #fef3c7;
  color: #92400e;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 15px;
  border-top: 1px solid #e0e0e0;
}

.page-info {
  color: #666;
  font-size: 14px;
}

/* Loading Spinner */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #E83F4A;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255,255,255,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 40px;
  color: #999;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 15px;
  opacity: 0.5;
}

/* Test Email Input */
.test-email-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 15px;
}

.test-email-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  font-size: 14px;
}

/* News Editor with Preview */
.news-editor {
  display: flex;
  gap: 15px;
}

.news-editor-left {
  flex: 1;
  min-width: 0;
}

.news-editor-right {
  flex: 1;
  min-width: 0;
  display: none;
}

.news-editor-right.visible {
  display: block;
}

.news-textarea {
  width: 100%;
  min-height: 120px;
  padding: 12px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}

.news-textarea:focus {
  outline: none;
  border-color: #E83F4A;
}

.news-preview {
  min-height: 120px;
  padding: 12px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  background: #fafafa;
  font-size: 14px;
  line-height: 1.6;
  overflow-y: auto;
}

.news-preview:empty::before {
  content: 'Preview will appear here...';
  color: #999;
  font-style: italic;
}

.news-preview h3 {
  margin: 15px 0 10px 0;
  font-size: 15px;
  color: #333;
  font-weight: 700;
}

.news-preview h4 {
  margin: 15px 0 8px 0;
  font-size: 14px;
  color: #333;
  font-weight: 600;
}

.news-preview ul {
  margin: 10px 0;
  padding-left: 20px;
}

.news-preview li {
  margin: 5px 0;
}

.news-preview a {
  color: #E83F4A;
  text-decoration: underline;
}

.news-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 5px;
}

.char-count {
  font-size: 12px;
  color: #999;
}

.preview-toggle {
  font-size: 12px;
  color: #666;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
  transition: background 0.2s;
}

.preview-toggle:hover {
  background: #f0f0f0;
}

.preview-toggle.active {
  color: #E83F4A;
  background: #fef2f2;
}

/* Tenant Filter Select */
.tenant-select {
  padding: 6px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  font-size: 13px;
  background: white;
  cursor: pointer;
  min-width: 150px;
}

.tenant-select:focus {
  outline: none;
  border-color: #E83F4A;
}

/* Campaign History Styles */
.campaign-stats {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: #666;
}

.stat-value {
  font-weight: 600;
  color: #333;
}

.stat-value.success { color: #10b981; }
.stat-value.warning { color: #f59e0b; }
.stat-value.danger { color: #ef4444; }

.campaign-row {
  cursor: pointer;
}

.campaign-row:hover {
  background: #f0f8ff;
}

.campaign-name {
  font-weight: 500;
  color: #333;
}

.campaign-date {
  font-size: 12px;
  color: #999;
}

.campaign-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.campaign-status.sent {
  background: #d1fae5;
  color: #065f46;
}

.campaign-status.sending {
  background: #fef3c7;
  color: #92400e;
}

.campaign-status.draft {
  background: #f3f4f6;
  color: #6b7280;
}

/* Campaign Detail Modal (wider) */
.modal.modal-lg {
  max-width: 800px;
}

.campaign-detail-header {
  margin-bottom: 20px;
}

.campaign-detail-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 15px;
  margin-bottom: 20px;
  padding: 15px;
  background: #f9fafb;
  border-radius: 8px;
}

.campaign-stat-box {
  text-align: center;
}

.campaign-stat-box .value {
  font-size: 24px;
  font-weight: 600;
  color: #333;
}

.campaign-stat-box .label {
  font-size: 12px;
  color: #666;
  text-transform: uppercase;
}

.recipient-table {
  font-size: 13px;
}

.recipient-table th {
  font-size: 11px;
  padding: 8px 10px;
}

.recipient-table td {
  padding: 8px 10px;
}

.recipient-status {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
}

.recipient-status.sent { background: #dbeafe; color: #1e40af; }
.recipient-status.delivered { background: #d1fae5; color: #065f46; }
.recipient-status.opened { background: #fef3c7; color: #92400e; }
.recipient-status.clicked { background: #d1fae5; color: #065f46; }
.recipient-status.bounced { background: #fee2e2; color: #991b1b; }
.recipient-status.complained { background: #fce7f3; color: #9d174d; }

.news-content-preview {
  max-height: 150px;
  overflow-y: auto;
  padding: 12px;
  background: #fafafa;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.5;
}

/* Login Screen */
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
}

.login-card {
  background: white;
  border-radius: 12px;
  padding: 40px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  text-align: center;
  max-width: 400px;
  width: 90%;
}

.login-logo {
  font-size: 32px;
  font-weight: 700;
  color: #E83F4A;
  margin-bottom: 10px;
}

.login-subtitle {
  color: #666;
  margin-bottom: 30px;
}

.login-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.login-btn:hover {
  background: #f5f5f5;
  border-color: #ccc;
}

.login-btn svg {
  width: 20px;
  height: 20px;
}

.login-error {
  margin-top: 20px;
  padding: 10px;
  background: #fee2e2;
  color: #991b1b;
  border-radius: 6px;
  font-size: 13px;
}

.login-loading {
  margin-top: 20px;
  color: #666;
}

/* User Info in Header */
.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #666;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #E83F4A;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
}

.user-name {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-btn {
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 4px;
}

.logout-btn:hover {
  background: #f0f0f0;
  color: #333;
}
