/* CoolCards.in Invoice & Billing Studio Styles */

:root {
  --inv-bg: #0b1110;
  --inv-sidebar-bg: #111a17;
  --inv-card-bg: #16241f;
  --inv-card-hover: #1c2e28;
  --inv-border: rgba(211, 235, 217, 0.12);
  --inv-border-strong: rgba(211, 235, 217, 0.24);
  --inv-mint: #c5f58a;
  --inv-mint-glow: rgba(197, 245, 138, 0.2);
  --inv-text: #f4f4e9;
  --inv-muted: #9aa89f;
  --inv-dim: #64756a;
}

/* Studio Layout Container */
.inv-studio {
  display: flex;
  height: calc(100vh - 70px);
  width: 100%;
  overflow: hidden;
  background: var(--inv-bg);
  position: relative;
}

/* Left Editor Sidebar */
.inv-editor-sidebar {
  width: 50%;
  min-width: 360px;
  max-width: calc(100% - 380px);
  height: 100%;
  overflow-y: auto;
  border-right: none;
  background: var(--inv-sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

/* Draggable Center Splitter / Resizer */
.inv-resizer {
  width: 14px;
  margin: 0 -7px;
  cursor: col-resize;
  position: relative;
  z-index: 45;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.15s ease;
}
.inv-resizer:hover,
.inv-resizer.is-dragging {
  background: rgba(197, 245, 138, 0.12);
}
.inv-resizer-handle {
  width: 4px;
  height: 38px;
  border-radius: 4px;
  background: var(--inv-border-strong);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: all 0.2s ease;
}
.inv-resizer-handle span {
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: var(--inv-muted);
  display: block;
}
.inv-resizer:hover .inv-resizer-handle,
.inv-resizer.is-dragging .inv-resizer-handle {
  background: var(--inv-mint);
  box-shadow: 0 0 10px var(--inv-mint-glow);
  height: 56px;
}
.inv-resizer:hover .inv-resizer-handle span,
.inv-resizer.is-dragging .inv-resizer-handle span {
  background: #0b1110;
}

body.is-resizing-inv,
body.is-resizing-inv * {
  cursor: col-resize !important;
  user-select: none !important;
  -webkit-user-select: none !important;
}

/* Sticky Toolbar */
.inv-sticky-toolbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(17, 26, 23, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--inv-border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.inv-toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.inv-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.inv-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  text-decoration: none;
}

.inv-btn-primary {
  background: var(--inv-mint);
  color: #0b1110;
  border-color: var(--inv-mint);
}
.inv-btn-primary:hover {
  background: #d8ffa6;
  box-shadow: 0 0 16px var(--inv-mint-glow);
}

.inv-btn-outline {
  background: rgba(255, 255, 255, 0.04);
  color: var(--inv-text);
  border-color: var(--inv-border);
}
.inv-btn-outline:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--inv-border-strong);
}

.inv-btn-danger {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.2);
}
.inv-btn-danger:hover {
  background: rgba(239, 68, 68, 0.18);
}

.inv-btn-small {
  padding: 5px 10px;
  font-size: 11.5px;
}

/* Editor Scrollable Body */
.inv-editor-body {
  padding: 20px;
  flex: 1;
}

/* Accordion Sections */
.inv-section {
  background: var(--inv-card-bg);
  border: 1px solid var(--inv-border);
  border-radius: 10px;
  margin-bottom: 16px;
  overflow: visible; /* Allows custom glassmorphic dropdown menus to float over section bounds */
  transition: border-color 0.2s ease;
  position: relative;
}

.inv-section:hover {
  border-color: var(--inv-border-strong);
}

.inv-section-header {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  background: rgba(0, 0, 0, 0.12);
  border-bottom: 1px solid transparent;
  border-top-left-radius: 9px;
  border-top-right-radius: 9px;
}

.inv-section-header.active {
  border-bottom-color: var(--inv-border);
}

.inv-section-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inv-section-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: rgba(197, 245, 138, 0.1);
  color: var(--inv-mint);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.inv-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--inv-text);
  margin: 0;
}

.inv-section-badge {
  font-size: 10.5px;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--inv-muted);
}

.inv-section-chevron {
  color: var(--inv-muted);
  transition: transform 0.25s ease;
  font-size: 12px;
}

.inv-section-header.active .inv-section-chevron {
  transform: rotate(180deg);
}

.inv-section-content {
  padding: 18px;
}

/* Form Grid & Inputs */
.inv-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.inv-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.inv-grid-4 {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 10px;
}

:root {
  --inv-control-height: 48px;
}

.inv-field {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
}

.inv-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--inv-muted);
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
}

/* ==========================================================================
   UNIFIED FORM FIELD CONTROLS HEIGHT & ALIGNMENT
   Guarantees that all inputs, date pickers, native selects and custom
   dropdown triggers inside .inv-field share the exact same height (48px),
   border radius, border weight, background, and vertical centering.
   ========================================================================== */
.inv-input, .inv-select {
  background: rgba(14, 23, 19, 0.92);
  border: 1.5px solid var(--inv-border);
  color: var(--inv-text, #f4f4e9);
  border-radius: 8px;
  padding: 0 14px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  width: 100%;
  height: var(--inv-control-height);
  min-height: var(--inv-control-height);
  max-height: var(--inv-control-height);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  line-height: normal;
  transition: border-color 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1), background 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.inv-field > .inv-input,
.inv-field > input.inv-input,
.inv-field > select.inv-select,
.inv-field > .cc-dropdown-wrap {
  width: 100%;
  height: var(--inv-control-height);
  min-height: var(--inv-control-height);
  max-height: var(--inv-control-height);
  box-sizing: border-box;
}

.inv-field .cc-dropdown-trigger {
  width: 100% !important;
  height: var(--inv-control-height) !important;
  min-height: var(--inv-control-height) !important;
  max-height: var(--inv-control-height) !important;
  box-sizing: border-box !important;
  padding: 0 14px !important;
  border-radius: 8px !important;
  border: 1.5px solid var(--inv-border) !important;
  background: rgba(14, 23, 19, 0.92) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 10px !important;
  transition: border-color 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1), background 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

/* Vertical Centering & Typography inside Dropdown Trigger */
.inv-field .cc-dropdown-selected {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  height: 100% !important;
  overflow: hidden !important;
  flex: 1 !important;
}

.inv-field .cc-dropdown-selected-icon {
  width: 24px !important;
  height: 24px !important;
  border-radius: 6px !important;
  font-size: 11.5px !important;
  flex-shrink: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.inv-field .cc-dropdown-selected-text-wrap {
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  line-height: 1.2 !important;
  gap: 1px !important;
  overflow: hidden !important;
  min-width: 0 !important;
}

.inv-field .cc-dropdown-selected-title,
.inv-field .cc-dropdown-selected-text {
  font-size: 13px !important;
  font-weight: 650 !important;
  color: var(--inv-text, #f4f4e9) !important;
  line-height: 1.25 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.inv-field .cc-dropdown-selected-sub {
  font-size: 10.5px !important;
  color: var(--inv-muted, #728a7c) !important;
  font-weight: 500 !important;
  line-height: 1.15 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.inv-field .cc-dropdown-chevron-icon {
  font-size: 11.5px !important;
  color: var(--inv-mint, #c5f58a) !important;
  flex-shrink: 0 !important;
  margin-left: auto !important;
  align-self: center !important;
}

/* Date input alignment */
.inv-field input[type="date"].inv-input {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 0 12px !important;
}

.inv-field input[type="date"].inv-input::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.75;
  filter: invert(0.85);
  padding: 4px;
  border-radius: 4px;
  transition: opacity 0.2s, background-color 0.2s;
  margin-left: auto;
}

.inv-field input[type="date"].inv-input::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
  background-color: rgba(197, 245, 138, 0.15);
}

.inv-field input[type="date"].inv-input::-webkit-date-and-time-value {
  text-align: left;
  line-height: normal;
}

/* Hover and Focus Glow */
.inv-field .inv-input:hover,
.inv-field .inv-select:hover,
.inv-field .cc-dropdown-trigger:hover {
  border-color: rgba(197, 245, 138, 0.45) !important;
  background: rgba(18, 30, 24, 0.98) !important;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35) !important;
}

.inv-field .inv-input:focus,
.inv-field .inv-select:focus,
.inv-field .cc-dropdown-trigger:focus-visible,
.inv-field .cc-dropdown-trigger[aria-expanded="true"] {
  border-color: var(--inv-mint) !important;
  box-shadow: 0 0 0 3px rgba(197, 245, 138, 0.2), 0 8px 25px rgba(0, 0, 0, 0.45) !important;
  background: rgba(18, 30, 24, 0.98) !important;
  outline: none !important;
}

/* Multi-line textareas retain auto/flexible height */
.inv-textarea {
  background: rgba(14, 23, 19, 0.92);
  border: 1.5px solid var(--inv-border);
  color: var(--inv-text);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  outline: none;
  resize: vertical;
  min-height: 72px;
  height: auto !important;
  max-height: none !important;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
  box-sizing: border-box;
}

.inv-textarea:focus {
  border-color: var(--inv-mint);
  box-shadow: 0 0 0 3px rgba(197, 245, 138, 0.2), 0 8px 25px rgba(0, 0, 0, 0.45);
}

/* Line Items Table in Editor */
.inv-items-box {
  border: 1px solid var(--inv-border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
}

.inv-item-row {
  background: rgba(0, 0, 0, 0.16);
  border-bottom: 1px solid var(--inv-border);
  padding: 12px;
  position: relative;
}

.inv-item-row:last-child {
  border-bottom: none;
}

.inv-item-top {
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
}

.inv-item-bottom {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1.2fr 1fr 1.2fr auto;
  gap: 8px;
  align-items: center;
}

.inv-item-del-btn {
  background: transparent;
  border: none;
  color: #ef4444;
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
  transition: background 0.2s ease;
}
.inv-item-del-btn:hover {
  background: rgba(239, 68, 68, 0.15);
}

/* Right Live Preview Area */
.inv-preview-area {
  flex: 1;
  min-width: 380px;
  height: 100%;
  background: #080d0c;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-left: 1px solid var(--inv-border);
}

.inv-preview-header {
  padding: 10px 20px;
  background: rgba(14, 23, 20, 0.9);
  border-bottom: 1px solid var(--inv-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.inv-preview-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inv-zoom-widget {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--inv-border);
  border-radius: 6px;
  overflow: hidden;
}

.inv-zoom-btn {
  background: transparent;
  border: none;
  color: var(--inv-muted);
  padding: 5px 10px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.inv-zoom-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--inv-text);
}
.inv-zoom-btn:active {
  background: rgba(197, 245, 138, 0.15);
  color: var(--inv-mint);
}

.inv-zoom-reset {
  background: transparent;
  border: none;
  border-left: 1px solid var(--inv-border);
  border-right: 1px solid var(--inv-border);
  color: var(--inv-text);
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  min-width: 52px;
  text-align: center;
  transition: all 0.15s ease;
  line-height: 1;
}
.inv-zoom-reset:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--inv-mint);
}

.inv-preview-viewport {
  flex: 1;
  overflow: auto;
  padding: 30px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.inv-paper-wrapper {
  background: #ffffff;
  color: #1e293b;
  width: 100%;
  max-width: 820px;
  min-height: 1120px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  border-radius: 4px;
  overflow: hidden;
  transition: transform 0.2s ease;
  transform-origin: top center;
}

/* Template Selector Carousel / Grid */
.inv-template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.inv-template-card {
  background: rgba(0, 0, 0, 0.2);
  border: 2px solid var(--inv-border);
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  position: relative;
}

.inv-template-card:hover {
  border-color: var(--inv-border-strong);
  transform: translateY(-2px);
}

.inv-template-card.active {
  border-color: var(--inv-mint);
  background: rgba(197, 245, 138, 0.08);
}

.inv-template-preview-box {
  height: 60px;
  border-radius: 4px;
  margin-bottom: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  padding: 6px;
  gap: 4px;
  overflow: hidden;
}

.inv-template-card-name {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--inv-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inv-template-card-badge {
  font-size: 9px;
  color: var(--inv-muted);
}

/* Mobile Tabs Toggle */
.inv-mobile-tabs {
  display: none;
  background: var(--inv-sidebar-bg);
  border-bottom: 1px solid var(--inv-border);
  padding: 8px 12px;
}

@media (max-width: 1024px) {
  .inv-studio {
    flex-direction: column;
    height: auto;
    min-height: calc(100vh - 70px);
  }
  .inv-mobile-tabs {
    display: flex;
    gap: 8px;
    position: sticky;
    top: 0;
    z-index: 60;
  }
  .inv-mobile-tab-btn {
    flex: 1;
    padding: 8px;
    background: transparent;
    border: 1px solid var(--inv-border);
    color: var(--inv-muted);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
  }
  .inv-mobile-tab-btn.active {
    background: var(--inv-mint);
    color: #0b1110;
    border-color: var(--inv-mint);
  }
  .inv-editor-sidebar {
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    height: auto;
    border-right: none;
  }
  .inv-resizer {
    display: none !important;
  }
  .inv-preview-area {
    width: 100%;
    height: 800px;
    border-left: none;
  }
  .inv-grid-2, .inv-grid-3, .inv-grid-4 {
    grid-template-columns: 1fr;
  }
  .inv-item-bottom {
    grid-template-columns: 1fr 1fr;
  }
}
