/**
 * Toolmaker Portal - Styles
 */

/* ─── Project Group Cards ─── */

.tm-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.25rem;
}

.tm-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 1.25rem;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}

.tm-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: #cbd5e1;
    text-decoration: none;
    color: inherit;
}

.tm-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.tm-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}

.tm-card-meta {
    font-size: 0.813rem;
    color: #64748b;
    margin-top: 0.25rem;
}

/* ─── Thumbnail Strip ─── */

.tm-thumbnail-strip {
    display: flex;
    gap: 0.5rem;
    margin: 0.75rem 0;
}

.tm-thumbnail {
    width: 60px;
    height: 60px;
    border-radius: 0.375rem;
    object-fit: cover;
    border: 1px solid #e2e8f0;
}

.tm-thumbnail-placeholder {
    width: 60px;
    height: 60px;
    border-radius: 0.375rem;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 1.25rem;
}

/* ─── Progress Bar ─── */

.tm-progress-bar {
    width: 100%;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
    margin-top: 0.75rem;
}

.tm-progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.tm-progress-fill.green  { background: #16a34a; }
.tm-progress-fill.yellow { background: #f59e0b; }
.tm-progress-fill.red    { background: #ef4444; }
.tm-progress-fill.blue   { background: #3b82f6; }

.tm-progress-label {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 0.25rem;
    text-align: right;
}

/* ─── Status Badges ─── */

.tm-status-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.tm-status-active   { background: #dcfce7; color: #166534; }
.tm-status-inactive { background: #f1f5f9; color: #475569; }
.tm-status-archived { background: #fef3c7; color: #92400e; }

/* ─── Response Flag / Traffic Light ─── */

.tm-response-flag {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.813rem;
}

.tm-traffic-light {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.tm-traffic-light.pending  { background: #ef4444; }
.tm-traffic-light.answered { background: #16a34a; }

/* ─── Comment Thread ─── */

.tm-comment-thread {
    margin-left: 2rem;
    padding-left: 1rem;
    border-left: 2px solid #e2e8f0;
}

.tm-comment-thread .tm-comment-thread {
    margin-left: 1.5rem;
}

/* ─── Tracking Report Stats ─── */

.tm-stat-card {
    text-align: center;
    padding: 1.25rem 1rem;
}

.tm-stat-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    opacity: 0.7;
}

.tm-stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1;
}

.tm-stat-label {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 0.375rem;
}

/* ─── Tracking Action Icons ─── */

.tm-action-icon {
    width: 1.25rem;
    text-align: center;
    display: inline-block;
    margin-right: 0.375rem;
}

/* ─── Tracking Empty State ─── */

.tm-empty-state {
    padding: 3rem 1rem;
    text-align: center;
}

.tm-empty-state i {
    font-size: 3.5rem;
    color: #cbd5e1;
    display: block;
    margin-bottom: 1rem;
}

.tm-empty-state h4 {
    color: #64748b;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.tm-empty-state p {
    color: #94a3b8;
    font-size: 0.875rem;
    max-width: 400px;
    margin: 0 auto;
}

/* ─── Discussion Accordion ─── */

.tm-discussion-toggle {
    user-select: none;
}

.tm-chevron {
    transition: transform 0.2s ease;
}

.tm-discussion-body .tc-content {
    margin-top: 0.5rem;
}

/* ─── Comment Styling (Client Portal) ─── */
/* Matches the clean admin backend look */

/* Overall container: remove default jquery-comments borders/shadows */
.tm-discussion-body .jquery-comments {
    background: transparent;
    box-shadow: none;
    border: none;
    padding: 0;
}

/* Navigation bar (Newest / Oldest / Attachments): subtler */
.tm-discussion-body .jquery-comments .navigation {
    border-bottom: 1px solid #f1f5f9;
    margin-bottom: 0.5rem;
    padding-bottom: 0;
}

.tm-discussion-body .jquery-comments .navigation li {
    list-style: none;
}

.tm-discussion-body .jquery-comments .navigation li a,
.tm-discussion-body .jquery-comments .navigation li.active a {
    font-size: 0.813rem;
    padding: 6px 12px;
}

/* Comment items: clean separators like admin */
.tm-discussion-body .jquery-comments li.comment {
    list-style: none;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 12px;
    margin-bottom: 12px;
}

.tm-discussion-body .jquery-comments li.comment:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

/* Avatar sizing: match admin (40px) */
.tm-discussion-body .jquery-comments .profile-picture {
    width: 40px;
    height: 40px;
    min-width: 40px;
}

.tm-discussion-body .jquery-comments .profile-picture img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

/* Comment wrapper: generous spacing */
.tm-discussion-body .jquery-comments .comment-wrapper {
    padding: 0;
}

/* Name: clean font sizing */
.tm-discussion-body .jquery-comments .name {
    font-size: 0.875rem;
    font-weight: 600;
}

/* Staff comments: subtle left accent border */
.tm-discussion-body .jquery-comments li.comment.by-admin > .comment-wrapper {
    border-left: 3px solid #3b82f6;
    padding-left: 12px;
    margin-left: -3px;
}

/* Staff name badge */
.tm-staff-badge {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #3b82f6;
    background: #eff6ff;
    padding: 1px 6px;
    border-radius: 3px;
    margin-left: 6px;
    vertical-align: middle;
}

/* Client name styling */
.tm-discussion-body .jquery-comments li.comment:not(.by-admin) .name {
    color: #475569;
}

/* Staff name styling */
.tm-discussion-body .jquery-comments li.comment.by-admin .name {
    color: #1d4ed8;
}

/* Better threading: clean connector like admin */
.tm-discussion-body .jquery-comments .child-comments {
    border-left: 2px solid #e2e8f0;
    margin-left: 20px;
    padding-left: 16px;
    list-style: none;
    margin-top: 0;
}

/* Remove default bullet points */
.tm-discussion-body .jquery-comments ul,
.tm-discussion-body .jquery-comments li.comment {
    list-style: none;
}

.tm-discussion-body .jquery-comments .child-comments .child-comments {
    margin-left: 12px;
}

/* Child comments: lighter separator */
.tm-discussion-body .jquery-comments .child-comments > li.comment {
    border-bottom: 1px solid #f8fafc;
    padding-bottom: 10px;
    margin-bottom: 10px;
}

/* Reply-to indicator */
.tm-discussion-body .jquery-comments .reply-to {
    font-size: 0.75rem;
    color: #94a3b8;
    font-style: italic;
}

/* Action buttons: match admin style */
.tm-discussion-body .jquery-comments .actions {
    margin-top: 4px;
}

.tm-discussion-body .jquery-comments .actions .action {
    font-size: 0.813rem;
    color: #94a3b8;
    transition: color 0.15s;
    text-decoration: none;
}

.tm-discussion-body .jquery-comments .actions .action:hover {
    color: #3b82f6;
    text-decoration: none;
}

.tm-discussion-body .jquery-comments .actions .separator {
    color: #d1d5db;
    margin: 0 4px;
}

/* Comment content: match admin typography */
.tm-discussion-body .jquery-comments .content {
    font-size: 0.875rem;
    line-height: 1.6;
    color: #334155;
    margin-top: 2px;
}

/* Time display */
.tm-discussion-body .jquery-comments .time {
    font-size: 0.75rem;
    color: #94a3b8;
}

/* Images in comments: rounded like admin */
.tm-discussion-body .jquery-comments .content img {
    border-radius: 6px;
    max-width: 300px;
    height: auto;
}

/* Avatar fallback (initials) */
.tm-avatar-initials {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}

.tm-avatar-initials.staff {
    background: #3b82f6;
}

.tm-avatar-initials.client {
    background: #64748b;
}

/* Textarea: clean with focus state */
.tm-discussion-body .jquery-comments .textarea-wrapper {
    margin-bottom: 0.5rem;
}

.tm-discussion-body .jquery-comments .textarea-wrapper textarea {
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 0.75rem;
    font-size: 0.875rem;
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.tm-discussion-body .jquery-comments .textarea-wrapper textarea:focus {
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    outline: none;
}

/* Send/control row */
.tm-discussion-body .jquery-comments .control-row {
    margin-top: 0.25rem;
}

.tm-discussion-body .jquery-comments .control-row .send {
    border-radius: 0.375rem;
    font-size: 0.813rem;
}

/* Attachments upload button */
.tm-discussion-body .jquery-comments .textarea-wrapper .upload {
    opacity: 0.5;
    transition: opacity 0.15s;
}

.tm-discussion-body .jquery-comments .textarea-wrapper .upload:hover {
    opacity: 1;
}

/* Response flag inline on comment */
.tm-response-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    font-weight: 500;
    padding: 1px 8px;
    border-radius: 9999px;
    margin-left: 8px;
    vertical-align: middle;
}

.tm-response-indicator.pending {
    background: #fef2f2;
    color: #dc2626;
}

.tm-response-indicator.answered {
    background: #f0fdf4;
    color: #16a34a;
}

/* Tables inside comments (like the kolona1/kolona2 example) */
.tm-discussion-body .jquery-comments .content table {
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 0.813rem;
}

.tm-discussion-body .jquery-comments .content table td,
.tm-discussion-body .jquery-comments .content table th {
    border: 1px solid #e2e8f0;
    padding: 6px 12px;
}

.tm-discussion-body .jquery-comments .content table th {
    background: #f8fafc;
    font-weight: 600;
}

/* Comment content: better text rendering */
.tm-discussion-body .jquery-comments .content {
    font-size: 0.875rem;
    line-height: 1.6;
    color: #334155;
}

/* Comment time styling */
.tm-discussion-body .jquery-comments .wrapper .time {
    font-size: 0.75rem;
    color: #94a3b8;
}

/* Textarea focus state */
.tm-discussion-body .jquery-comments .textarea-wrapper textarea {
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 0.75rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.tm-discussion-body .jquery-comments .textarea-wrapper textarea:focus {
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    outline: none;
}

/* Send button styling */
.tm-discussion-body .jquery-comments .control-row .send {
    border-radius: 0.375rem;
}

/* ─── Milestone Stepper ─── */

.tm-stepper {
    display: flex;
    align-items: flex-start;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    gap: 0;
    -webkit-overflow-scrolling: touch;
}

.tm-stepper-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    min-width: 100px;
    flex: 1 1 0;
    text-align: center;
}

.tm-stepper-step .tm-step-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    position: relative;
    z-index: 2;
    flex-shrink: 0;
}

.tm-stepper-step.completed .tm-step-dot { background: #16a34a; }
.tm-stepper-step.current .tm-step-dot   { background: #3b82f6; animation: tm-pulse 2s ease-in-out infinite; }
.tm-stepper-step.upcoming .tm-step-dot  { background: #d1d5db; color: #9ca3af; }
.tm-stepper-step.overdue .tm-step-dot   { background: #ef4444; }

@keyframes tm-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4); }
    50%      { box-shadow: 0 0 0 8px rgba(59, 130, 246, 0); }
}

.tm-stepper-step .tm-step-label {
    margin-top: 0.5rem;
    font-size: 0.7rem;
    font-weight: 500;
    line-height: 1.2;
    max-width: 90px;
    word-wrap: break-word;
}

.tm-stepper-step.completed .tm-step-label { color: #16a34a; }
.tm-stepper-step.current .tm-step-label   { color: #1d4ed8; font-weight: 600; }
.tm-stepper-step.upcoming .tm-step-label  { color: #9ca3af; }
.tm-stepper-step.overdue .tm-step-label   { color: #dc2626; font-weight: 600; }

.tm-stepper-step .tm-step-meta {
    font-size: 0.65rem;
    color: #9ca3af;
    margin-top: 0.125rem;
}

.tm-stepper-step.overdue .tm-step-meta { color: #f87171; }

/* Connector line between steps */
.tm-stepper-connector {
    flex: 1 1 0;
    height: 2px;
    background: #e5e7eb;
    margin-top: 15px; /* center on dot */
    min-width: 16px;
}

.tm-stepper-connector.completed { background: #16a34a; }
.tm-stepper-connector.active    { background: linear-gradient(90deg, #16a34a 50%, #e5e7eb 50%); }

/* ─── Lightbox ─── */

.tm-lightbox .modal-body {
    padding: 0;
    text-align: center;
    background: #000;
    position: relative;
    min-height: 300px;
}

.tm-lightbox-img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
}

.tm-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.9);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
    transition: background 0.2s;
}

.tm-lightbox-nav:hover { background: #fff; }
.tm-lightbox-nav.prev { left: 12px; }
.tm-lightbox-nav.next { right: 12px; }

.tm-lightbox-counter {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.7);
    font-size: 0.813rem;
}

/* ─── Loading Spinner ─── */

.tm-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: tm-spin 0.6s linear infinite;
    margin: 0 auto;
}

@keyframes tm-spin {
    to { transform: rotate(360deg); }
}

/* ─── Sticky Header ─── */

.tm-sticky-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1040;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid #e5e7eb;
    padding: 0.625rem 0;
    transform: translateY(-100%);
    transition: transform 0.25s ease;
}

.tm-sticky-header.tm-sticky-visible {
    transform: translateY(0);
}

/* ─── File List ─── */

.tm-file-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.15s;
}

.tm-file-item:last-child { border-bottom: none; }
.tm-file-item:hover { background: #f8fafc; }

.tm-file-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    border-radius: 0.375rem;
    font-size: 1rem;
    flex-shrink: 0;
}

.tm-file-info {
    flex: 1;
    min-width: 0;
}

.tm-file-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tm-file-meta {
    font-size: 0.75rem;
    color: #94a3b8;
}

/* ─── Progress Bar Thick ─── */

.tm-progress-bar-thick {
    height: 8px;
}

/* ─── Tool Detail Header ─── */

.tm-tool-detail-header {
    /* Wrapper for CSS targeting */
}

/* ─── Responsive ─── */

@media (max-width: 768px) {
    .tm-card-grid {
        grid-template-columns: 1fr;
    }

    .tm-thumbnail-strip {
        overflow-x: auto;
    }

    /* Tool detail: stack image + info vertically */
    .tm-tool-detail-header > .tw-flex.tw-gap-6,
    .tm-tool-detail-header .tw-flex {
        flex-direction: column;
    }

    .tm-tool-detail-header .tm-tool-detail-img {
        width: 100% !important;
        height: auto !important;
        max-height: 200px;
    }

    /* Stepper: scroll horizontally */
    .tm-stepper {
        padding-bottom: 1rem;
    }

    .tm-stepper-step {
        min-width: 80px;
    }
}

@media (max-width: 480px) {
    .tm-card {
        padding: 1rem;
    }

    .tm-stepper-step .tm-step-dot {
        width: 26px;
        height: 26px;
        font-size: 0.65rem;
    }

    .tm-stepper-connector {
        margin-top: 12px;
    }
}
