:root {
    --primary: #1F4E79;
    --secondary: #D9E1F2;
    --success: #28a745;
    --text: #333;
    --bg: #f4f7f6;
}
* { box-sizing: border-box; }
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: var(--bg); color: var(--text); margin: 0; display: flex; height: 100vh; overflow: hidden; }

.sidebar { width: 250px; background-color: var(--primary); color: white; padding: 20px; display: flex; flex-direction: column; gap: 8px; position: relative; transition: background-color 0.3s; overflow-y: auto; }
.sidebar h2 { font-size: 1.1rem; text-align: center; margin-bottom: 15px; border-bottom: 1px solid rgba(255,255,255,0.2); padding-bottom: 10px; }

.tab-btn { background: none; border: 1px solid rgba(255,255,255,0.3); color: white; padding: 10px; cursor: pointer; border-radius: 5px; font-size: 0.95rem; transition: 0.3s; text-align: right; }
.tab-btn:hover, .tab-btn.active { background-color: rgba(255,255,255,0.2); font-weight: bold; }

.color-picker-container { margin-top: auto; background: rgba(0,0,0,0.1); padding: 10px; border-radius: 5px; display: flex; align-items: center; justify-content: space-between; margin-bottom: 40px; }

.main-content { flex-grow: 1; padding: 30px; overflow-y: auto; height: 100%; }
.tab-content { display: none; background: white; padding: 25px; border-radius: 8px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
.tab-content.active { display: block; }

table { width: 100%; border-collapse: collapse; margin-top: 15px; margin-bottom: 25px; }
th, td { border: 1px solid #ddd; padding: 10px; text-align: right; font-size: 0.95rem; }
th { background-color: var(--primary); color: white; transition: background-color 0.3s; }
tr:nth-child(even) { background-color: #f9f9f9; }
input[type="number"] { width: 70px; padding: 6px; border: 1px solid #ccc; border-radius: 4px; text-align: center; }
.total-row { font-weight: bold; background-color: #eef2f7 !important; font-size: 1.05rem; }

/* Contract Styles */
.contract-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 30px; border-bottom: 2px solid var(--primary); padding-bottom: 20px; transition: border-color 0.3s; }
.logo-area { text-align: right; display: flex; flex-direction: column; gap: 5px; }
.architect-name-input { font-size: 24px; font-weight: bold; color: var(--primary); border: none; border-bottom: 1px dashed #999; background: transparent; font-family: inherit; width: 300px; outline: none; transition: color 0.3s; max-width: 100%; }
.architect-subtitle { font-size: 16px; color: #666; border: none; border-bottom: 1px dashed #999; background: transparent; font-family: inherit; width: 300px; outline: none; max-width: 100%; }
#custom-logo { display: none; margin-bottom: 10px; object-fit: contain; max-width: 100%; }

.contract-details input { border: none; border-bottom: 1px dashed #999; padding: 5px; font-size: 1rem; font-family: inherit; width: 200px; background: transparent; outline: none; max-width: 100%; }
.contract-details input:focus { border-bottom: 1px solid var(--primary); }

.legal-text { font-size: 0.85rem; line-height: 1.5; margin-top: 30px; }
.legal-text h3 { color: var(--primary); font-size: 1rem; margin-top: 20px; margin-bottom: 10px; transition: color 0.3s; }
.legal-text ul { padding-right: 20px; margin-top: 5px; }
.legal-text li { margin-bottom: 5px; }

.scope-of-work { width: 100%; min-height: 150px; border: 1px dashed #999; padding: 20px; border-radius: 5px; outline: none; background: #fafafa; font-family: inherit; margin-bottom: 25px; line-height: 1.6; font-size: 0.9rem; }
.scope-of-work:focus { border: 1px solid var(--primary); background: #fff; }

.editable-notes { width: 100%; min-height: 60px; border: 1px dashed #999; padding: 15px; border-radius: 5px; outline: none; background: #fafafa; font-family: inherit; margin-top: 10px; margin-bottom: 20px; line-height: 1.5; font-size: 0.9rem; }
.editable-notes:empty:before { content: attr(placeholder); color: #888; }
.editable-notes:focus { border: 1px solid var(--primary); background: #fff; }

.signatures-container { display: flex; justify-content: space-around; margin-top: 40px; flex-wrap: wrap; gap: 20px; }
.sig-box { text-align: center; width: 100%; max-width: 250px; font-size: 0.9rem; }
.sig-canvas { border: 1px solid #ccc; border-radius: 5px; cursor: crosshair; background: #fff; touch-action: none; width: 100%; height: 90px; }
.clear-sig-btn { background: #eee; border: 1px solid #ccc; padding: 5px 10px; border-radius: 3px; cursor: pointer; font-size: 0.8rem; margin-top: 5px; transition: 0.2s; width: 100%; }

.controls { margin-bottom: 20px; padding: 15px; background: #fff3cd; border-radius: 5px; border: 1px solid #ffeeba; display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 15px; }
.btn-print { background-color: var(--success); color: white; border: none; padding: 10px 20px; border-radius: 5px; cursor: pointer; font-size: 1rem; font-weight: bold; }
.btn-save { background-color: #007bff; color: white; border: none; padding: 10px 20px; border-radius: 5px; cursor: pointer; font-size: 1rem; font-weight: bold; }

.copyright-notice { margin-top: 30px; text-align: center; font-size: 11px; color: #777; display: flex; flex-direction: column; align-items: center; gap: 5px; border-top: 1px solid #eee; padding-top: 15px;}
.sidebar-copyright { position: absolute; bottom: 10px; right: 0; left: 0; text-align: center; font-size: 10px; color: rgba(255,255,255,0.6); }

/* Mobile Responsiveness */
@media (max-width: 768px) {
    body { flex-direction: column; overflow: auto; height: auto; }
    .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; justify-content: center; padding: 10px; position: sticky; top: 0; z-index: 1000; height: auto; overflow: visible; box-shadow: 0 2px 5px rgba(0,0,0,0.2); gap: 5px; }
    .sidebar h2 { width: 100%; margin-bottom: 5px; padding-bottom: 5px; font-size: 1rem; border: none; }
    .tab-btn { padding: 8px 10px; font-size: 0.85rem; flex-grow: 1; text-align: center; margin: 2px; }
    .sidebar-copyright { display: none; } 
    .color-picker-container { width: 100%; justify-content: center; gap: 10px; margin-top: 5px; padding: 5px; margin-bottom: 0; }
    .main-content { padding: 15px; height: auto; overflow: visible; }
    table { display: block; overflow-x: auto; white-space: nowrap; font-size: 0.85rem; }
    .controls { flex-direction: column; align-items: stretch; text-align: center; }
}

/* Print Settings */
@media print {
    body { background: white; display: block; height: auto; overflow: visible; font-size: 12px; }
    .sidebar, .controls, .clear-sig-btn, .tab-btn, .hide-print { display: none !important; }
    .main-content { padding: 0; margin: 0; overflow: visible; width: 100%; }
    .tab-content { box-shadow: none; padding: 0; border: none; display: none; }
    #contract { display: block; }
    table { display: table; overflow: visible; white-space: normal; font-size: 12px; }
    .contract-details input, .architect-name-input, .architect-subtitle { border-bottom: none; }
    .editable-notes, .scope-of-work { border: none; background: transparent; padding: 0; }
    .editable-notes:empty { display: none; }
    .sig-canvas { border: none !important; border-bottom: 1px solid #000 !important; border-radius: 0; height: 60px;}
}
