/**
 * Shared Component Styles
 * Extracted from individual templates for consistency
 */

/* ============================================
   EDITABLE FIELDS
   ============================================ */

.editable {
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    display: inline-block;
    min-width: 50px;
    transition: background 0.15s;
}

.editable:hover {
    background: var(--bg-hover);
}

.editable.editing {
    padding: 0;
}

.edit-input {
    width: 100%;
    padding: 0.2rem 0.4rem;
    border: 1px solid var(--accent);
    border-radius: 3px;
    background: var(--bg);
    color: var(--text);
    font-size: inherit;
    font-family: inherit;
}

.edit-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Cost fields */
.editable-cost {
    cursor: pointer;
    padding: 0.1rem 0.2rem;
    border-radius: 2px;
    transition: background 0.15s;
}

.editable-cost:hover {
    background: var(--bg-hover);
}

.cost-input {
    width: 70px;
    padding: 0.1rem 0.2rem;
    border: 1px solid var(--accent);
    border-radius: 2px;
    background: var(--bg);
    color: var(--text);
    font-size: inherit;
    text-align: right;
}

/* ============================================
   INLINE SELECT DROPDOWNS
   ============================================ */

.inline-select {
    padding: 0.25rem 0.4rem;
    border: 1px solid transparent;
    border-radius: 3px;
    background: transparent;
    color: var(--text);
    font-size: 0.85rem;
    cursor: pointer;
    width: 100%;
    transition: all 0.15s;
}

.inline-select:hover,
.inline-select:focus {
    border-color: var(--border);
    background: var(--bg-hover);
}

.inline-select option {
    background: var(--bg-card);
    color: var(--text);
}

/* Priority select colors */
.priority-select option[value="High"] { color: #ef5350; }
.priority-select option[value="Medium"] { color: #ffb74d; }
.priority-select option[value="Low"] { color: #8892a0; }

/* Urgency select colors */
.urgency-select option[value="Immediate"] { color: #ef5350; }
.urgency-select option[value="Week 1-2"] { color: #ffb74d; }

/* ============================================
   STATUS PILLS (Click to advance)
   ============================================ */

.status-pill {
    display: inline-block;
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}

.status-pill:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.status-pill:active {
    transform: scale(0.98);
}

.status-not-started {
    background: rgba(136, 146, 160, 0.2);
    color: var(--text-dim);
}

.status-in-progress {
    background: rgba(99, 102, 241, 0.2);
    color: var(--accent);
}

.status-complete {
    background: rgba(102, 187, 106, 0.2);
    color: var(--success);
}

.status-blocked {
    background: rgba(239, 83, 80, 0.2);
    color: var(--danger);
}

/* Status context menu */
.status-menu {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    z-index: 1000;
}

.status-menu-item {
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: background 0.15s;
}

.status-menu-item:hover {
    background: var(--bg-hover);
}

.status-menu-item.status-blocked {
    color: var(--danger);
    border-top: 1px solid var(--border);
}

/* ============================================
   DELETE BUTTON
   ============================================ */

.delete-form {
    margin: 0;
}

.btn-delete {
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    opacity: 0.3;
    transition: all 0.2s;
}

.btn-delete:hover {
    opacity: 1;
    color: var(--danger);
    background: rgba(239, 83, 80, 0.1);
}

tr:hover .btn-delete {
    opacity: 0.7;
}

/* ============================================
   TABLE STYLES
   ============================================ */

/* Base data table styling - improved typography and scaling */
.data-table {
    width: 100%;
    table-layout: auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 0.9rem;
    line-height: 1.5;
    border-collapse: collapse;
}

.data-table th {
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--text-dim);
    padding: 0.75rem 0.75rem;
    text-align: left;
    white-space: nowrap;
    background: var(--bg-input);
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 0.65rem 0.75rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
}

.data-table tbody tr {
    transition: background 0.15s;
}

.data-table tbody tr:hover {
    background: var(--bg-hover);
}

/* Column width classes for flexible scaling */
.col-xs { width: 5%; min-width: 50px; }
.col-sm { width: 8%; min-width: 70px; }
.col-md { width: 12%; min-width: 100px; }
.col-lg { width: 18%; min-width: 150px; }
.col-xl { width: 25%; min-width: 200px; }
.col-auto { width: auto; }

/* Text alignment helpers */
.col-center { text-align: center; }
.col-right { text-align: right; }

/* Responsive column hiding */
@media (max-width: 1400px) {
    .hide-xl { display: none; }
}

@media (max-width: 1200px) {
    .hide-lg { display: none; }
    .data-table { font-size: 0.85rem; }
}

@media (max-width: 900px) {
    .hide-md { display: none; }
}

@media (max-width: 600px) {
    .hide-sm { display: none; }
    .data-table th,
    .data-table td {
        padding: 0.5rem;
    }
}

/* Monospace columns for IDs and codes */
.col-mono {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-size: 0.85em;
}

/* Dim secondary text */
.col-dim {
    color: var(--text-dim);
    font-size: 0.85rem;
}

/* Truncate with ellipsis */
.col-truncate {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Card wrapper for tables */
.table-card {
    overflow-x: auto;
}

.editable-table td {
    padding: 0.4rem 0.5rem;
    vertical-align: middle;
}

/* Sortable columns */
th[data-sortable] {
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

th[data-sortable]:hover {
    background: var(--bg-hover);
}

.sort-indicator {
    opacity: 0.6;
    font-size: 0.7em;
}

/* Sticky header */
.sticky-header thead {
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 10;
}

.sticky-header thead th {
    background: var(--bg-card);
}

/* Row expansion */
tr[data-expandable] {
    cursor: pointer;
}

tr.expanded {
    background: var(--bg-hover);
}

.row-details {
    background: var(--bg);
}

.row-details td {
    padding: 0;
}

.details-content {
    padding: 1rem 1.5rem;
    border-left: 3px solid var(--accent);
    margin-left: 1rem;
}

.details-section {
    margin-bottom: 0.75rem;
}

.details-section:last-child {
    margin-bottom: 0;
}

.details-section strong {
    color: var(--text-dim);
    font-size: 0.8rem;
    text-transform: uppercase;
}

.details-section p {
    margin: 0.25rem 0 0 0;
    color: var(--text);
}

.details-loading {
    padding: 1rem;
    color: var(--text-dim);
    font-style: italic;
}

/* Quick add row */
.quick-add-row {
    background: var(--bg);
    border-top: 2px dashed var(--border);
}

.quick-add-row td {
    padding: 0.5rem;
}

.quick-add-row input,
.quick-add-row select {
    width: 100%;
    padding: 0.4rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-size: 0.85rem;
}

.quick-add-row input:focus,
.quick-add-row select:focus {
    border-color: var(--accent);
    outline: none;
}

.quick-add-save {
    padding: 0.4rem 0.8rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.15s;
}

.quick-add-save:hover {
    background: var(--accent-dim);
}

/* ============================================
   SAVE STATE INDICATORS
   ============================================ */

.saving {
    opacity: 0.6;
    pointer-events: none;
}

.saving::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-left: 0.5rem;
    border: 2px solid var(--accent);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.save-success {
    animation: flash-success 0.5s;
}

@keyframes flash-success {
    0% { background: var(--success); }
    100% { background: transparent; }
}

.save-error {
    animation: flash-error 0.3s;
}

@keyframes flash-error {
    0%, 100% { background: transparent; }
    50% { background: rgba(239, 83, 80, 0.2); }
}

.save-error-tooltip {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: var(--danger);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 100;
}

/* ============================================
   BOOLEAN TOGGLE SWITCHES
   ============================================ */

.bool-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s ease;
    user-select: none;
    background: rgba(136, 146, 160, 0.15);
    color: var(--text-dim);
    border: 1px solid transparent;
}

.bool-toggle:hover {
    background: rgba(136, 146, 160, 0.25);
    border-color: var(--border);
}

.bool-toggle.active {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent);
    border-color: rgba(99, 102, 241, 0.3);
}

.bool-toggle.active:hover {
    background: rgba(99, 102, 241, 0.25);
}

.bool-toggle-indicator {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--bg-hover);
    border: 2px solid var(--border);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
}

.bool-toggle.active .bool-toggle-indicator {
    background: var(--accent);
    border-color: var(--accent);
}

.bool-toggle.active .bool-toggle-indicator::after {
    content: '\2713';
    color: white;
}

/* Inline editable row for details */
.editable-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

.editable-row:hover {
    background: var(--bg-hover);
    margin: 0 -0.5rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    border-radius: var(--radius-sm);
}

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

.editable-row-label {
    flex: 0 0 140px;
    color: var(--text-dim);
    font-size: 0.8rem;
    font-weight: 500;
}

.editable-row-value {
    flex: 1;
    min-width: 0;
}

/* ============================================
   VALIDATION STATES
   ============================================ */

.validation-error {
    border-color: var(--danger) !important;
    background: rgba(239, 83, 80, 0.1) !important;
}

.validation-tooltip {
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--danger);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 100;
    margin-top: 2px;
}

/* ============================================
   BADGES (Extended)
   ============================================ */

.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success { background: rgba(102, 187, 106, 0.2); color: var(--success); }
.badge-warning { background: rgba(255, 183, 77, 0.2); color: var(--warning); }
.badge-danger { background: rgba(239, 83, 80, 0.2); color: var(--danger); }
.badge-info { background: rgba(99, 102, 241, 0.2); color: var(--accent); }
.badge-neutral { background: rgba(136, 146, 160, 0.2); color: var(--text-dim); }

/* Small badges for indicators */
.badge-sm {
    padding: 0.1rem 0.4rem;
    font-size: 0.65rem;
    margin-left: 0.25rem;
    vertical-align: middle;
}

/* ============================================
   PRIORITY INDICATORS
   ============================================ */

.priority-high { border-left: 3px solid var(--danger); }
.priority-medium { border-left: 3px solid var(--warning); }
.priority-low { border-left: 3px solid var(--text-dim); }

/* ============================================
   MOBILE STYLES
   ============================================ */

/* Mobile navigation */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 0.5rem;
    z-index: 1000;
}

.mobile-nav-items {
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem;
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.7rem;
    min-width: 60px;
}

.mobile-nav-item.active {
    color: var(--accent);
}

.mobile-nav-icon {
    font-size: 1.3rem;
    margin-bottom: 0.2rem;
}

/* Slide-out drawer */
.drawer-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1001;
}

.drawer-overlay.visible {
    display: block;
}

.drawer {
    position: fixed;
    top: 0;
    right: -280px;
    width: 280px;
    height: 100%;
    background: var(--bg-card);
    z-index: 1002;
    transition: right 0.3s ease;
    overflow-y: auto;
    padding: 1rem;
}

.drawer.visible {
    right: 0;
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}

.drawer-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.5rem;
    cursor: pointer;
}

.drawer a {
    display: block;
    padding: 0.75rem 0;
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px solid var(--border);
}

.drawer a:hover {
    color: var(--accent);
}

.drawer-theme-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 0;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-size: 1rem;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
}

.drawer-theme-toggle:hover {
    color: var(--accent);
}

.drawer-theme-toggle .theme-icon-dark,
.drawer-theme-toggle .theme-icon-light {
    font-size: 1.1rem;
}

/* Show/hide icons based on theme in drawer */
[data-theme="dark"] .drawer-theme-toggle .theme-icon-dark { display: inline; }
[data-theme="dark"] .drawer-theme-toggle .theme-icon-light { display: none; }
[data-theme="light"] .drawer-theme-toggle .theme-icon-dark { display: none; }
[data-theme="light"] .drawer-theme-toggle .theme-icon-light { display: inline; }

/* Card view for mobile tables */
.card-view {
    display: none;
}

.item-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.item-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.item-card-title {
    font-weight: 500;
    flex: 1;
}

.item-card-id {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-left: 0.5rem;
}

.item-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.item-card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

/* Swipe actions (touch) */
.swipe-container {
    overflow: hidden;
    position: relative;
}

.swipe-actions {
    position: absolute;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
}

.swipe-actions-left {
    left: 0;
    transform: translateX(-100%);
}

.swipe-actions-right {
    right: 0;
    transform: translateX(100%);
}

.swipe-action {
    padding: 1rem;
    color: white;
    font-weight: 500;
}

.swipe-action-complete {
    background: var(--success);
}

.swipe-action-edit {
    background: var(--accent);
}

/* Mobile responsive breakpoint */
@media (max-width: 768px) {
    .mobile-nav {
        display: block;
    }

    main {
        padding-bottom: 70px;
    }

    /* Show card view, hide table on mobile */
    .table-view {
        display: none;
    }

    .card-view {
        display: block;
    }

    /* Larger touch targets */
    .btn, .status-pill, .inline-select {
        min-height: 44px;
        min-width: 44px;
    }

    .editable {
        padding: 0.5rem;
    }

    /* Filters stack vertically */
    .filters {
        flex-direction: column;
    }

    .filters select {
        width: 100%;
    }
}

/* ============================================
   GLOBAL SEARCH
   ============================================ */

.global-search {
    position: relative;
}

.global-search-input {
    width: 200px;
    padding: 0.4rem 0.75rem 0.4rem 2rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text);
    font-size: 0.85rem;
    transition: all 0.2s;
}

.global-search-input:focus {
    width: 280px;
    border-color: var(--accent);
    outline: none;
}

.global-search-input::placeholder {
    color: var(--text-dim);
}

.global-search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    pointer-events: none;
}

.global-search-shortcut {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    color: var(--text-dim);
    background: var(--bg-card);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    border: 1px solid var(--border);
}

/* Search results dropdown */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    margin-top: 0.5rem;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.search-results.visible {
    display: block;
}

.search-result-group {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.search-result-group:last-child {
    border-bottom: none;
}

.search-result-group-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-dim);
    padding: 0.25rem 0.5rem;
}

.search-result-item {
    display: block;
    padding: 0.5rem;
    color: var(--text);
    text-decoration: none;
    border-radius: 4px;
    transition: background 0.15s;
}

.search-result-item:hover,
.search-result-item.selected {
    background: var(--bg-hover);
}

.search-result-item-id {
    font-size: 0.75rem;
    color: var(--text-dim);
}

/* ============================================
   REFERENCE HUB TABS
   ============================================ */

.tab-container {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.tab {
    padding: 0.75rem 1.25rem;
    color: var(--text-dim);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
    font-weight: 500;
}

.tab:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-content {
    display: none;
}

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

/* ============================================
   COMMAND CENTER DASHBOARD
   ============================================ */

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 1.5rem;
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.focus-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
}

.focus-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.focus-section-title {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.focus-section-count {
    background: var(--danger);
    color: white;
    font-size: 0.75rem;
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
}

/* Quick action items */
.quick-action-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg);
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.quick-action-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-radius: 50%;
    margin-right: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quick-action-checkbox:hover {
    border-color: var(--success);
    background: rgba(102, 187, 106, 0.1);
}

.quick-action-checkbox.completing {
    background: var(--success);
    border-color: var(--success);
}

.quick-action-checkbox.completing::after {
    content: '\2713';
    color: white;
    font-size: 0.8rem;
}

.quick-action-content {
    flex: 1;
}

.quick-action-title {
    font-weight: 500;
}

.quick-action-meta {
    font-size: 0.75rem;
    color: var(--text-dim);
}

/* Stats sidebar */
.stats-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
}

.stat-card-title {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.stat-card-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-card-detail {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-top: 0.25rem;
}

/* Mini progress bars */
.mini-progress {
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.mini-progress-bar {
    height: 100%;
    background: var(--accent);
    transition: width 0.3s;
}
