/* ==================================================
   TERMS & CONDITIONS PAGE STYLES
   Professional contract layout with multi-page support
   ================================================== */

/* Ensure page-content can scroll when Terms & Conditions is loaded */
#page-content:has(.tc-wrapper) {
    overflow-y: auto !important;
    height: 100vh !important;
    max-height: 100vh !important;
    background: transparent !important;
}

/* Global text wrapping for all contract elements */
.tc-page-container * {
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    box-sizing: border-box;
}

/* Wrapper for centering content - long scrolling page */
.tc-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    min-height: 100%;
    position: relative;
    padding-bottom: 100px;
}

/* A4 Page Container - Long scrolling page for screen, breaks to A4 in print */
.tc-page-container {
    width: 210mm;
    max-width: 210mm;
    min-height: auto;
    display: block;
    padding: 20mm 18mm 20mm 18mm;
    box-shadow: 0 3px 15px rgba(0,0,0,0.08);
    border: 1px solid #e5e7eb;
    border-radius: 5px;
    margin: 30px auto 50px auto;
    transform-origin: top center;
    background-color: #fff;
    box-sizing: border-box;
    /* Long scrolling page - no height restriction */
    height: auto;
    overflow: visible;
    word-wrap: break-word;
    overflow-wrap: break-word;
    position: relative;
}

/* ==================================================
   HEADER SECTION
   ================================================== */

.tc-header {
    text-align: center;
    padding-bottom: 15px;
    border-bottom: 3px solid var(--brand-primary, #2063BE);
    margin-bottom: 20px;
    max-width: 100%;
}

.tc-header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    color: #1a202c;
    margin: 0 0 10px 0;
    text-transform: uppercase;
    letter-spacing: 1px;
    word-wrap: break-word;
}

.tc-header .tc-subtitle {
    font-size: 1.15rem;
    color: #4a5568;
    font-weight: 500;
    margin: 0;
    word-wrap: break-word;
}

/* ==================================================
   PARTIES SECTION
   ================================================== */

.tc-parties-section {
    background-color: #f8f9fa;
    border-left: 4px solid var(--brand-primary, #2063BE);
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 4px;
    max-width: 100%;
    box-sizing: border-box;
}

.tc-parties-section h2 {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--brand-primary, #2063BE);
    margin: 0 0 15px 0;
    word-wrap: break-word;
}

.tc-party-info {
    margin-bottom: 20px;
}

.tc-party-info:last-child {
    margin-bottom: 0;
}

.tc-party-label {
    font-weight: 700;
    font-size: 1.1rem;
    color: #2d3748;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tc-party-details {
    padding-left: 15px;
    line-height: 1.7;
    color: #2d3748;
    font-size: 1rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.tc-party-details p {
    margin: 5px 0;
    word-wrap: break-word;
    font-size: 1rem;
}

.tc-party-name {
    font-weight: 600;
    color: #1a202c;
    font-size: 1.15rem;
    word-wrap: break-word;
}

/* ==================================================
   CONTRACT CONTENT SECTIONS
   ================================================== */

.tc-content {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.tc-section {
    margin-bottom: 20px;
    page-break-inside: avoid;
    break-inside: avoid; /* Modern browsers */
    max-width: 100%;
    box-sizing: border-box;
}

.tc-section h2 {
    font-size: 1.3rem;
    font-weight: 700;
    color: #1a202c;
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #e2e8f0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    word-wrap: break-word;
}

.tc-section h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2d3748;
    margin: 15px 0 10px 0;
    word-wrap: break-word;
}

.tc-section p {
    line-height: 1.8;
    color: #2d3748;
    font-size: 1rem;
    margin-bottom: 12px;
    text-align: justify;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.tc-section p strong,
.tc-section strong {
    font-weight: 700;
    color: #1a202c;
    font-size: 1.05rem;
}

.tc-section ul,
.tc-section ol {
    margin: 10px 0 12px 0;
    padding-left: 25px;
    max-width: 100%;
    box-sizing: border-box;
}

.tc-section li {
    line-height: 1.8;
    color: #2d3748;
    font-size: 1rem;
    margin-bottom: 8px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Numbered clauses */
.tc-clause {
    margin-bottom: 15px;
}

.tc-clause-number {
    font-weight: 700;
    color: var(--brand-primary, #2063BE);
    margin-right: 6px;
}

/* Important notices */
.tc-notice {
    background-color: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 12px;
    margin: 15px 0;
    border-radius: 4px;
    max-width: 100%;
    box-sizing: border-box;
}

.tc-notice p {
    margin: 0;
    color: #856404;
    font-weight: 500;
    font-size: 0.9rem;
    word-wrap: break-word;
}

/* Terms table */
.tc-terms-table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    table-layout: fixed;
    box-sizing: border-box;
}

.tc-terms-table th,
.tc-terms-table td {
    border: 1px solid #dee2e6;
    padding: 10px;
    text-align: left;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.tc-terms-table th {
    background-color: var(--brand-primary, #2063BE);
    color: white;
    font-weight: 600;
    font-size: 1rem;
}

.tc-terms-table td {
    color: #2d3748;
    font-size: 1rem;
}

/* ==================================================
   SIGNATURE SECTION
   ================================================== */

.tc-signature-section {
    margin-top: 30px;
    margin-bottom: 80px;
    padding-top: 20px;
    padding-bottom: 60px;
    border-top: 2px solid #dee2e6;
    page-break-inside: avoid;
    break-inside: avoid; /* Modern browsers */
    page-break-before: auto; /* Allow page break before if needed */
    max-width: 100%;
    box-sizing: border-box;
}

.tc-signature-section h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: #1a202c;
    margin: 0 0 20px 0;
    text-align: center;
    word-wrap: break-word;
}

.tc-signature-section > p {
    font-size: 1rem;
    line-height: 1.6;
    word-wrap: break-word;
    color: #2d3748;
}

.tc-signature-boxes {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-top: 20px;
    max-width: 100%;
    box-sizing: border-box;
}

.tc-signature-box {
    flex: 1;
    min-width: 0;
    max-width: 48%;
    box-sizing: border-box;
}

.tc-signature-line {
    border-bottom: 2px solid #1a202c;
    height: 50px;
    margin-bottom: 8px;
}

.tc-signature-label {
    font-weight: 600;
    color: #1a202c;
    margin-bottom: 5px;
    font-size: 1.05rem;
    word-wrap: break-word;
}

.tc-signature-info {
    color: #2d3748;
    font-size: 0.95rem;
    line-height: 1.6;
}

.tc-signature-info p {
    margin: 6px 0;
    word-wrap: break-word;
}

.tc-date-line {
    display: flex;
    align-items: center;
    margin-top: 12px;
    gap: 8px;
}

.tc-date-line label {
    font-weight: 600;
    color: #1a202c;
    margin: 0;
    font-size: 0.95rem;
}

.tc-date-line .tc-date-input {
    border-bottom: 1px solid #1a202c;
    flex: 1;
    min-width: 120px;
    font-size: 0.95rem;
}

/* ==================================================
   FOOTER
   ================================================== */

.tc-footer {
    margin-top: 30px;
    margin-left: 0;
    margin-right: 0;
    margin-bottom: 0;
    padding: 12px 15px;
    background-color: var(--brand-primary, #2063BE);
    color: white;
    font-size: 0.85rem;
    text-align: center;
    border-radius: 0 0 5px 5px;
    max-width: 100%;
    box-sizing: border-box;
    word-wrap: break-word;
    position: relative;
}

.tc-footer p {
    margin: 0;
    line-height: 1.5;
    word-wrap: break-word;
}

.tc-footer a {
    color: white;
    text-decoration: underline;
    word-wrap: break-word;
}

.tc-footer a:hover {
    color: #eee;
}

/* ==================================================
   FLOATING ACTION BUTTONS
   ================================================== */

.tc-fab-container {
    position: fixed !important;
    right: 20px !important;
    z-index: 1000 !important;
}

.tc-fab-container .action-fab {
    position: fixed !important;
    right: 20px !important;
}

/* ==================================================
   TOAST NOTIFICATION
   ================================================== */

#tc-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 25px;
    background-color: rgba(76,175,80, 0.9);
    color: #fff;
    border-radius: 5px;
    display: none;
    z-index: 9999;
    font-size: 14px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

/* ==================================================
   PROJECT MANAGER MODAL - MATCHES SOW/OBJECTIVES
   ================================================== */

#tcProjectModal .modal-xl-custom {
    max-width: 950px;
    min-width: 800px;
}

#tcProjectModal .explorer-content {
    display: flex;
    width: 100%;
    gap: 25px;
    flex-grow: 1;
}

#tcProjectModal .explorer-section {
    flex: 1;
    display: flex;
    flex-direction: column;
}

#tcProjectModal .section-header {
    font-size: 1.15rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 12px;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
}

#tcProjectModal .explorer-list {
    min-width: 200px;
    flex-basis: 250px;
    max-height: 500px;
    min-height: 350px;
    overflow-y: auto;
    border: 1px solid #ddd;
    padding: 10px;
    border-radius: 5px;
    background-color: #fff;
    flex-grow: 1;
}

#tcProjectModal .search-sort-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

#tcProjectModal .search-input {
    flex-grow: 1;
    padding: 9px 12px;
    font-size: 14px;
    border-radius: 5px;
    min-width: 150px;
}

#tcProjectModal .breadcrumbs {
    margin-bottom: 15px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    font-size: 14px;
    color: #6c757d;
    padding: 5px;
    background-color: #f8f9fa;
    border-radius: 4px;
}

#tcProjectModal .breadcrumb-item {
    cursor: pointer;
    color: #007bff;
    padding: 3px 5px;
    border-radius: 3px;
}

#tcProjectModal .breadcrumb-item:hover {
    background-color: #e2e6ea;
    color: #0056b3;
}

#tcProjectModal .breadcrumb-separator {
    margin: 0 5px;
    color: #6c757d;
}

#tcProjectModal .project-list-item {
    padding: 9px 12px;
    margin: 6px 0;
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#tcProjectModal .project-list-item:hover {
    background: #f8f9fa;
    border-color: #dee2e6;
}

#tcProjectModal .file-icon {
    margin-right: 12px;
    font-size: 1.5rem;
    color: #6c757d;
}

#tcProjectModal .file-name {
    flex-grow: 1;
    cursor: pointer;
    color: #333;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#tcProjectModal .file-name:hover {
    color: #007bff;
}

#tcProjectModal .project-list-item .actions {
    display: flex;
    align-items: center;
    position: relative;
    flex-shrink: 0;
}

#tcProjectModal .ellipsis-btn {
    background: transparent;
    border: none;
    padding: 4px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    color: #6c757d;
}

#tcProjectModal .ellipsis-btn:hover {
    background: #e9ecef;
    color: #333;
}

#tcProjectModal .item-options-menu {
    display: none;
    position: absolute;
    right: 100%;
    margin-right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: #fff;
    border-radius: 5px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 6px;
    z-index: 20;
    flex-direction: row;
    gap: 6px;
    border: 1px solid #ddd;
}

#tcProjectModal .ellipsis-btn.active + .item-options-menu,
#tcProjectModal .item-options-menu.active {
    display: flex;
}

#tcProjectModal .menu-btn {
    padding: 4px 8px;
    font-size: 11px;
    border-radius: 4px;
    border: 1px solid #ccc;
    background: #fff;
    cursor: pointer;
}

#tcProjectModal .menu-btn.delete-btn {
    color: #dc3545;
}

#tcProjectModal .menu-btn.delete-btn:hover {
    background: #dc3545;
    color: #fff;
    border-color: #c82333;
}

#tcProjectModal .create-folder-btn {
    background-color: #007bff;
    color: white;
}

#tcProjectModal .create-folder-btn:hover {
    background-color: #0056b3;
}

#tcProjectModal .save-btn {
    background-color: #28a745;
    color: white;
}

#tcProjectModal .save-btn:hover {
    background-color: #218838;
}

#tcProjectModal .refresh-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    padding: 6px 10px;
    font-size: 12px;
}

/* ==================================================
   PRINT STYLES
   ================================================== */

@media print {
    @page {
        size: A4 portrait;
        margin: 15mm 12mm;
    }

    body {
        margin: 0;
        padding: 0;
        background: white !important;
    }

    /* Remove background for print */
    .tc-wrapper {
        margin: 0 !important;
        padding: 0 !important;
        background: white !important;
    }

    /* Clean A4 pages for print */
    .tc-page-container {
        width: 100% !important;
        max-width: 100% !important;
        min-height: 0 !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 0 40px 0 !important;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        box-sizing: border-box !important;
        overflow: visible !important;
        page-break-after: auto;
        display: block !important;
        background: white !important;
    }

    .tc-header {
        page-break-after: avoid;
        break-after: avoid;
        padding-top: 0;
    }

    .tc-parties-section {
        page-break-inside: avoid;
        page-break-after: avoid;
        break-inside: avoid;
        break-after: avoid;
    }

    .tc-content {
        display: block;
    }

    .tc-section {
        page-break-inside: avoid;
        break-inside: avoid;
        orphans: 3;
        widows: 3;
    }

    /* Force page break before signature if needed */
    .tc-signature-section {
        page-break-before: auto;
        page-break-inside: avoid;
        break-before: auto;
        break-inside: avoid;
        orphans: 3;
        widows: 3;
    }

    .tc-signature-boxes {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .tc-footer {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        margin: 0 !important;
        padding: 8px 12px !important;
        background-color: var(--brand-primary, #2063BE) !important;
        color: white !important;
        font-size: 10px !important;
        text-align: center !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        border-radius: 0 !important;
        z-index: 99999;
        display: block !important;
        box-sizing: border-box !important;
    }
    
    .tc-footer p {
        margin: 0 !important;
        color: white !important;
    }
    
    .tc-footer a {
        color: white !important;
    }

    .tc-fab-container,
    #tc-toast {
        display: none !important;
    }

    .tc-header,
    .tc-footer,
    .tc-parties-section,
    .tc-terms-table th {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ==================================================
   RESPONSIVE DESIGN
   ================================================== */

@media (max-width: 768px) {
    .tc-page-container {
        width: 100%;
        max-width: 100%;
        margin: 10px auto;
        padding: 15px;
    }

    .tc-header h1 {
        font-size: 1.5rem;
    }

    .tc-signature-boxes {
        flex-direction: column;
        gap: 20px;
    }
}

/* ==================================================
   DASHBOARD INTEGRATION
   ================================================== */

/* Ensure scrolling works in dashboard context */
body:has(.tc-wrapper) #page-content,
#page-content:has(.tc-wrapper) {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    height: 100% !important;
    max-height: 100vh !important;
}

/* Make sure wrapper takes full available space */
#page-content .tc-wrapper {
    min-height: 100%;
    height: auto;
}

/* Ensure FABs stay visible while scrolling */
.tc-fab-container {
    position: fixed !important;
    pointer-events: auto !important;
}

/* Add padding to bottom of page for FABs */
#page-content:has(.tc-wrapper) {
    padding-bottom: 100px;
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}
